44 #if defined(LDAP_CONFIGURATION) 46 #if defined(LDAP_CASA_AUTH) 47 #include "ldap_casa.h" 50 static LDAP * ld = NULL;
51 static char *ldap_server = NULL,
52 *ldap_username = NULL,
53 *ldap_password = NULL,
55 *ldap_dhcp_server_cn = NULL,
56 *ldap_debug_file = NULL;
57 static int ldap_port = LDAP_PORT,
58 ldap_method = LDAP_METHOD_DYNAMIC,
61 #if defined (LDAP_USE_SSL) 62 static int ldap_use_ssl = -1,
63 ldap_tls_reqcert = -1,
64 ldap_tls_crlcheck = -1;
65 static char *ldap_tls_ca_file = NULL,
66 *ldap_tls_ca_dir = NULL,
67 *ldap_tls_cert = NULL,
69 *ldap_tls_ciphers = NULL,
70 *ldap_tls_randfile = NULL;
72 static struct ldap_config_stack *ldap_stack = NULL;
74 typedef struct ldap_dn_node {
75 struct ldap_dn_node *next;
80 static ldap_dn_node *ldap_service_dn_head = NULL;
81 static ldap_dn_node *ldap_service_dn_tail = NULL;
85 x_strncat(
char *dst,
const char *src,
size_t dst_size)
87 size_t len = strlen(dst);
88 return strncat(dst, src, dst_size > len ? dst_size - len - 1: 0);
92 ldap_parse_class (
struct ldap_config_stack *item,
struct parse *cfile)
94 struct berval **tempbv;
96 if ((tempbv = ldap_get_values_len (ld, item->ldent,
"cn")) == NULL ||
100 ldap_value_free_len (tempbv);
105 x_strncat (cfile->
inbuf,
"class \"", LDAP_BUFFER_SIZE);
106 x_strncat (cfile->
inbuf, tempbv[0]->bv_val, LDAP_BUFFER_SIZE);
107 x_strncat (cfile->
inbuf,
"\" {\n", LDAP_BUFFER_SIZE);
109 item->close_brace = 1;
110 ldap_value_free_len (tempbv);
115 ldap_parse_subclass (
struct ldap_config_stack *item,
struct parse *cfile)
117 struct berval **tempbv, **classdata;
119 if ((tempbv = ldap_get_values_len (ld, item->ldent,
"cn")) == NULL ||
123 ldap_value_free_len (tempbv);
128 if ((classdata = ldap_get_values_len (ld, item->ldent,
129 "dhcpClassData")) == NULL ||
130 classdata[0] == NULL)
132 if (classdata != NULL)
133 ldap_value_free_len (classdata);
134 ldap_value_free_len (tempbv);
139 x_strncat (cfile->
inbuf,
"subclass ", LDAP_BUFFER_SIZE);
140 x_strncat (cfile->
inbuf, classdata[0]->bv_val, LDAP_BUFFER_SIZE);
141 x_strncat (cfile->
inbuf,
" ", LDAP_BUFFER_SIZE);
142 x_strncat (cfile->
inbuf, tempbv[0]->bv_val, LDAP_BUFFER_SIZE);
143 x_strncat (cfile->
inbuf,
" {\n", LDAP_BUFFER_SIZE);
145 item->close_brace = 1;
146 ldap_value_free_len (tempbv);
147 ldap_value_free_len (classdata);
152 ldap_parse_host (
struct ldap_config_stack *item,
struct parse *cfile)
154 struct berval **tempbv, **hwaddr;
156 if ((tempbv = ldap_get_values_len (ld, item->ldent,
"cn")) == NULL ||
160 ldap_value_free_len (tempbv);
165 hwaddr = ldap_get_values_len (ld, item->ldent,
"dhcpHWAddress");
167 x_strncat (cfile->
inbuf,
"host ", LDAP_BUFFER_SIZE);
168 x_strncat (cfile->
inbuf, tempbv[0]->bv_val, LDAP_BUFFER_SIZE);
170 if (hwaddr != NULL && hwaddr[0] != NULL)
172 x_strncat (cfile->
inbuf,
" {\nhardware ", LDAP_BUFFER_SIZE);
173 x_strncat (cfile->
inbuf, hwaddr[0]->bv_val, LDAP_BUFFER_SIZE);
174 x_strncat (cfile->
inbuf,
";\n", LDAP_BUFFER_SIZE);
175 ldap_value_free_len (hwaddr);
178 item->close_brace = 1;
179 ldap_value_free_len (tempbv);
184 ldap_parse_shared_network (
struct ldap_config_stack *item,
struct parse *cfile)
186 struct berval **tempbv;
188 if ((tempbv = ldap_get_values_len (ld, item->ldent,
"cn")) == NULL ||
192 ldap_value_free_len (tempbv);
197 x_strncat (cfile->
inbuf,
"shared-network \"", LDAP_BUFFER_SIZE);
198 x_strncat (cfile->
inbuf, tempbv[0]->bv_val, LDAP_BUFFER_SIZE);
199 x_strncat (cfile->
inbuf,
"\" {\n", LDAP_BUFFER_SIZE);
201 item->close_brace = 1;
202 ldap_value_free_len (tempbv);
207 parse_netmask (
int netmask,
char *netmaskbuf)
213 for (i=1; i <= netmask; i++)
218 sprintf (netmaskbuf,
"%d.%d.%d.%d", (
int) (nm >> 24) & 0xff,
219 (
int) (nm >> 16) & 0xff,
220 (
int) (nm >> 8) & 0xff,
226 ldap_parse_subnet (
struct ldap_config_stack *item,
struct parse *cfile)
228 struct berval **tempbv, **netmaskstr;
229 char netmaskbuf[
sizeof(
"255.255.255.255")];
232 if ((tempbv = ldap_get_values_len (ld, item->ldent,
"cn")) == NULL ||
236 ldap_value_free_len (tempbv);
241 if ((netmaskstr = ldap_get_values_len (ld, item->ldent,
242 "dhcpNetmask")) == NULL ||
243 netmaskstr[0] == NULL)
245 if (netmaskstr != NULL)
246 ldap_value_free_len (netmaskstr);
247 ldap_value_free_len (tempbv);
252 x_strncat (cfile->
inbuf,
"subnet ", LDAP_BUFFER_SIZE);
253 x_strncat (cfile->
inbuf, tempbv[0]->bv_val, LDAP_BUFFER_SIZE);
255 x_strncat (cfile->
inbuf,
" netmask ", LDAP_BUFFER_SIZE);
256 parse_netmask (strtol (netmaskstr[0]->bv_val, NULL, 10), netmaskbuf);
257 x_strncat (cfile->
inbuf, netmaskbuf, LDAP_BUFFER_SIZE);
259 x_strncat (cfile->
inbuf,
" {\n", LDAP_BUFFER_SIZE);
261 ldap_value_free_len (tempbv);
262 ldap_value_free_len (netmaskstr);
264 if ((tempbv = ldap_get_values_len (ld, item->ldent,
"dhcpRange")) != NULL)
266 for (i=0; tempbv[i] != NULL; i++)
268 x_strncat (cfile->
inbuf,
"range", LDAP_BUFFER_SIZE);
269 x_strncat (cfile->
inbuf,
" ", LDAP_BUFFER_SIZE);
270 x_strncat (cfile->
inbuf, tempbv[i]->bv_val, LDAP_BUFFER_SIZE);
271 x_strncat (cfile->
inbuf,
";\n", LDAP_BUFFER_SIZE);
275 item->close_brace = 1;
280 ldap_parse_pool (
struct ldap_config_stack *item,
struct parse *cfile)
282 struct berval **tempbv;
285 x_strncat (cfile->
inbuf,
"pool {\n", LDAP_BUFFER_SIZE);
287 if ((tempbv = ldap_get_values_len (ld, item->ldent,
"dhcpRange")) != NULL)
289 x_strncat (cfile->
inbuf,
"range", LDAP_BUFFER_SIZE);
290 for (i=0; tempbv[i] != NULL; i++)
292 x_strncat (cfile->
inbuf,
" ", LDAP_BUFFER_SIZE);
293 x_strncat (cfile->
inbuf, tempbv[i]->bv_val, LDAP_BUFFER_SIZE);
295 x_strncat (cfile->
inbuf,
";\n", LDAP_BUFFER_SIZE);
296 ldap_value_free_len (tempbv);
299 if ((tempbv = ldap_get_values_len (ld, item->ldent,
"dhcpPermitList")) != NULL)
301 for (i=0; tempbv[i] != NULL; i++)
303 x_strncat (cfile->
inbuf, tempbv[i]->bv_val, LDAP_BUFFER_SIZE);
304 x_strncat (cfile->
inbuf,
";\n", LDAP_BUFFER_SIZE);
306 ldap_value_free_len (tempbv);
309 item->close_brace = 1;
314 ldap_parse_group (
struct ldap_config_stack *item,
struct parse *cfile)
316 x_strncat (cfile->
inbuf,
"group {\n", LDAP_BUFFER_SIZE);
317 item->close_brace = 1;
322 ldap_parse_key (
struct ldap_config_stack *item,
struct parse *cfile)
324 struct berval **tempbv;
326 if ((tempbv = ldap_get_values_len (ld, item->ldent,
"cn")) != NULL)
328 x_strncat (cfile->
inbuf,
"key ", LDAP_BUFFER_SIZE);
329 x_strncat (cfile->
inbuf, tempbv[0]->bv_val, LDAP_BUFFER_SIZE);
330 x_strncat (cfile->
inbuf,
" {\n", LDAP_BUFFER_SIZE);
331 ldap_value_free_len (tempbv);
334 if ((tempbv = ldap_get_values_len (ld, item->ldent,
"dhcpKeyAlgorithm")) != NULL)
336 x_strncat (cfile->
inbuf,
"algorithm ", LDAP_BUFFER_SIZE);
337 x_strncat (cfile->
inbuf, tempbv[0]->bv_val, LDAP_BUFFER_SIZE);
338 x_strncat (cfile->
inbuf,
";\n", LDAP_BUFFER_SIZE);
339 ldap_value_free_len (tempbv);
342 if ((tempbv = ldap_get_values_len (ld, item->ldent,
"dhcpKeySecret")) != NULL)
344 x_strncat (cfile->
inbuf,
"secret ", LDAP_BUFFER_SIZE);
345 x_strncat (cfile->
inbuf, tempbv[0]->bv_val, LDAP_BUFFER_SIZE);
346 x_strncat (cfile->
inbuf,
";\n", LDAP_BUFFER_SIZE);
347 ldap_value_free_len (tempbv);
350 item->close_brace = 1;
355 ldap_parse_zone (
struct ldap_config_stack *item,
struct parse *cfile)
357 char *cnFindStart, *cnFindEnd;
358 struct berval **tempbv;
362 if ((tempbv = ldap_get_values_len (ld, item->ldent,
"cn")) != NULL)
364 x_strncat (cfile->
inbuf,
"zone ", LDAP_BUFFER_SIZE);
365 x_strncat (cfile->
inbuf, tempbv[0]->bv_val, LDAP_BUFFER_SIZE);
366 x_strncat (cfile->
inbuf,
" {\n", LDAP_BUFFER_SIZE);
367 ldap_value_free_len (tempbv);
370 if ((tempbv = ldap_get_values_len (ld, item->ldent,
"dhcpDnsZoneServer")) != NULL)
372 x_strncat (cfile->
inbuf,
"primary ", LDAP_BUFFER_SIZE);
373 x_strncat (cfile->
inbuf, tempbv[0]->bv_val, LDAP_BUFFER_SIZE);
375 x_strncat (cfile->
inbuf,
";\n", LDAP_BUFFER_SIZE);
376 ldap_value_free_len (tempbv);
379 if ((tempbv = ldap_get_values_len (ld, item->ldent,
"dhcpKeyDN")) != NULL)
381 cnFindStart = strchr(tempbv[0]->bv_val,
'=');
382 if (cnFindStart != NULL)
383 cnFindEnd = strchr(++cnFindStart,
',');
387 if (cnFindEnd != NULL && cnFindEnd > cnFindStart)
389 len = cnFindEnd - cnFindStart;
400 strncpy (keyCn, cnFindStart, len);
403 x_strncat (cfile->
inbuf,
"key ", LDAP_BUFFER_SIZE);
404 x_strncat (cfile->
inbuf, keyCn, LDAP_BUFFER_SIZE);
405 x_strncat (cfile->
inbuf,
";\n", LDAP_BUFFER_SIZE);
410 ldap_value_free_len (tempbv);
413 item->close_brace = 1;
418 add_to_config_stack (LDAPMessage * res, LDAPMessage * ent)
420 struct ldap_config_stack *ns;
427 ns->next = ldap_stack;
435 struct sigaction old, new;
447 new.sa_handler = SIG_IGN;
448 sigemptyset (&
new.sa_mask);
449 sigaction (SIGPIPE, &
new, &old);
451 ldap_unbind_ext_s (ld, NULL, NULL);
454 sigaction (SIGPIPE, &old, &
new);
459 _do_lookup_dhcp_string_option (
struct option_state *options,
int option_name)
465 memset (&db, 0,
sizeof (db));
469 (
struct lease *) NULL,
473 db.data != NULL && *db.data !=
'\0')
478 log_fatal (
"no memory for ldap option %d value", option_name);
480 memcpy (ret, db.data, db.len);
492 _do_lookup_dhcp_int_option (
struct option_state *options,
int option_name)
498 memset (&db, 0,
sizeof (db));
502 (
struct lease *) NULL,
506 db.data != NULL && *db.data !=
'\0')
508 ret = strtol ((
const char *) db.data, NULL, 10);
519 _do_lookup_dhcp_enum_option (
struct option_state *options,
int option_name)
525 memset (&db, 0,
sizeof (db));
529 (
struct lease *) NULL,
533 db.data != NULL && *db.data !=
'\0')
538 log_fatal (
"invalid option name %d", option_name);
549 ldap_rebind_cb (LDAP *ld, LDAP_CONST
char *url, ber_tag_t request, ber_int_t msgid,
void *parms)
552 LDAPURLDesc *ldapurl = NULL;
556 log_info(
"LDAP rebind to '%s'", url);
557 if ((ret = ldap_url_parse(url, &ldapurl)) != LDAP_SUCCESS)
559 log_error (
"Error: Can not parse ldap rebind url '%s': %s",
560 url, ldap_err2string(ret));
565 #if defined (LDAP_USE_SSL) 566 if (strcasecmp(ldapurl->lud_scheme,
"ldaps") == 0)
568 int opt = LDAP_OPT_X_TLS_HARD;
569 if ((ret = ldap_set_option (ld, LDAP_OPT_X_TLS, &opt)) != LDAP_SUCCESS)
571 log_error (
"Error: Cannot init LDAPS session to %s:%d: %s",
572 ldapurl->lud_host, ldapurl->lud_port, ldap_err2string (ret));
577 log_info (
"LDAPS session successfully enabled to %s", ldap_server);
581 if (strcasecmp(ldapurl->lud_scheme,
"ldap") == 0 &&
582 ldap_use_ssl != LDAP_SSL_OFF)
584 if ((ret = ldap_start_tls_s (ld, NULL, NULL)) != LDAP_SUCCESS)
586 log_error (
"Error: Cannot start TLS session to %s:%d: %s",
587 ldapurl->lud_host, ldapurl->lud_port, ldap_err2string (ret));
592 log_info (
"TLS session successfully started to %s:%d",
593 ldapurl->lud_host, ldapurl->lud_port);
599 if (ldap_username != NULL || *ldap_username !=
'\0')
602 creds.bv_val = strdup(ldap_password);
603 creds.bv_len = strlen(ldap_password);
606 if ((ret = ldap_sasl_bind_s (ld, who, LDAP_SASL_SIMPLE, &creds,
607 NULL, NULL, NULL)) != LDAP_SUCCESS)
609 log_error (
"Error: Cannot login into ldap server %s:%d: %s",
610 ldapurl->lud_host, ldapurl->lud_port, ldap_err2string (ret));
626 if (ldap_server == NULL)
635 ldap_server = _do_lookup_dhcp_string_option (options, SV_LDAP_SERVER);
636 ldap_dhcp_server_cn = _do_lookup_dhcp_string_option (options,
637 SV_LDAP_DHCP_SERVER_CN);
638 ldap_port = _do_lookup_dhcp_int_option (options, SV_LDAP_PORT);
639 ldap_base_dn = _do_lookup_dhcp_string_option (options, SV_LDAP_BASE_DN);
640 ldap_method = _do_lookup_dhcp_enum_option (options, SV_LDAP_METHOD);
641 ldap_debug_file = _do_lookup_dhcp_string_option (options,
643 ldap_referrals = _do_lookup_dhcp_enum_option (options, SV_LDAP_REFERRALS);
645 #if defined (LDAP_USE_SSL) 646 ldap_use_ssl = _do_lookup_dhcp_enum_option (options, SV_LDAP_SSL);
647 if( ldap_use_ssl != LDAP_SSL_OFF)
649 ldap_tls_reqcert = _do_lookup_dhcp_enum_option (options, SV_LDAP_TLS_REQCERT);
650 ldap_tls_ca_file = _do_lookup_dhcp_string_option (options, SV_LDAP_TLS_CA_FILE);
651 ldap_tls_ca_dir = _do_lookup_dhcp_string_option (options, SV_LDAP_TLS_CA_DIR);
652 ldap_tls_cert = _do_lookup_dhcp_string_option (options, SV_LDAP_TLS_CERT);
653 ldap_tls_key = _do_lookup_dhcp_string_option (options, SV_LDAP_TLS_KEY);
654 ldap_tls_crlcheck = _do_lookup_dhcp_enum_option (options, SV_LDAP_TLS_CRLCHECK);
655 ldap_tls_ciphers = _do_lookup_dhcp_string_option (options, SV_LDAP_TLS_CIPHERS);
656 ldap_tls_randfile = _do_lookup_dhcp_string_option (options, SV_LDAP_TLS_RANDFILE);
660 #if defined (LDAP_CASA_AUTH) 661 if (!load_uname_pwd_from_miCASA(&ldap_username,&ldap_password))
663 #if defined (DEBUG_LDAP) 664 log_info (
"Authentication credential taken from file");
668 ldap_username = _do_lookup_dhcp_string_option (options, SV_LDAP_USERNAME);
669 ldap_password = _do_lookup_dhcp_string_option (options, SV_LDAP_PASSWORD);
671 #if defined (LDAP_CASA_AUTH) 678 if (ldap_server == NULL || ldap_base_dn == NULL)
680 log_info (
"Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file");
681 ldap_method = LDAP_METHOD_STATIC;
685 if (ldap_debug_file != NULL && ldap_debug_fd == -1)
687 if ((ldap_debug_fd = open (ldap_debug_file, O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC,
688 S_IRUSR | S_IWUSR)) < 0)
689 log_error (
"Error opening debug LDAP log file %s: %s", ldap_debug_file,
693 #if defined (DEBUG_LDAP) 694 log_info (
"Connecting to LDAP server %s:%d", ldap_server, ldap_port);
697 #if defined (LDAP_USE_SSL) 698 if (ldap_use_ssl == -1)
705 int opt = LDAP_OPT_X_TLS_ALLOW;
706 if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_REQUIRE_CERT,
707 &opt)) != LDAP_SUCCESS)
709 log_error (
"Warning: Cannot set LDAP TLS require cert option to 'allow': %s",
710 ldap_err2string (ret));
714 if (ldap_use_ssl != LDAP_SSL_OFF)
716 if (ldap_tls_reqcert != -1)
718 if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_REQUIRE_CERT,
719 &ldap_tls_reqcert)) != LDAP_SUCCESS)
721 log_error (
"Cannot set LDAP TLS require cert option: %s",
722 ldap_err2string (ret));
726 if( ldap_tls_ca_file != NULL)
728 if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_CACERTFILE,
729 ldap_tls_ca_file)) != LDAP_SUCCESS)
731 log_error (
"Cannot set LDAP TLS CA certificate file %s: %s",
732 ldap_tls_ca_file, ldap_err2string (ret));
735 if( ldap_tls_ca_dir != NULL)
737 if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_CACERTDIR,
738 ldap_tls_ca_dir)) != LDAP_SUCCESS)
740 log_error (
"Cannot set LDAP TLS CA certificate dir %s: %s",
741 ldap_tls_ca_dir, ldap_err2string (ret));
744 if( ldap_tls_cert != NULL)
746 if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_CERTFILE,
747 ldap_tls_cert)) != LDAP_SUCCESS)
749 log_error (
"Cannot set LDAP TLS client certificate file %s: %s",
750 ldap_tls_cert, ldap_err2string (ret));
753 if( ldap_tls_key != NULL)
755 if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_KEYFILE,
756 ldap_tls_key)) != LDAP_SUCCESS)
758 log_error (
"Cannot set LDAP TLS certificate key file %s: %s",
759 ldap_tls_key, ldap_err2string (ret));
762 if( ldap_tls_crlcheck != -1)
764 int opt = ldap_tls_crlcheck;
765 if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_CRLCHECK,
766 &opt)) != LDAP_SUCCESS)
768 log_error (
"Cannot set LDAP TLS crl check option: %s",
769 ldap_err2string (ret));
772 if( ldap_tls_ciphers != NULL)
774 if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_CIPHER_SUITE,
775 ldap_tls_ciphers)) != LDAP_SUCCESS)
777 log_error (
"Cannot set LDAP TLS cipher suite %s: %s",
778 ldap_tls_ciphers, ldap_err2string (ret));
781 if( ldap_tls_randfile != NULL)
783 if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_RANDOM_FILE,
784 ldap_tls_randfile)) != LDAP_SUCCESS)
786 log_error (
"Cannot set LDAP TLS random file %s: %s",
787 ldap_tls_randfile, ldap_err2string (ret));
794 uri = malloc(strlen(ldap_server) + 16);
797 log_error (
"Cannot build ldap init URI %s:%d", ldap_server, ldap_port);
801 sprintf(uri,
"ldap://%s:%d", ldap_server, ldap_port);
802 ldap_initialize(&ld, uri);
806 log_error (
"Cannot init ldap session to %s:%d", ldap_server, ldap_port);
812 version = LDAP_VERSION3;
813 if ((ret = ldap_set_option (ld, LDAP_OPT_PROTOCOL_VERSION, &version)) != LDAP_OPT_SUCCESS)
815 log_error (
"Cannot set LDAP version to %d: %s", version,
816 ldap_err2string (ret));
819 if (ldap_referrals != -1)
821 if ((ret = ldap_set_option (ld, LDAP_OPT_REFERRALS, ldap_referrals ?
822 LDAP_OPT_ON : LDAP_OPT_OFF)) != LDAP_OPT_SUCCESS)
824 log_error (
"Cannot %s LDAP referrals option: %s",
825 (ldap_referrals ?
"enable" :
"disable"),
826 ldap_err2string (ret));
830 if ((ret = ldap_set_rebind_proc(ld, ldap_rebind_cb, NULL)) != LDAP_SUCCESS)
832 log_error (
"Warning: Cannot set ldap rebind procedure: %s",
833 ldap_err2string (ret));
836 #if defined (LDAP_USE_SSL) 837 if (ldap_use_ssl == LDAP_SSL_LDAPS ||
838 (ldap_use_ssl == LDAP_SSL_ON && ldap_port == LDAPS_PORT))
840 int opt = LDAP_OPT_X_TLS_HARD;
841 if ((ret = ldap_set_option (ld, LDAP_OPT_X_TLS, &opt)) != LDAP_SUCCESS)
843 log_error (
"Error: Cannot init LDAPS session to %s:%d: %s",
844 ldap_server, ldap_port, ldap_err2string (ret));
850 log_info (
"LDAPS session successfully enabled to %s:%d",
851 ldap_server, ldap_port);
854 else if (ldap_use_ssl != LDAP_SSL_OFF)
856 if ((ret = ldap_start_tls_s (ld, NULL, NULL)) != LDAP_SUCCESS)
858 log_error (
"Error: Cannot start TLS session to %s:%d: %s",
859 ldap_server, ldap_port, ldap_err2string (ret));
865 log_info (
"TLS session successfully started to %s:%d",
866 ldap_server, ldap_port);
871 if (ldap_username != NULL && *ldap_username !=
'\0')
873 creds.bv_val = strdup(ldap_password);
874 creds.bv_len = strlen(ldap_password);
876 if ((ret = ldap_sasl_bind_s (ld, ldap_username, LDAP_SASL_SIMPLE,
877 &creds, NULL, NULL, NULL)) != LDAP_SUCCESS)
879 log_error (
"Error: Cannot login into ldap server %s:%d: %s",
880 ldap_server, ldap_port, ldap_err2string (ret));
886 #if defined (DEBUG_LDAP) 887 log_info (
"Successfully logged into LDAP server %s", ldap_server);
893 parse_external_dns (LDAPMessage * ent)
895 char *search[] = {
"dhcpFailOverPeerDN",
"dhcpOptionsDN",
"dhcpSharedNetworkDN",
"dhcpSubnetDN",
896 "dhcpGroupDN",
"dhcpHostDN",
"dhcpClassesDN",
898 LDAPMessage * newres, * newent;
899 struct berval **tempbv;
901 #if defined (DEBUG_LDAP) 904 dn = ldap_get_dn (ld, ent);
907 log_info (
"Parsing external DNs for '%s'", dn);
917 for (i=0; search[i] != NULL; i++)
919 if ((tempbv = ldap_get_values_len (ld, ent, search[i])) == NULL)
922 for (j=0; tempbv[j] != NULL; j++)
924 if (*tempbv[j]->bv_val ==
'\0')
927 if ((ret = ldap_search_ext_s(ld, tempbv[j]->bv_val, LDAP_SCOPE_BASE,
928 "objectClass=*", NULL, 0, NULL,
929 NULL, NULL, 0, &newres)) != LDAP_SUCCESS)
931 ldap_value_free_len (tempbv);
936 #if defined (DEBUG_LDAP) 937 log_info (
"Adding contents of subtree '%s' to config stack from '%s' reference", tempbv[j], search[i]);
939 for (newent = ldap_first_entry (ld, newres);
941 newent = ldap_next_entry (ld, newent))
943 #if defined (DEBUG_LDAP) 944 dn = ldap_get_dn (ld, newent);
947 log_info (
"Adding LDAP result set starting with '%s' to config stack", dn);
952 add_to_config_stack (newres, newent);
957 ldap_value_free_len (tempbv);
963 free_stack_entry (
struct ldap_config_stack *item)
965 struct ldap_config_stack *look_ahead_pointer = item;
966 int may_free_msg = 1;
968 while (look_ahead_pointer->next != NULL)
970 look_ahead_pointer = look_ahead_pointer->next;
971 if (look_ahead_pointer->res == item->res)
979 ldap_msgfree (item->res);
986 next_ldap_entry (
struct parse *cfile)
988 struct ldap_config_stack *temp_stack;
990 if (ldap_stack != NULL && ldap_stack->close_brace)
992 x_strncat (cfile->
inbuf,
"}\n", LDAP_BUFFER_SIZE);
993 ldap_stack->close_brace = 0;
996 while (ldap_stack != NULL &&
997 (ldap_stack->ldent == NULL ||
998 (ldap_stack->ldent = ldap_next_entry (ld, ldap_stack->ldent)) == NULL))
1000 if (ldap_stack->close_brace)
1002 x_strncat (cfile->
inbuf,
"}\n", LDAP_BUFFER_SIZE);
1003 ldap_stack->close_brace = 0;
1006 temp_stack = ldap_stack;
1007 ldap_stack = ldap_stack->next;
1008 free_stack_entry (temp_stack);
1011 if (ldap_stack != NULL && ldap_stack->close_brace)
1013 x_strncat (cfile->
inbuf,
"}\n", LDAP_BUFFER_SIZE);
1014 ldap_stack->close_brace = 0;
1020 check_statement_end (
const char *statement)
1024 if (statement == NULL || *statement ==
'\0')
1032 ptr = strrchr (statement,
'}');
1036 for (++ptr; isspace ((
int)*ptr); ptr++);
1051 ptr = strrchr (statement,
';');
1055 for (++ptr; isspace ((
int)*ptr); ptr++);
1069 ldap_parse_entry_options (LDAPMessage *ent,
char *
buffer,
size_t size,
1072 struct berval **tempbv;
1075 if (ent == NULL || buffer == NULL || size == 0)
1076 return (ISC_R_FAILURE);
1078 if ((tempbv = ldap_get_values_len (ld, ent,
"dhcpStatements")) != NULL)
1080 for (i=0; tempbv[i] != NULL; i++)
1082 if (lease_limit != NULL &&
1083 strncasecmp (
"lease limit ", tempbv[i]->bv_val, 12) == 0)
1085 *lease_limit = (
int) strtol ((tempbv[i]->bv_val) + 12, NULL, 10);
1089 x_strncat (buffer, tempbv[i]->bv_val, size);
1091 switch((
int) check_statement_end (tempbv[i]->bv_val))
1095 x_strncat (buffer,
"\n", size);
1098 x_strncat (buffer,
";\n", size);
1102 ldap_value_free_len (tempbv);
1105 if ((tempbv = ldap_get_values_len (ld, ent,
"dhcpOption")) != NULL)
1107 for (i=0; tempbv[i] != NULL; i++)
1109 x_strncat (buffer,
"option ", size);
1110 x_strncat (buffer, tempbv[i]->bv_val, size);
1111 switch ((
int) check_statement_end (tempbv[i]->bv_val))
1114 x_strncat (buffer,
"\n", size);
1117 x_strncat (buffer,
";\n", size);
1121 ldap_value_free_len (tempbv);
1124 return (ISC_R_SUCCESS);
1129 ldap_generate_config_string (
struct parse *cfile)
1131 struct berval **objectClass;
1133 struct ldap_config_stack *entry;
1134 LDAPMessage * ent, * res;
1135 int i, ignore, found;
1144 if ((objectClass = ldap_get_values_len (ld, entry->ldent,
1145 "objectClass")) == NULL)
1150 for (i=0; objectClass[i] != NULL; i++)
1152 if (strcasecmp (objectClass[i]->bv_val,
"dhcpSharedNetwork") == 0)
1153 ldap_parse_shared_network (entry, cfile);
1154 else if (strcasecmp (objectClass[i]->bv_val,
"dhcpClass") == 0)
1155 ldap_parse_class (entry, cfile);
1156 else if (strcasecmp (objectClass[i]->bv_val,
"dhcpSubnet") == 0)
1157 ldap_parse_subnet (entry, cfile);
1158 else if (strcasecmp (objectClass[i]->bv_val,
"dhcpPool") == 0)
1159 ldap_parse_pool (entry, cfile);
1160 else if (strcasecmp (objectClass[i]->bv_val,
"dhcpGroup") == 0)
1161 ldap_parse_group (entry, cfile);
1162 else if (strcasecmp (objectClass[i]->bv_val,
"dhcpTSigKey") == 0)
1163 ldap_parse_key (entry, cfile);
1164 else if (strcasecmp (objectClass[i]->bv_val,
"dhcpDnsZone") == 0)
1165 ldap_parse_zone (entry, cfile);
1166 else if (strcasecmp (objectClass[i]->bv_val,
"dhcpHost") == 0)
1168 if (ldap_method == LDAP_METHOD_STATIC)
1169 ldap_parse_host (entry, cfile);
1176 else if (strcasecmp (objectClass[i]->bv_val,
"dhcpSubClass") == 0)
1178 if (ldap_method == LDAP_METHOD_STATIC)
1179 ldap_parse_subclass (entry, cfile);
1189 if (found && cfile->
inbuf[0] ==
'\0')
1196 ldap_value_free_len (objectClass);
1200 next_ldap_entry (cfile);
1204 ldap_parse_entry_options(entry->ldent, cfile->
inbuf,
1205 LDAP_BUFFER_SIZE-1, NULL);
1207 dn = ldap_get_dn (ld, entry->ldent);
1209 #if defined(DEBUG_LDAP) 1211 log_info (
"Found LDAP entry '%s'", dn);
1215 (ret = ldap_search_ext_s (ld, dn, LDAP_SCOPE_ONELEVEL,
1216 "objectClass=*", NULL, 0, NULL, NULL,
1217 NULL, 0, &res)) != LDAP_SUCCESS)
1228 if ((ent = ldap_first_entry (ld, res)) != NULL)
1230 add_to_config_stack (res, ent);
1231 parse_external_dns (entry->ldent);
1236 parse_external_dns (entry->ldent);
1237 next_ldap_entry (cfile);
1243 ldap_close_debug_fd()
1245 if (ldap_debug_fd != -1)
1247 close (ldap_debug_fd);
1254 ldap_write_debug (
const void *buff,
size_t size)
1256 if (ldap_debug_fd != -1)
1258 if (write (ldap_debug_fd, buff, size) < 0)
1260 log_error (
"Error writing to LDAP debug file %s: %s." 1261 " Disabling log file.", ldap_debug_file,
1263 ldap_close_debug_fd();
1269 ldap_read_function (
struct parse *cfile)
1271 cfile->
inbuf[0] =
'\0';
1274 while (ldap_stack != NULL && *cfile->
inbuf ==
'\0')
1275 ldap_generate_config_string (cfile);
1277 if (ldap_stack == NULL && *cfile->
inbuf ==
'\0')
1285 #if defined (DEBUG_LDAP) 1289 return (cfile->
inbuf[0]);
1294 ldap_get_host_name (LDAPMessage * ent)
1296 struct berval **name;
1300 if ((name = ldap_get_values_len (ld, ent,
"cn")) == NULL || name[0] == NULL)
1303 ldap_value_free_len (name);
1305 #if defined (DEBUG_LDAP) 1306 ret = ldap_get_dn (ld, ent);
1309 log_info (
"Cannot get cn attribute for LDAP entry %s", ret);
1316 ret =
dmalloc (strlen (name[0]->bv_val) + 1,
MDL);
1317 strcpy (ret, name[0]->bv_val);
1318 ldap_value_free_len (name);
1325 getfqhostname(
char *fqhost,
size_t size)
1327 #if defined(MAXHOSTNAMELEN) 1328 char hname[MAXHOSTNAMELEN];
1334 if(NULL == fqhost || 1 >= size)
1337 memset(hname, 0,
sizeof(hname));
1338 if( gethostname(hname,
sizeof(hname)-1))
1341 if(NULL == (hp = gethostbyname(hname)))
1344 strncpy(fqhost, hp->h_name, size-1);
1345 fqhost[size-1] =
'\0';
1351 ldap_read_config (
void)
1353 LDAPMessage * ldres, * hostres, * ent, * hostent;
1354 char hfilter[1024], sfilter[1024], fqdn[257];
1355 char *buffer, *hostdn;
1356 ldap_dn_node *curr = NULL;
1357 struct parse *cfile;
1358 struct utsname unme;
1362 struct berval **tempbv = NULL;
1367 return (ldap_server == NULL ? ISC_R_SUCCESS : ISC_R_FAILURE);
1371 return (ISC_R_FAILURE);
1373 cfile = (
struct parse *) NULL;
1374 res =
new_parse (&cfile, -1, buffer, LDAP_BUFFER_SIZE,
"LDAP", 0);
1375 if (res != ISC_R_SUCCESS)
1379 if (ldap_dhcp_server_cn != NULL)
1381 snprintf (hfilter,
sizeof (hfilter),
1382 "(&(objectClass=dhcpServer)(cn=%s))", ldap_dhcp_server_cn);
1386 if(0 == getfqhostname(fqdn,
sizeof(fqdn)))
1388 snprintf (hfilter,
sizeof (hfilter),
1389 "(&(objectClass=dhcpServer)(|(cn=%s)(cn=%s)))",
1390 unme.nodename, fqdn);
1394 snprintf (hfilter,
sizeof (hfilter),
1395 "(&(objectClass=dhcpServer)(cn=%s))", unme.nodename);
1400 if ((ret = ldap_search_ext_s (ld, ldap_base_dn, LDAP_SCOPE_SUBTREE,
1401 hfilter, NULL, 0, NULL, NULL, NULL, 0,
1402 &hostres)) != LDAP_SUCCESS)
1404 log_error (
"Cannot find host LDAP entry %s %s",
1405 ((ldap_dhcp_server_cn == NULL)?(unme.nodename):(ldap_dhcp_server_cn)), hfilter);
1407 ldap_msgfree (hostres);
1409 return (ISC_R_FAILURE);
1412 if ((hostent = ldap_first_entry (ld, hostres)) == NULL)
1414 log_error (
"Error: Cannot find LDAP entry matching %s", hfilter);
1415 ldap_msgfree (hostres);
1417 return (ISC_R_FAILURE);
1420 hostdn = ldap_get_dn (ld, hostent);
1421 #if defined(DEBUG_LDAP) 1423 log_info (
"Found dhcpServer LDAP entry '%s'", hostdn);
1426 if (hostdn == NULL ||
1427 (tempbv = ldap_get_values_len (ld, hostent,
"dhcpServiceDN")) == NULL ||
1430 log_error (
"Error: Cannot find LDAP entry matching %s", hfilter);
1433 ldap_value_free_len (tempbv);
1436 ldap_memfree (hostdn);
1437 ldap_msgfree (hostres);
1439 return (ISC_R_FAILURE);
1442 #if defined(DEBUG_LDAP) 1443 log_info (
"LDAP: Parsing dhcpServer options '%s' ...", hostdn);
1446 cfile->
inbuf[0] =
'\0';
1447 ldap_parse_entry_options(hostent, cfile->
inbuf, LDAP_BUFFER_SIZE, NULL);
1454 if (res != ISC_R_SUCCESS)
1456 log_error (
"LDAP: cannot parse dhcpServer entry '%s'", hostdn);
1457 ldap_memfree (hostdn);
1461 cfile->
inbuf[0] =
'\0';
1463 ldap_msgfree (hostres);
1469 cfile->read_function = ldap_read_function;
1471 res = ISC_R_SUCCESS;
1472 for (cnt=0; tempbv[cnt] != NULL; cnt++)
1474 snprintf(sfilter,
sizeof(sfilter),
"(&(objectClass=dhcpService)" 1475 "(|(dhcpPrimaryDN=%s)(dhcpSecondaryDN=%s)))",
1478 if ((ret = ldap_search_ext_s (ld, tempbv[cnt]->bv_val, LDAP_SCOPE_BASE,
1479 sfilter, NULL, 0, NULL, NULL, NULL,
1480 0, &ldres)) != LDAP_SUCCESS)
1482 log_error (
"Error searching for dhcpServiceDN '%s': %s. Please update the LDAP entry '%s'",
1483 tempbv[cnt]->bv_val, ldap_err2string (ret), hostdn);
1485 ldap_msgfree(ldres);
1486 res = ISC_R_FAILURE;
1490 if ((ent = ldap_first_entry (ld, ldres)) == NULL)
1492 log_error (
"Error: Cannot find dhcpService DN '%s' with primary or secondary server reference. Please update the LDAP server entry '%s'",
1493 tempbv[cnt]->bv_val, hostdn);
1495 ldap_msgfree(ldres);
1496 res = ISC_R_FAILURE;
1509 length = strlen (tempbv[cnt]->bv_val);
1511 if (curr->dn == NULL)
1517 strcpy (curr->dn, tempbv[cnt]->bv_val);
1525 if (ldap_service_dn_tail != NULL)
1526 ldap_service_dn_tail->next = curr;
1528 ldap_service_dn_head = curr;
1530 ldap_service_dn_tail = curr;
1533 log_fatal (
"no memory to remember ldap service dn");
1535 #if defined (DEBUG_LDAP) 1536 log_info (
"LDAP: Parsing dhcpService DN '%s' ...", tempbv[cnt]);
1538 add_to_config_stack (ldres, ent);
1540 if (res != ISC_R_SUCCESS)
1542 log_error (
"LDAP: cannot parse dhcpService entry '%s'", tempbv[cnt]->bv_val);
1548 ldap_close_debug_fd();
1550 ldap_memfree (hostdn);
1551 ldap_value_free_len (tempbv);
1553 if (res != ISC_R_SUCCESS)
1555 struct ldap_config_stack *temp_stack;
1557 while ((curr = ldap_service_dn_head) != NULL)
1559 ldap_service_dn_head = curr->next;
1564 ldap_service_dn_tail = NULL;
1566 while ((temp_stack = ldap_stack) != NULL)
1568 ldap_stack = temp_stack->next;
1569 free_stack_entry (temp_stack);
1576 if (ldap_method == LDAP_METHOD_STATIC)
1590 ldap_parse_options (LDAPMessage * ent,
struct group *
group,
1592 struct class **
class)
1594 int declaration, lease_limit;
1595 char option_buffer[8192];
1597 struct parse *cfile;
1602 *option_buffer =
'\0';
1608 char *hostdn, *basedn, *temp1, *temp2, filter[1024];
1609 LDAPMessage *groupdn, *entry;
1612 hostdn = ldap_get_dn (ld, ent);
1617 temp1 = strchr (hostdn,
'=');
1619 temp1 = strchr (++temp1,
'=');
1621 temp2 = strchr (++temp1,
',');
1627 snprintf (filter,
sizeof(filter),
1628 "(&(cn=%.*s)(objectClass=dhcpGroup))",
1629 (
int)(temp2 - temp1), temp1);
1631 basedn = strchr (temp1,
',');
1636 if (basedn != NULL && *basedn !=
'\0')
1638 ret = ldap_search_ext_s (ld, basedn, LDAP_SCOPE_SUBTREE, filter,
1639 NULL, 0, NULL, NULL, NULL, 0, &groupdn);
1640 if (ret == LDAP_SUCCESS)
1642 if ((entry = ldap_first_entry (ld, groupdn)) != NULL)
1644 res = ldap_parse_entry_options (entry, option_buffer,
1645 sizeof(option_buffer) - 1,
1647 if (res != ISC_R_SUCCESS)
1650 *option_buffer =
'\0';
1654 ldap_msgfree( groupdn);
1657 ldap_memfree( hostdn);
1661 res = ldap_parse_entry_options (ent, option_buffer,
sizeof(option_buffer) - 1,
1663 if (res != ISC_R_SUCCESS)
1664 return (lease_limit);
1666 option_buffer[
sizeof(option_buffer) - 1] =
'\0';
1667 if (*option_buffer ==
'\0')
1668 return (lease_limit);
1670 cfile = (
struct parse *) NULL;
1671 res =
new_parse (&cfile, -1, option_buffer, strlen (option_buffer),
1672 type ==
HOST_DECL ?
"LDAP-HOST" :
"LDAP-SUBCLASS", 0);
1673 if (res != ISC_R_SUCCESS)
1674 return (lease_limit);
1676 #if defined (DEBUG_LDAP) 1677 log_info (
"Sending the following options: '%s'", option_buffer);
1686 declaration =
parse_statement (cfile, group, type, host, declaration);
1691 return (lease_limit);
1697 find_haddr_in_ldap (
struct host_decl **hp,
int htype,
unsigned hlen,
1698 const unsigned char *haddr,
const char *
file,
int line)
1700 char buf[128], *type_str;
1701 LDAPMessage * res, *ent;
1703 isc_result_t status;
1707 if (ldap_method == LDAP_METHOD_STATIC)
1718 type_str =
"ethernet";
1721 type_str =
"token-ring";
1727 log_info (
"Ignoring unknown type %d", htype);
1735 snprintf (buf,
sizeof (buf),
1736 "(&(objectClass=dhcpHost)(dhcpHWAddress=%s %s))",
1740 for (curr = ldap_service_dn_head;
1741 curr != NULL && *curr->dn !=
'\0';
1744 #if defined (DEBUG_LDAP) 1745 log_info (
"Searching for %s in LDAP tree %s", buf, curr->dn);
1747 ret = ldap_search_ext_s (ld, curr->dn, LDAP_SCOPE_SUBTREE, buf, NULL, 0,
1748 NULL, NULL, NULL, 0, &res);
1750 if(ret == LDAP_SERVER_DOWN)
1752 log_info (
"LDAP server was down, trying to reconnect...");
1758 log_info (
"LDAP reconnect failed - try again later...");
1762 ret = ldap_search_ext_s (ld, curr->dn, LDAP_SCOPE_SUBTREE, buf, NULL,
1763 0, NULL, NULL, NULL, 0, &res);
1766 if (ret == LDAP_SUCCESS)
1768 if( (ent = ldap_first_entry (ld, res)) != NULL)
1771 #if defined (DEBUG_LDAP) 1772 log_info (
"No host entry for %s in LDAP tree %s",
1789 if (ret != LDAP_NO_SUCH_OBJECT && ret != LDAP_SUCCESS)
1791 log_error (
"Cannot search for %s in LDAP tree %s: %s", buf,
1792 curr->dn, ldap_err2string (ret));
1796 #if defined (DEBUG_LDAP) 1799 log_info (
"ldap_search_ext_s returned %s when searching for %s in %s",
1800 ldap_err2string (ret), buf, curr->dn);
1808 #if defined (DEBUG_LDAP) 1809 char *dn = ldap_get_dn (ld, ent);
1812 log_info (
"Found dhcpHWAddress LDAP entry %s", dn);
1818 status = host_allocate (&host,
MDL);
1819 if (status != ISC_R_SUCCESS)
1821 log_fatal (
"can't allocate host decl struct: %s",
1822 isc_result_totext (status));
1827 host->
name = ldap_get_host_name (ent);
1828 if (host->
name == NULL)
1830 host_dereference (&host,
MDL);
1838 host_dereference (&host,
MDL);
1851 if(res) ldap_msgfree (res);
1857 find_subclass_in_ldap (
struct class *
class,
struct class **newclass,
1860 LDAPMessage * res, * ent;
1861 int ret, lease_limit;
1862 isc_result_t status;
1866 if (ldap_method == LDAP_METHOD_STATIC)
1874 snprintf (buf,
sizeof (buf),
1875 "(&(objectClass=dhcpSubClass)(cn=%s)(dhcpClassData=%s))",
1878 #if defined (DEBUG_LDAP) 1879 log_info (
"Searching LDAP for %s", buf);
1883 for (curr = ldap_service_dn_head;
1884 curr != NULL && *curr->dn !=
'\0';
1887 #if defined (DEBUG_LDAP) 1888 log_info (
"Searching for %s in LDAP tree %s", buf, curr->dn);
1890 ret = ldap_search_ext_s (ld, curr->dn, LDAP_SCOPE_SUBTREE, buf, NULL, 0,
1891 NULL, NULL, NULL, 0, &res);
1893 if(ret == LDAP_SERVER_DOWN)
1895 log_info (
"LDAP server was down, trying to reconnect...");
1902 log_info (
"LDAP reconnect failed - try again later...");
1906 ret = ldap_search_ext_s (ld, curr->dn, LDAP_SCOPE_SUBTREE, buf,
1907 NULL, 0, NULL, NULL, NULL, 0, &res);
1910 if (ret == LDAP_SUCCESS)
1912 if( (ent = ldap_first_entry (ld, res)) != NULL)
1915 #if defined (DEBUG_LDAP) 1916 log_info (
"No subclass entry for %s in LDAP tree %s",
1933 if (ret != LDAP_NO_SUCH_OBJECT && ret != LDAP_SUCCESS)
1935 log_error (
"Cannot search for %s in LDAP tree %s: %s", buf,
1936 curr->dn, ldap_err2string (ret));
1940 #if defined (DEBUG_LDAP) 1943 log_info (
"ldap_search_ext_s returned %s when searching for %s in %s",
1944 ldap_err2string (ret), buf, curr->dn);
1952 #if defined (DEBUG_LDAP) 1953 char *dn = ldap_get_dn (ld, ent);
1956 log_info (
"Found subclass LDAP entry %s", dn);
1961 status = class_allocate (newclass,
MDL);
1962 if (status != ISC_R_SUCCESS)
1964 log_error (
"Cannot allocate memory for a new class");
1970 class_reference (&(*newclass)->superclass,
class,
MDL);
1971 lease_limit = ldap_parse_options (ent, (*newclass)->group,
1973 if (lease_limit == 0)
1974 (*newclass)->lease_limit =
class->lease_limit;
1976 class->lease_limit = lease_limit;
1978 if ((*newclass)->lease_limit)
1980 (*newclass)->billed_leases =
1982 if (!(*newclass)->billed_leases)
1985 class_dereference (newclass,
MDL);
1989 memset ((*newclass)->billed_leases, 0,
1990 ((*newclass)->lease_limit * sizeof (
struct lease *)));
1999 if(res) ldap_msgfree (res);
struct binding_scope * global_scope
isc_result_t end_parse(struct parse **cfile)
void * dmalloc(unsigned, const char *, int)
struct universe server_universe
char * print_hw_addr(int htype, const int hlen, const unsigned char *data) const
#define print_hex_1(len, data, limit)
int group_reference(struct group **ptr, struct group *bp, const char *file, int line)
void data_string_forget(struct data_string *data, const char *file, int line)
struct group * root_group
int log_error(const char *,...) __attribute__((__format__(__printf__
enum dhcp_token peek_token(const char **rval, unsigned *rlen, struct parse *cfile)
void log_fatal(const char *,...) __attribute__((__format__(__printf__
void execute_statements_in_scope(struct binding_value **result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *out_options, struct binding_scope **scope, struct group *group, struct group *limiting_group, struct on_star *on_star)
int option_state_allocate(struct option_state **ptr, const char *file, int line)
int evaluate_option_cache(struct data_string *result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct option_cache *oc, const char *file, int line)
void dfree(void *, const char *, int)
struct option_cache * lookup_option(struct universe *universe, struct option_state *options, unsigned code)
int int log_info(const char *,...) __attribute__((__format__(__printf__
int parse_statement(struct parse *, struct group *, int, struct host_decl *, int)
int option_state_dereference(struct option_state **ptr, const char *file, int line)
#define print_hex_2(len, data, limit)
const unsigned char * data
isc_result_t conf_file_subparse(struct parse *, struct group *, int)
void data_string_copy(struct data_string *dest, const struct data_string *src, const char *file, int line)
int clone_group(struct group **gp, struct group *group, const char *file, int line)
isc_result_t new_parse(struct parse **cfile, int file, char *inbuf, unsigned buflen, const char *name, int eolp)