clone: return instead of exit()
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 22 Dec 2011 02:32:45 +0000 (21:32 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 22 Dec 2011 02:32:45 +0000 (21:32 -0500)
Calling exit() from the cloned process is a bad idea, because we share
file descriptors with the parent, and exit() has side-effects (anyway,
more than the low-level _exit()).

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
librunas/runas.c

index ba361d6d63156a3361816a83bc1c0ae1b3a692da..0ffe52ea3792ad8f9e0e6a4d8933bff13c96d998 100644 (file)
@@ -149,14 +149,14 @@ int child_run_as(void *_data)
                ret = setegid(data->gid);
                if (ret < 0) {
                        perror("setegid");
-                       exit(EXIT_FAILURE);
+                       return EXIT_FAILURE;
                }
        }
        if (data->uid != geteuid()) {
                ret = seteuid(data->uid);
                if (ret < 0) {
                        perror("seteuid");
-                       exit(EXIT_FAILURE);
+                       return EXIT_FAILURE;
                }
        }
        /*
@@ -172,13 +172,12 @@ int child_run_as(void *_data)
                                writeleft);
                if (writelen < 0) {
                        perror("write");
-                       exit(EXIT_FAILURE);
+                       return EXIT_FAILURE;
                }
                writeleft -= writelen;
                index += writelen;
        } while (writeleft > 0);
-
-       exit(EXIT_SUCCESS);
+       return EXIT_SUCCESS;
 }
 
 static
This page took 0.029373 seconds and 4 git commands to generate.