Skip to content

Commit ee386d7

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 <[email protected]> (cherry picked from commit a408d44) (cherry picked from commit 7fcfb73) (cherry picked from commit 76fe6eb) (cherry picked from commit 084b911) (cherry picked from commit b9a08c7)
1 parent 9e3972e commit ee386d7

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
@@ -557,5 +557,6 @@ int fork_agent(const char *name, const int except[], size_t n_except, pid_t *ret
557557
va_end(ap);
558558

559559
execv(path, l);
560+
log_error_errno(errno, "Failed to execute %s: %m", path);
560561
_exit(EXIT_FAILURE);
561562
}

src/shared/spawn-polkit-agent.c

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

4646
r = fork_agent("(polkit-agent)",
47-
&pipe_fd[1], 1,
47+
&pipe_fd[1],
48+
1,
4849
&agent_pid,
4950
POLKIT_AGENT_BINARY_PATH,
50-
POLKIT_AGENT_BINARY_PATH, "--notify-fd", notify_fd, "--fallback", NULL);
51+
POLKIT_AGENT_BINARY_PATH,
52+
"--notify-fd",
53+
notify_fd,
54+
"--fallback",
55+
NULL);
5156

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

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

0 commit comments

Comments
 (0)