Skip to content

Commit 76fe6eb

Browse files
mauri870bluca
authored andcommitted
shared: log error when execve fail
If there is an error with the execv call in fork_agent the program exits without any meaningful log message. Log the command and errno so the user gets more information about the failure. Fixes: #33418 Signed-off-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> (cherry picked from commit a408d44) (cherry picked from commit 7fcfb73)
1 parent 896754d commit 76fe6eb

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/shared/exec-util.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,5 +601,6 @@ int fork_agent(const char *name, const int except[], size_t n_except, pid_t *ret
601601
va_end(ap);
602602

603603
execv(path, l);
604+
log_error_errno(errno, "Failed to execute %s: %m", path);
604605
_exit(EXIT_FAILURE);
605606
}

src/shared/spawn-polkit-agent.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,21 @@ int polkit_agent_open(void) {
4343
xsprintf(notify_fd, "%i", pipe_fd[1]);
4444

4545
r = fork_agent("(polkit-agent)",
46-
&pipe_fd[1], 1,
46+
&pipe_fd[1],
47+
1,
4748
&agent_pid,
4849
POLKIT_AGENT_BINARY_PATH,
49-
POLKIT_AGENT_BINARY_PATH, "--notify-fd", notify_fd, "--fallback", NULL);
50+
POLKIT_AGENT_BINARY_PATH,
51+
"--notify-fd",
52+
notify_fd,
53+
"--fallback",
54+
NULL);
5055

5156
/* Close the writing side, because that's the one for the agent */
5257
safe_close(pipe_fd[1]);
5358

5459
if (r < 0)
55-
log_error_errno(r, "Failed to fork TTY ask password agent: %m");
60+
log_error_errno(r, "Failed to fork polkit agent: %m");
5661
else
5762
/* Wait until the agent closes the fd */
5863
(void) fd_wait_for_event(pipe_fd[0], POLLHUP, USEC_INFINITY);

0 commit comments

Comments
 (0)