Hello all,

I have found a bug in the DHCP server that the LDAP does’t support the tags “subnet6, pool6 and rang6”. This will result in a incorrect config file and DHCP server will not load.

Below you can see my patch that will help to make it this work.
The patch is based on the 4.3.1 version from Debian. 

Kind regards,

 

Edward A. Heuveling

ReD Innovation


+31 (0) 85 0090564

+31 (0)6 - 32227106

E ea.heuveling@red-innovation.nl





--- ldap.c 2014-08-07 00:35:03.000000000 +0200

+++ server/ldap.c 2017-08-07 21:57:13.285063020 +0200

@@ -275,6 +275,52 @@

   item->close_brace = 1;

 }

 

+static void

+ldap_parse_subnet6 (struct ldap_config_stack *item, struct parse *cfile)

+{

+  struct berval **tempbv;

+  int i;

+

+  if ((tempbv = ldap_get_values_len (ld, item->ldent, "cn")) == NULL ||

+      tempbv[0] == NULL)

+    {

+      if (tempbv != NULL)

+        ldap_value_free_len (tempbv);

+

+      return;

+    }

+

+  x_strncat (cfile->inbuf, "subnet6 ", LDAP_BUFFER_SIZE);

+  x_strncat (cfile->inbuf, tempbv[0]->bv_val, LDAP_BUFFER_SIZE);

+

+  x_strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE);

+

+  ldap_value_free_len (tempbv);

+

+  if ((tempbv = ldap_get_values_len (ld, item->ldent, "dhcpRange6")) != NULL)

+    {

+      for (i=0; tempbv[i] != NULL; i++)

+        {

+          x_strncat (cfile->inbuf, "range6", LDAP_BUFFER_SIZE);

+          x_strncat (cfile->inbuf, " ", LDAP_BUFFER_SIZE);

+          x_strncat (cfile->inbuf, tempbv[i]->bv_val, LDAP_BUFFER_SIZE);

+          x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);

+        }

+      ldap_value_free_len (tempbv);

+    }

+

+  if ((tempbv = ldap_get_values_len (ld, item->ldent, "dhcpPermitList")) != NULL)

+    {

+      for (i=0; tempbv[i] != NULL; i++)

+        {

+          x_strncat (cfile->inbuf, tempbv[i]->bv_val, LDAP_BUFFER_SIZE);

+          x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);

+        }

+      ldap_value_free_len (tempbv);

+    }

+

+  item->close_brace = 1;

+}

 

 static void

 ldap_parse_pool (struct ldap_config_stack *item, struct parse *cfile)

@@ -309,6 +355,38 @@

   item->close_brace = 1;

 }

 

+static void

+ldap_parse_pool6 (struct ldap_config_stack *item, struct parse *cfile)

+{

+  struct berval **tempbv;

+  int i;

+

+  x_strncat (cfile->inbuf, "pool6 {\n", LDAP_BUFFER_SIZE);

+

+  if ((tempbv = ldap_get_values_len (ld, item->ldent, "dhcpRange6")) != NULL)

+    {

+      for (i=0; tempbv[i] != NULL; i++)

+        {

+          x_strncat (cfile->inbuf, "range6", LDAP_BUFFER_SIZE);

+          x_strncat (cfile->inbuf, " ", LDAP_BUFFER_SIZE);

+          x_strncat (cfile->inbuf, tempbv[i]->bv_val, LDAP_BUFFER_SIZE);

+          x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);

+        }

+      ldap_value_free_len (tempbv);

+    }

+

+  if ((tempbv = ldap_get_values_len (ld, item->ldent, "dhcpPermitList")) != NULL)

+    {

+      for (i=0; tempbv[i] != NULL; i++)

+        {

+          x_strncat (cfile->inbuf, tempbv[i]->bv_val, LDAP_BUFFER_SIZE);

+          x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);

+        }

+      ldap_value_free_len (tempbv);

+    }

+

+  item->close_brace = 1;

+}

 

 static void

 ldap_parse_group (struct ldap_config_stack *item, struct parse *cfile)

@@ -892,7 +970,7 @@

 static void

 parse_external_dns (LDAPMessage * ent)

 {

-  char *search[] = {"dhcpOptionsDN", "dhcpSharedNetworkDN", "dhcpSubnetDN",

+  char *search[] = {"dhcpOptionsDN", "dhcpSharedNetworkDN", "dhcpSubnetDN", 

                     "dhcpGroupDN", "dhcpHostDN", "dhcpClassesDN",

                     "dhcpPoolDN", NULL};

   LDAPMessage * newres, * newent;

@@ -1155,8 +1233,12 @@

         ldap_parse_class (entry, cfile);

       else if (strcasecmp (objectClass[i]->bv_val, "dhcpSubnet") == 0)

         ldap_parse_subnet (entry, cfile);

+      else if (strcasecmp (objectClass[i]->bv_val, "dhcpSubnet6") == 0)

+        ldap_parse_subnet6 (entry, cfile);

       else if (strcasecmp (objectClass[i]->bv_val, "dhcpPool") == 0)

         ldap_parse_pool (entry, cfile);

+      else if (strcasecmp (objectClass[i]->bv_val, "dhcpPool6") == 0)

+        ldap_parse_pool6 (entry, cfile);

       else if (strcasecmp (objectClass[i]->bv_val, "dhcpGroup") == 0)

         ldap_parse_group (entry, cfile);

       else if (strcasecmp (objectClass[i]->bv_val, "dhcpTSigKey") == 0)