do detaching after user switch

This commit is contained in:
Erik Ekman 2007-03-01 21:41:17 +00:00
parent 264a5227de
commit 6a4dfb8cbd
2 changed files with 8 additions and 8 deletions

View File

@ -569,16 +569,16 @@ main(int argc, char **argv)
do_chroot(newroot); do_chroot(newroot);
if (!foreground) {
do_detach();
}
if (username) { if (username) {
if (setgid(pw->pw_gid) < 0 || setuid(pw->pw_uid) < 0) { if (setgid(pw->pw_gid) < 0 || setuid(pw->pw_uid) < 0) {
printf("Could not switch to user %s!\n", username); printf("Could not switch to user %s!\n", username);
usage(); usage();
} }
} }
if (!foreground) {
do_detach();
}
tunnel(tun_fd, dns_fd); tunnel(tun_fd, dns_fd);

View File

@ -535,10 +535,6 @@ main(int argc, char **argv)
printf("Listening to dns for domain %s\n", argv[1]); printf("Listening to dns for domain %s\n", argv[1]);
do_chroot(newroot); do_chroot(newroot);
if (!foreground) {
do_detach();
}
signal(SIGINT, sigint); signal(SIGINT, sigint);
if (username) { if (username) {
@ -548,6 +544,10 @@ main(int argc, char **argv)
} }
} }
if (!foreground) {
do_detach();
}
tunnel(tun_fd, dnsd_fd); tunnel(tun_fd, dnsd_fd);
cleanup2: cleanup2: