diff options
Diffstat (limited to 'libglouglou/utils.c')
-rw-r--r-- | libglouglou/utils.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libglouglou/utils.c b/libglouglou/utils.c index 9915bf2..8ca3660 100644 --- a/libglouglou/utils.c +++ b/libglouglou/utils.c @@ -174,15 +174,19 @@ addrcmp(struct sockaddr_in *a, struct sockaddr_in *b) } void -droppriv(char *user) +droppriv(char *user, int do_chroot, char *chroot_path) { struct passwd *pw; pw = getpwnam(user); if (!pw) err(1, "unknown user %s", user); - if (chroot(pw->pw_dir) != 0) - err(1, "unable to chroot"); + if (do_chroot) { + if (!chroot_path) + chroot_path = pw->pw_dir; + if (chroot(chroot_path) != 0) + err(1, "unable to chroot"); + } if (chdir("/") != 0) err(1, "unable to chdir"); if (setgroups(1, &pw->pw_gid) == -1) |