MCPcopy Create free account
hub / github.com/ElementsProject/lightning / reexec_args

Function reexec_args

lightningd/lightningd.c:1194–1220  ·  view source on GitHub ↗

~ We store a copy of our arguments before parsing mangles them, so we can * re-exec if versions of subdaemons change. Minus --recover, which would * only fail now: we stay offline instead. */

Source from the content-addressed store, hash-verified

1192 * re-exec if versions of subdaemons change. Minus --recover, which would
1193 * only fail now: we stay offline instead. */
1194static char **reexec_args(const tal_t *ctx, int argc, char *argv[])
1195{
1196 char **args = tal_arr(ctx, char *, 0);
1197 bool recovered = false, offline = false;
1198
1199 /*~ Turn argv[0] into an absolute path (if not already) */
1200 tal_arr_expand(&args, path_join(args, take(path_cwd(NULL)), argv[0]));
1201 for (size_t i = 1; i < argc; i++) {
1202 char *val;
1203 size_t n = opt_args(argv, i, "--recover", &val);
1204
1205 if (!n)
1206 n = opt_args(argv, i, "--recover-fd", &val);
1207 if (n) {
1208 recovered = true;
1209 i += n - 1;
1210 continue;
1211 }
1212 if (streq(argv[i], "--offline"))
1213 offline = true;
1214 tal_arr_expand(&args, tal_strdup(args, argv[i]));
1215 }
1216 if (recovered && !offline)
1217 tal_arr_expand(&args, tal_strdup(args, "--offline"));
1218 tal_arr_expand(&args, NULL);
1219 return args;
1220}
1221
1222/* Anyone can read argv (e.g. ps), so wipe the secret once parsed. */
1223static void scrub_recover_secret(char *argv[])

Callers 1

mainFunction · 0.85

Calls 3

path_joinFunction · 0.85
path_cwdFunction · 0.85
opt_argsFunction · 0.85

Tested by

no test coverage detected