mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-23 18:15:13 +00:00
Move superuser check to common.c
This commit is contained in:
parent
31b2958b28
commit
86ee760e8b
11
src/common.c
11
src/common.c
@ -82,6 +82,17 @@ int setgroups(int count, int *groups)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
check_superuser(void (*usage_fn)(void))
|
||||||
|
{
|
||||||
|
if (geteuid() != 0) {
|
||||||
|
warnx("Run as root and you'll be happy.\n");
|
||||||
|
usage_fn();
|
||||||
|
/* NOTREACHED */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
open_dns(int localport, in_addr_t listen_ip)
|
open_dns(int localport, in_addr_t listen_ip)
|
||||||
{
|
{
|
||||||
|
@ -58,6 +58,7 @@ struct query {
|
|||||||
int fromlen;
|
int fromlen;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void check_superuser(void (*usage_fn)(void));
|
||||||
int open_dns(int, in_addr_t);
|
int open_dns(int, in_addr_t);
|
||||||
void close_dns(int);
|
void close_dns(int);
|
||||||
|
|
||||||
|
@ -945,11 +945,7 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (geteuid() != 0) {
|
check_superuser(usage);
|
||||||
warnx("Run as root and you'll be happy.\n");
|
|
||||||
usage();
|
|
||||||
/* NOTREACHED */
|
|
||||||
}
|
|
||||||
|
|
||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
@ -1002,10 +1002,7 @@ main(int argc, char **argv)
|
|||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
if (geteuid() != 0) {
|
check_superuser(usage);
|
||||||
warnx("Run as root and you'll be happy.\n");
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
usage();
|
usage();
|
||||||
|
Loading…
Reference in New Issue
Block a user