Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -ur server/dhcpd.c server-rdomain/dhcpd.c
- --- server/dhcpd.c Thu Aug 6 08:08:57 2015
- +++ server-rdomain/dhcpd.c Thu Aug 6 08:06:44 2015
- @@ -52,6 +52,10 @@
- # undef group
- #endif /* PARANOIA */
- +#ifdef __BSD_VISIBLE
- +# include <sys/ioctl.h>
- +#endif /* __BSD_VISIBLE */
- +
- #ifndef UNIT_TEST
- static void usage(void);
- #endif
- @@ -124,7 +128,25 @@
- }
- omapi_object_dereference (&listener, MDL);
- }
- +#ifdef __BSD_VISIBLE
- +static int
- +get_rdomain(char *name)
- +{
- + int rv = 0, s;
- + struct ifreq ifr;
- + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
- + log_fatal("get_rdomain socket: %m");
- +
- + bzero(&ifr, sizeof(ifr));
- + strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
- + if (ioctl(s, SIOCGIFRDOMAIN, (caddr_t)&ifr) != -1)
- + rv = ifr.ifr_rdomainid;
- +
- + close(s);
- + return rv;
- +}
- +#endif /* __BSD_VISIBLE */
- #if defined (PARANOIA)
- /* to be used in one of two possible scenarios */
- static void setup_chroot (char *chroot_dir) {
- @@ -184,7 +206,11 @@
- gid_t set_gid = 0;
- #endif /* PARANOIA */
- - /* Make sure that file descriptors 0 (stdin), 1, (stdout), and
- +#ifdef __BSD_VISIBLE
- + int rdomain = -1;
- +#endif /* __BSD_VISIBLE */
- +
- + /* Make sure that file descriptors 0 (stdin), 1, (stdout), and
- 2 (stderr) are open. To do this, we assume that when we
- open a file the lowest available file descriptor is used. */
- fd = open("/dev/null", O_RDWR);
- @@ -348,6 +374,17 @@
- interface_dereference (&interfaces, MDL);
- }
- interface_reference (&interfaces, tmp, MDL);
- +#ifdef __BSD_VISIBLE
- + int ird = get_rdomain(tmp->name);
- + if (rdomain == -1) {
- + rdomain = ird;
- + setrtable(rdomain);
- + }
- + else if (rdomain != ird)
- + log_fatal("Interface %s is not in rdomain %d",
- + tmp->name, rdomain);
- +
- +#endif /* __BSD_VISIBLLE */
- tmp -> flags = INTERFACE_REQUESTED;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment