]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/: Use _exit in case of execv errors
authorTobias Stoeckmann <tobias@stoeckmann.org>
Mon, 6 Jan 2025 16:18:43 +0000 (17:18 +0100)
committerAlejandro Colomar <alx@kernel.org>
Fri, 10 Jan 2025 09:23:57 +0000 (10:23 +0100)
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 <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
lib/run_part.c
lib/spawn.c

index 840d951197b7625f0ce1ac9088981f559d998bbe..890f837cd353ee9b98fc8cb9d46a7f9199d013e6 100644 (file)
@@ -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);
index 57a412199c081c6fcb6c8586948f4cc8d17a88c0..0a2b109500f344ca70032c7bc3195ef73829faa6 100644 (file)
@@ -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));