summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
authorMauri de Souza Meneguzzo <mauri870@gmail.com>2024-06-25 04:47:15 +0200
committerLuca Boccassi <luca.boccassi@gmail.com>2024-07-22 11:12:35 +0200
commita408d4453145621902b9a3ef78a552f83b09bd8d (patch)
tree51f4e15069426e53dab311332b328e437c39deaf /src/shared
parentMerge pull request #33432 from gregorHerburger/add_IFLA_BR_FDB_MAX_LEARNED_su... (diff)
downloadsystemd-a408d4453145621902b9a3ef78a552f83b09bd8d.tar.xz
systemd-a408d4453145621902b9a3ef78a552f83b09bd8d.zip
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>
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/exec-util.c1
-rw-r--r--src/shared/polkit-agent.c11
2 files changed, 9 insertions, 3 deletions
diff --git a/src/shared/exec-util.c b/src/shared/exec-util.c
index 5408be5328..b02361a579 100644
--- a/src/shared/exec-util.c
+++ b/src/shared/exec-util.c
@@ -606,5 +606,6 @@ int fork_agent(const char *name, const int except[], size_t n_except, pid_t *ret
va_end(ap);
execv(path, l);
+ log_error_errno(errno, "Failed to execute %s: %m", path);
_exit(EXIT_FAILURE);
}
diff --git a/src/shared/polkit-agent.c b/src/shared/polkit-agent.c
index a891246156..93c15c29e7 100644
--- a/src/shared/polkit-agent.c
+++ b/src/shared/polkit-agent.c
@@ -43,16 +43,21 @@ int polkit_agent_open(void) {
xsprintf(notify_fd, "%i", pipe_fd[1]);
r = fork_agent("(polkit-agent)",
- &pipe_fd[1], 1,
+ &pipe_fd[1],
+ 1,
&agent_pid,
POLKIT_AGENT_BINARY_PATH,
- POLKIT_AGENT_BINARY_PATH, "--notify-fd", notify_fd, "--fallback", NULL);
+ POLKIT_AGENT_BINARY_PATH,
+ "--notify-fd",
+ notify_fd,
+ "--fallback",
+ NULL);
/* Close the writing side, because that's the one for the agent */
safe_close(pipe_fd[1]);
if (r < 0)
- log_error_errno(r, "Failed to fork TTY ask password agent: %m");
+ log_error_errno(r, "Failed to fork polkit agent: %m");
else
/* Wait until the agent closes the fd */
(void) fd_wait_for_event(pipe_fd[0], POLLHUP, USEC_INFINITY);