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 <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
This commit is contained in:
Tobias Stoeckmann
2025-01-06 17:18:43 +01:00
committed by Alejandro Colomar
parent f2b5eb1274
commit a772484f00
2 changed files with 3 additions and 3 deletions

View 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);

View 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));