Commit a11a544f by Serge Hallyn Committed by Daniel Lezcano

lxc-unshare: require an argument

It segfaults otherwise trying to execute &NULL. We could alternatively guess at a command to execute, such as a shell, but invariably there would be cases where the command we guess does not exist. Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com> Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 30c5d292
...@@ -44,12 +44,11 @@ lxc_log_define(lxc_unshare_ui, lxc); ...@@ -44,12 +44,11 @@ lxc_log_define(lxc_unshare_ui, lxc);
void usage(char *cmd) void usage(char *cmd)
{ {
fprintf(stderr, "%s <options> [command]\n", basename(cmd)); fprintf(stderr, "%s <options> command [command_arguments]\n", basename(cmd));
fprintf(stderr, "Options are:\n"); fprintf(stderr, "Options are:\n");
fprintf(stderr, "\t -s flags: ORed list of flags to unshare:\n" \ fprintf(stderr, "\t -s flags: ORed list of flags to unshare:\n" \
"\t MOUNT, PID, UTSNAME, IPC, USER, NETWORK\n"); "\t MOUNT, PID, UTSNAME, IPC, USER, NETWORK\n");
fprintf(stderr, "\t -u <id> : new id to be set if -s USER is specified\n"); fprintf(stderr, "\t -u <id> : new id to be set if -s USER is specified\n");
fprintf(stderr, "\t if -s PID is specified, <command> is mandatory)\n");
_exit(1); _exit(1);
} }
...@@ -184,6 +183,11 @@ int main(int argc, char *argv[]) ...@@ -184,6 +183,11 @@ int main(int argc, char *argv[])
} }
} }
if (argv[optind] == NULL) {
ERROR("a command to execute in the new namespace is required");
return 1;
}
args = &argv[optind]; args = &argv[optind];
ret = lxc_caps_init(); ret = lxc_caps_init();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment