~ 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. */
| 1192 | * re-exec if versions of subdaemons change. Minus --recover, which would |
| 1193 | * only fail now: we stay offline instead. */ |
| 1194 | static 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. */ |
| 1223 | static void scrub_recover_secret(char *argv[]) |