mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-22 16:19:20 +02:00
move chrooting to common.c
This commit is contained in:
parent
e3245fbd76
commit
baf1ab4201
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 New Issue