mirror of
https://github.com/yarrick/iodine.git
synced 2024-12-22 21:33:33 +02:00
move chrooting to common.c
This commit is contained in:
parent
e3245fbd76
commit
baf1ab4201
4 changed files with 15 additions and 13 deletions
11
src/common.c
11
src/common.c
|
@ -67,3 +67,14 @@ close_dns(int fd)
|
|||
close(fd);
|
||||
}
|
||||
|
||||
void
|
||||
do_chroot(char *newroot)
|
||||
{
|
||||
if (newroot) {
|
||||
if (chroot(newroot) != 0 || chdir("/") != 0)
|
||||
err(1, "%s", newroot);
|
||||
|
||||
seteuid(geteuid());
|
||||
setuid(getuid());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,4 +45,6 @@ struct query {
|
|||
int open_dns(int, in_addr_t);
|
||||
void close_dns(int);
|
||||
|
||||
void do_chroot(char *);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -568,13 +568,7 @@ main(int argc, char **argv)
|
|||
|
||||
printf("Sending queries for %s to %s\n", argv[1], argv[0]);
|
||||
|
||||
if (newroot) {
|
||||
if (chroot(newroot) != 0 || chdir("/") != 0)
|
||||
err(1, "%s", newroot);
|
||||
|
||||
seteuid(geteuid());
|
||||
setuid(getuid());
|
||||
}
|
||||
do_chroot(newroot);
|
||||
|
||||
if (!foreground) {
|
||||
printf("Detaching from terminal...\n");
|
||||
|
|
|
@ -535,12 +535,7 @@ main(int argc, char **argv)
|
|||
|
||||
printf("Listening to dns for domain %s\n", argv[1]);
|
||||
|
||||
if (newroot) {
|
||||
if (chroot(newroot) != 0 || chdir("/") != 0)
|
||||
err(1, "%s", newroot);
|
||||
seteuid(geteuid());
|
||||
setuid(getuid());
|
||||
}
|
||||
do_chroot(newroot);
|
||||
|
||||
if (!foreground) {
|
||||
printf("Detaching from terminal...\n");
|
||||
|
|
Loading…
Reference in a new issue