]> git.proxmox.com Git - mirror_lxc.git/commitdiff
lxc-unshare: require an argument
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Tue, 31 Jul 2012 14:07:18 +0000 (16:07 +0200)
committerDaniel Lezcano <daniel.lezcano@free.fr>
Tue, 31 Jul 2012 14:07:18 +0000 (16:07 +0200)
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: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/lxc_unshare.c

index 0baccb007dfa52c1b2f530199fdb176504ebdfb1..498d6e0e65423a20b071921f693d4079bd903680 100644 (file)
@@ -44,12 +44,11 @@ lxc_log_define(lxc_unshare_ui, lxc);
 
 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, "\t -s flags: ORed list of flags to unshare:\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 if -s PID is specified, <command> is mandatory)\n");
        _exit(1);
 }
 
@@ -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];
 
        ret = lxc_caps_init();