Socolin

isc-dhcp-server patch rdomain ports openbsd

Aug 6th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.27 KB | None | 0 0
  1. diff -ur server/dhcpd.c server-rdomain/dhcpd.c
  2. --- server/dhcpd.c      Thu Aug  6 08:08:57 2015
  3. +++ server-rdomain/dhcpd.c      Thu Aug  6 08:06:44 2015
  4. @@ -52,6 +52,10 @@
  5.  #  undef group
  6.  #endif /* PARANOIA */
  7.  
  8. +#ifdef __BSD_VISIBLE
  9. +#  include <sys/ioctl.h>
  10. +#endif /* __BSD_VISIBLE */
  11. +
  12.  #ifndef UNIT_TEST
  13.  static void usage(void);
  14.  #endif
  15. @@ -124,7 +128,25 @@
  16.         }
  17.         omapi_object_dereference (&listener, MDL);
  18.  }
  19. +#ifdef __BSD_VISIBLE
  20. +static int
  21. +get_rdomain(char *name)
  22. +{
  23. +       int rv = 0, s;
  24. +       struct  ifreq ifr;
  25.  
  26. +       if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
  27. +               log_fatal("get_rdomain socket: %m");
  28. +
  29. +       bzero(&ifr, sizeof(ifr));
  30. +       strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
  31. +       if (ioctl(s, SIOCGIFRDOMAIN, (caddr_t)&ifr) != -1)
  32. +               rv = ifr.ifr_rdomainid;
  33. +
  34. +       close(s);
  35. +       return rv;
  36. +}
  37. +#endif /* __BSD_VISIBLE */
  38.  #if defined (PARANOIA)
  39.  /* to be used in one of two possible scenarios */
  40.  static void setup_chroot (char *chroot_dir) {
  41. @@ -184,7 +206,11 @@
  42.         gid_t set_gid = 0;
  43.  #endif /* PARANOIA */
  44.  
  45. -        /* Make sure that file descriptors 0 (stdin), 1, (stdout), and
  46. +#ifdef __BSD_VISIBLE
  47. +       int rdomain = -1;
  48. +#endif /* __BSD_VISIBLE */
  49. +
  50. +       /* Make sure that file descriptors 0 (stdin), 1, (stdout), and
  51.             2 (stderr) are open. To do this, we assume that when we
  52.             open a file the lowest available file descriptor is used. */
  53.          fd = open("/dev/null", O_RDWR);
  54. @@ -348,6 +374,17 @@
  55.                                 interface_dereference (&interfaces, MDL);
  56.                         }
  57.                         interface_reference (&interfaces, tmp, MDL);
  58. +#ifdef __BSD_VISIBLE
  59. +                       int ird = get_rdomain(tmp->name);
  60. +                       if (rdomain == -1) {
  61. +                               rdomain = ird;
  62. +                               setrtable(rdomain);
  63. +                       }
  64. +                       else if (rdomain != ird)
  65. +                               log_fatal("Interface %s is not in rdomain %d",
  66. +                                   tmp->name, rdomain);
  67. +
  68. +#endif /* __BSD_VISIBLLE */
  69.                         tmp -> flags = INTERFACE_REQUESTED;
  70.                 }
  71.         }
Advertisement
Add Comment
Please, Sign In to add comment