aboutsummaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2023-06-11 09:26:16 +0000
committerOmar Polo <op@omarpolo.com>2023-06-11 09:26:16 +0000
commit725457a9e46a773f0fd5e18c9cf0f00b2347dcaf (patch)
treeecb888f25375c0a969be4ef873a25ec9d1f051bb /proc.c
parent4ad573d0d5675212b0b5719a0a5c1de22974dd0e (diff)
move setproctitle/privsep_process earlier
We don't always do privilege dropping (as we may start as unprivileged user), so set these two beforehand so when we skip privdrop we don't miss to set privsep_process and set the process' title.
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/proc.c b/proc.c
index 3060e65..79eaa32 100644
--- a/proc.c
+++ b/proc.c
@@ -548,6 +548,9 @@ proc_run(struct privsep *ps, struct privsep_proc *p,
const char *root;
log_procinit(p->p_title);
+ setproctitle("%s", p->p_title);
+
+ privsep_process = p->p_id;
if (ps->ps_pw == NULL)
goto init;
@@ -572,10 +575,6 @@ proc_run(struct privsep *ps, struct privsep_proc *p,
if (chdir("/") == -1)
fatal("%s: chdir(\"/\")", __func__);
- privsep_process = p->p_id;
-
- setproctitle("%s", p->p_title);
-
if (setgroups(1, &pw->pw_gid) ||
setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) ||
setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid))