diff options
Diffstat (limited to 'src/machine-id-setup/machine-id-setup-main.c')
-rw-r--r-- | src/machine-id-setup/machine-id-setup-main.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/machine-id-setup/machine-id-setup-main.c b/src/machine-id-setup/machine-id-setup-main.c index a9c4e3fadf..f1165ea09c 100644 --- a/src/machine-id-setup/machine-id-setup-main.c +++ b/src/machine-id-setup/machine-id-setup-main.c @@ -27,8 +27,9 @@ #include "log.h" #include "machine-id-setup.h" #include "util.h" +#include "path-util.h" -static const char *arg_root = NULL; +static char *arg_root = NULL; static bool arg_commit = false; static void help(void) { @@ -57,7 +58,7 @@ static int parse_argv(int argc, char *argv[]) { {} }; - int c; + int c, r; assert(argc >= 0); assert(argv); @@ -74,7 +75,9 @@ static int parse_argv(int argc, char *argv[]) { return version(); case ARG_ROOT: - arg_root = optarg; + r = parse_path_argument_and_warn(optarg, true, &arg_root); + if (r < 0) + return r; break; case ARG_COMMIT: @@ -104,13 +107,14 @@ int main(int argc, char *argv[]) { r = parse_argv(argc, argv); if (r <= 0) - return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; + goto finish; if (arg_commit) r = machine_id_commit(arg_root); else r = machine_id_setup(arg_root); - +finish: + free(arg_root); return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; } |