Description: Require an argument for lxc-unshare
 It segfaults otherwise trying to execute &NULL.
Author: Serge Hallyn <serge.hallyn@ubuntu.com>
Forwarded: yes
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1011603

Index: lxc-0.8.0~rc1/src/lxc/lxc_unshare.c
===================================================================
--- lxc-0.8.0~rc1.orig/src/lxc/lxc_unshare.c	2011-10-25 12:02:11.000000000 +0000
+++ lxc-0.8.0~rc1/src/lxc/lxc_unshare.c	2012-06-11 15:44:52.906269292 +0000
@@ -44,12 +44,11 @@
 
 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 @@
 		}
 	}
 
+    if (argv[optind] == NULL) {
+        ERROR("a command to execute in the new namespace is required");
+        return 1;
+    }
+
 	args = &argv[optind];
 
 	ret = lxc_caps_init();
