mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-22 22:51:27 +00: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);
|
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);
|
int open_dns(int, in_addr_t);
|
||||||
void close_dns(int);
|
void close_dns(int);
|
||||||
|
|
||||||
|
void do_chroot(char *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -568,13 +568,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
printf("Sending queries for %s to %s\n", argv[1], argv[0]);
|
printf("Sending queries for %s to %s\n", argv[1], argv[0]);
|
||||||
|
|
||||||
if (newroot) {
|
do_chroot(newroot);
|
||||||
if (chroot(newroot) != 0 || chdir("/") != 0)
|
|
||||||
err(1, "%s", newroot);
|
|
||||||
|
|
||||||
seteuid(geteuid());
|
|
||||||
setuid(getuid());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!foreground) {
|
if (!foreground) {
|
||||||
printf("Detaching from terminal...\n");
|
printf("Detaching from terminal...\n");
|
||||||
|
|
|
@ -535,12 +535,7 @@ 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]);
|
||||||
|
|
||||||
if (newroot) {
|
do_chroot(newroot);
|
||||||
if (chroot(newroot) != 0 || chdir("/") != 0)
|
|
||||||
err(1, "%s", newroot);
|
|
||||||
seteuid(geteuid());
|
|
||||||
setuid(getuid());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!foreground) {
|
if (!foreground) {
|
||||||
printf("Detaching from terminal...\n");
|
printf("Detaching from terminal...\n");
|
||||||
|
|
Loading…
Reference in a new issue