From 6da9f915f29c93ac54ed62e7669df7c7e18a141d Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 21 Dec 2011 21:32:45 -0500 Subject: [PATCH] clone: return instead of exit() 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 --- librunas/runas.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/librunas/runas.c b/librunas/runas.c index ba361d6d6..0ffe52ea3 100644 --- a/librunas/runas.c +++ b/librunas/runas.c @@ -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 -- 2.34.1