From: Tobias Stoeckmann Date: Mon, 6 Jan 2025 16:18:43 +0000 (+0100) Subject: lib/: Use _exit in case of execv errors X-Git-Tag: 4.17.2~3 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=a772484f00eae0f8a4d5e73f23b36c50445c3c51;p=thirdparty%2Fshadow.git lib/: Use _exit in case of execv errors Calling exit might trigger cleanup functions registered through atexit. Since some programs use this mechanism, be extra cautious to never release passwd/group locks too early. Reviewed-by: Alejandro Colomar Signed-off-by: Tobias Stoeckmann --- diff --git a/lib/run_part.c b/lib/run_part.c index 840d95119..890f837cd 100644 --- a/lib/run_part.c +++ b/lib/run_part.c @@ -32,7 +32,7 @@ static int run_part(char *script_path, const char *name, const char *action) setenv("SUBJECT",name,1); execv(script_path,args); fprintf(shadow_logfd, "execv: %s\n", strerror(errno)); - exit(1); + _exit(1); } pid_status = wait(&wait_status); diff --git a/lib/spawn.c b/lib/spawn.c index 57a412199..0a2b10950 100644 --- a/lib/spawn.c +++ b/lib/spawn.c @@ -35,11 +35,11 @@ run_command(const char *cmd, const char *argv[], (void) execve (cmd, (char * const *) argv, (char * const *) envp); if (ENOENT == errno) { - exit (E_CMD_NOTFOUND); + _exit (E_CMD_NOTFOUND); } fprintf (shadow_logfd, "%s: cannot execute %s: %s\n", shadow_progname, cmd, strerror (errno)); - exit (E_CMD_NOEXEC); + _exit (E_CMD_NOEXEC); } else if ((pid_t)-1 == pid) { fprintf (shadow_logfd, "%s: cannot execute %s: %s\n", shadow_progname, cmd, strerror (errno));