Skip to content

Commit

Permalink
supervise-daemon: fix: pam_start before chrooting
Browse files Browse the repository at this point in the history
pam_start(3) must be called before chroot(2) for chroots that do not have PAM-related files present.
  • Loading branch information
sijanec authored Apr 17, 2022
1 parent db55135 commit 9ad6db1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/supervise-daemon/supervise-daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,6 @@ static void child_process(char *exec, char **argv)
fclose(fp);
}

if (ch_root && chroot(ch_root) < 0)
eerrorx("%s: chroot `%s': %s", applet, ch_root, strerror(errno));

if (ch_dir && chdir(ch_dir) < 0)
eerrorx("%s: chdir `%s': %s", applet, ch_dir, strerror(errno));

#ifdef HAVE_PAM
if (changeuser != NULL) {
pamr = pam_start("supervise-daemon",
Expand All @@ -426,6 +420,12 @@ static void child_process(char *exec, char **argv)
}
#endif

if (ch_root && chroot(ch_root) < 0)
eerrorx("%s: chroot `%s': %s", applet, ch_root, strerror(errno));

if (ch_dir && chdir(ch_dir) < 0)
eerrorx("%s: chdir `%s': %s", applet, ch_dir, strerror(errno));

if (gid && setgid(gid))
eerrorx("%s: unable to set groupid to %d", applet, gid);
if (changeuser && initgroups(changeuser, gid))
Expand Down

0 comments on commit 9ad6db1

Please sign in to comment.