process-util: move fork_agent() to process-util.[ch]
It's a relatively small wrapper around safe_fork() now, hence let's move it over, and make its signature even more alike. Also, set a different process name for the polkit and askpw agents.
This commit is contained in:
@@ -40,8 +40,9 @@ int ask_password_agent_open(void) {
|
||||
if (!isatty(STDIN_FILENO))
|
||||
return 0;
|
||||
|
||||
r = fork_agent(&agent_pid,
|
||||
r = fork_agent("(sd-askpwagent)",
|
||||
NULL, 0,
|
||||
&agent_pid,
|
||||
SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH,
|
||||
SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH, "--watch", NULL);
|
||||
if (r < 0)
|
||||
|
||||
@@ -38,9 +38,8 @@
|
||||
static pid_t agent_pid = 0;
|
||||
|
||||
int polkit_agent_open(void) {
|
||||
int r;
|
||||
int pipe_fd[2];
|
||||
char notify_fd[DECIMAL_STR_MAX(int) + 1];
|
||||
int pipe_fd[2], r;
|
||||
|
||||
if (agent_pid > 0)
|
||||
return 0;
|
||||
@@ -49,8 +48,7 @@ int polkit_agent_open(void) {
|
||||
if (geteuid() == 0)
|
||||
return 0;
|
||||
|
||||
/* We check STDIN here, not STDOUT, since this is about input,
|
||||
* not output */
|
||||
/* We check STDIN here, not STDOUT, since this is about input, not output */
|
||||
if (!isatty(STDIN_FILENO))
|
||||
return 0;
|
||||
|
||||
@@ -59,8 +57,9 @@ int polkit_agent_open(void) {
|
||||
|
||||
xsprintf(notify_fd, "%i", pipe_fd[1]);
|
||||
|
||||
r = fork_agent(&agent_pid,
|
||||
r = fork_agent("(polkit-agent)",
|
||||
&pipe_fd[1], 1,
|
||||
&agent_pid,
|
||||
POLKIT_AGENT_BINARY_PATH,
|
||||
POLKIT_AGENT_BINARY_PATH, "--notify-fd", notify_fd, "--fallback", NULL);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user