]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
fix up lxc-usernsexec's exit status
authorTycho Andersen <tycho@tycho.ws>
Mon, 8 Jan 2018 16:20:24 +0000 (16:20 +0000)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 19 Jan 2018 13:40:05 +0000 (14:40 +0100)
* exit(1) when there is an option parsing error
* exit(0) when the user explicitly asks for help
* exit(1) when the user specifies an invalid option

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
src/lxc/tools/lxc_usernsexec.c

index ee94e39f642c75372aa0eb268358580084436e43..5d48372ba04cae1c465962180b252c63b0b9c559 100644 (file)
@@ -71,7 +71,6 @@ static void usage(const char *name)
        printf("  Note: This program uses newuidmap(2) and newgidmap(2).\n");
        printf("        As such, /etc/subuid and /etc/subgid must grant the\n");
        printf("        calling user permission to use the mapped ranges\n");
-       exit(EXIT_SUCCESS);
 }
 
 static void opentty(const char * tty, int which) {
@@ -300,10 +299,18 @@ int main(int argc, char *argv[])
 
        while ((c = getopt(argc, argv, "m:h")) != EOF) {
                switch (c) {
-                       case 'm': if (parse_map(optarg)) usage(argv[0]); break;
+                       case 'm':
+                               if (parse_map(optarg)) {
+                                       usage(argv[0]);
+                                       exit(EXIT_FAILURE);
+                               }
+                               break;
                        case 'h':
+                                 usage(argv[0]);
+                                 exit(EXIT_SUCCESS);
                        default:
                                  usage(argv[0]);
+                                 exit(EXIT_FAILURE);
                }
        };