tools: unify exit() calls outside of main()

This also changes the help exit status of lxc-unshare and lxc-usernsexec. So far they did exit(EXIT_FAILURE) whereas all other tools do exit(EXIT_SUCCESS). Let's align them with the rest of the tools. This should be safe to do. Signed-off-by: 's avatarChristian Brauner <cbrauner@suse.de>
parent b52b0595
...@@ -89,7 +89,7 @@ static void usage(const char *me) ...@@ -89,7 +89,7 @@ static void usage(const char *me)
printf(" -p: use container orig from custom lxcpath\n"); printf(" -p: use container orig from custom lxcpath\n");
printf(" -P: create container new in custom lxcpath\n"); printf(" -P: create container new in custom lxcpath\n");
printf(" -R: rename existing container\n"); printf(" -R: rename existing container\n");
exit(1); exit(EXIT_SUCCESS);
} }
static struct option options[] = { static struct option options[] = {
......
...@@ -45,7 +45,7 @@ static void usage(char *me) ...@@ -45,7 +45,7 @@ static void usage(char *me)
{ {
printf("Usage: %s -l: list all available configuration items\n", me); printf("Usage: %s -l: list all available configuration items\n", me);
printf(" %s item: print configuration item\n", me); printf(" %s item: print configuration item\n", me);
exit(1); exit(EXIT_SUCCESS);
} }
static void list_config_items(void) static void list_config_items(void)
...@@ -54,7 +54,7 @@ static void list_config_items(void) ...@@ -54,7 +54,7 @@ static void list_config_items(void)
for (i = &items[0]; i->name; i++) for (i = &items[0]; i->name; i++)
printf("%s\n", i->name); printf("%s\n", i->name);
exit(0); exit(EXIT_SUCCESS);
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
......
...@@ -66,7 +66,7 @@ static bool is_interface(const char* dev_name, pid_t pid) ...@@ -66,7 +66,7 @@ static bool is_interface(const char* dev_name, pid_t pid)
if (p < 0) { if (p < 0) {
SYSERROR("failed to fork task."); SYSERROR("failed to fork task.");
exit(1); exit(EXIT_FAILURE);
} }
if (p == 0) { if (p == 0) {
...@@ -86,10 +86,10 @@ static bool is_interface(const char* dev_name, pid_t pid) ...@@ -86,10 +86,10 @@ static bool is_interface(const char* dev_name, pid_t pid)
/* Iterate through the interfaces */ /* Iterate through the interfaces */
for (tempIfAddr = interfaceArray; tempIfAddr != NULL; tempIfAddr = tempIfAddr->ifa_next) { for (tempIfAddr = interfaceArray; tempIfAddr != NULL; tempIfAddr = tempIfAddr->ifa_next) {
if (strcmp(tempIfAddr->ifa_name, dev_name) == 0) { if (strcmp(tempIfAddr->ifa_name, dev_name) == 0) {
exit(0); exit(EXIT_SUCCESS);
} }
} }
exit(1); exit(EXIT_FAILURE);
} }
if (wait_for_pid(p) == 0) { if (wait_for_pid(p) == 0) {
......
...@@ -77,7 +77,7 @@ static void usage(char *cmd) ...@@ -77,7 +77,7 @@ static void usage(char *cmd)
fprintf(stderr, "\t -H <hostname>: Set the hostname in the container\n"); fprintf(stderr, "\t -H <hostname>: Set the hostname in the container\n");
fprintf(stderr, "\t -d : Daemonize (do not wait for container to exit)\n"); fprintf(stderr, "\t -d : Daemonize (do not wait for container to exit)\n");
fprintf(stderr, "\t -M : reMount default fs inside container (/proc /dev/shm /dev/mqueue)\n"); fprintf(stderr, "\t -M : reMount default fs inside container (/proc /dev/shm /dev/mqueue)\n");
_exit(1); _exit(EXIT_SUCCESS);
} }
static bool lookup_user(const char *optarg, uid_t *uid) static bool lookup_user(const char *optarg, uid_t *uid)
...@@ -134,13 +134,13 @@ static int do_start(void *arg) ...@@ -134,13 +134,13 @@ static int do_start(void *arg)
if ((flags & CLONE_NEWUTS) && want_hostname) if ((flags & CLONE_NEWUTS) && want_hostname)
if (sethostname(want_hostname, strlen(want_hostname)) < 0) { if (sethostname(want_hostname, strlen(want_hostname)) < 0) {
ERROR("failed to set hostname %s: %s", want_hostname, strerror(errno)); ERROR("failed to set hostname %s: %s", want_hostname, strerror(errno));
exit(1); exit(EXIT_FAILURE);
} }
// Setuid is useful even without a new user id space // Setuid is useful even without a new user id space
if (start_arg->setuid && setuid(uid)) { if (start_arg->setuid && setuid(uid)) {
ERROR("failed to set uid %d: %s", uid, strerror(errno)); ERROR("failed to set uid %d: %s", uid, strerror(errno));
exit(1); exit(EXIT_FAILURE);
} }
execvp(args[0], args); execvp(args[0], args);
...@@ -177,7 +177,7 @@ int main(int argc, char *argv[]) ...@@ -177,7 +177,7 @@ int main(int argc, char *argv[])
case 'i': case 'i':
if (!(tmpif = malloc(sizeof(*tmpif)))) { if (!(tmpif = malloc(sizeof(*tmpif)))) {
perror("malloc"); perror("malloc");
exit(1); exit(EXIT_FAILURE);
} }
tmpif->mi_ifname = optarg; tmpif->mi_ifname = optarg;
tmpif->mi_next = my_iflist; tmpif->mi_next = my_iflist;
...@@ -246,7 +246,7 @@ int main(int argc, char *argv[]) ...@@ -246,7 +246,7 @@ int main(int argc, char *argv[])
} }
if (daemonize) if (daemonize)
exit(0); exit(EXIT_SUCCESS);
if (waitpid(pid, &status, 0) < 0) { if (waitpid(pid, &status, 0) < 0) {
ERROR("failed to wait for '%d'", pid); ERROR("failed to wait for '%d'", pid);
......
...@@ -71,7 +71,7 @@ static void usage(const char *name) ...@@ -71,7 +71,7 @@ static void usage(const char *name)
printf(" Note: This program uses newuidmap(2) and newgidmap(2).\n"); printf(" Note: This program uses newuidmap(2) and newgidmap(2).\n");
printf(" As such, /etc/subuid and /etc/subgid must grant the\n"); printf(" As such, /etc/subuid and /etc/subgid must grant the\n");
printf(" calling user permission to use the mapped ranges\n"); printf(" calling user permission to use the mapped ranges\n");
exit(1); exit(EXIT_SUCCESS);
} }
static void opentty(const char * tty, int which) { static void opentty(const char * tty, int which) {
......
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