298 lines
10 KiB
Plaintext
298 lines
10 KiB
Plaintext
--- server/ldap.c
|
|
+++ server/ldap.c 2007/01/24 12:40:58
|
|
@@ -68,6 +68,13 @@
|
|
static ldap_dn_node *ldap_service_dn_tail = NULL;
|
|
|
|
|
|
+static char *
|
|
+x_strncat(char *dst, const char *src, size_t dst_size)
|
|
+{
|
|
+ size_t len = strlen(dst);
|
|
+ return strncat(dst, src, dst_size > len ? dst_size - len - 1: 0);
|
|
+}
|
|
+
|
|
static void
|
|
ldap_parse_class (struct ldap_config_stack *item, struct parse *cfile)
|
|
{
|
|
@@ -82,9 +89,9 @@
|
|
return;
|
|
}
|
|
|
|
- strncat (cfile->inbuf, "class \"", LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, "\" {\n", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, "class \"", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, "\" {\n", LDAP_BUFFER_SIZE);
|
|
|
|
item->close_brace = 1;
|
|
ldap_value_free (tempstr);
|
|
@@ -116,11 +123,11 @@
|
|
return;
|
|
}
|
|
|
|
- strncat (cfile->inbuf, "subclass ", LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, classdata[0], LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, " ", LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, "subclass ", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, classdata[0], LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, " ", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE);
|
|
|
|
item->close_brace = 1;
|
|
ldap_value_free (tempstr);
|
|
@@ -144,14 +151,14 @@
|
|
|
|
hwaddr = ldap_get_values (ld, item->ldent, "dhcpHWAddress");
|
|
|
|
- strncat (cfile->inbuf, "host ", LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, "host ", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
|
|
|
|
if (hwaddr != NULL && hwaddr[0] != NULL)
|
|
{
|
|
- strncat (cfile->inbuf, " {\nhardware ", LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, hwaddr[0], LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, " {\nhardware ", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, hwaddr[0], LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
|
|
ldap_value_free (hwaddr);
|
|
}
|
|
|
|
@@ -174,9 +181,9 @@
|
|
return;
|
|
}
|
|
|
|
- strncat (cfile->inbuf, "shared-network \"", LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, "\" {\n", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, "shared-network \"", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, "\" {\n", LDAP_BUFFER_SIZE);
|
|
|
|
item->close_brace = 1;
|
|
ldap_value_free (tempstr);
|
|
@@ -228,14 +235,14 @@
|
|
return;
|
|
}
|
|
|
|
- strncat (cfile->inbuf, "subnet ", LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, "subnet ", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
|
|
|
|
- strncat (cfile->inbuf, " netmask ", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, " netmask ", LDAP_BUFFER_SIZE);
|
|
parse_netmask (strtol (netmaskstr[0], NULL, 10), netmaskbuf);
|
|
- strncat (cfile->inbuf, netmaskbuf, LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, netmaskbuf, LDAP_BUFFER_SIZE);
|
|
|
|
- strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE);
|
|
|
|
ldap_value_free (tempstr);
|
|
ldap_value_free (netmaskstr);
|
|
@@ -244,10 +251,10 @@
|
|
{
|
|
for (i=0; tempstr[i] != NULL; i++)
|
|
{
|
|
- strncat (cfile->inbuf, "range", LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, " ", LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, tempstr[i], LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, "range", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, " ", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, tempstr[i], LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
|
|
}
|
|
ldap_value_free (tempstr);
|
|
}
|
|
@@ -262,17 +269,17 @@
|
|
char **tempstr;
|
|
int i;
|
|
|
|
- strncat (cfile->inbuf, "pool {\n", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, "pool {\n", LDAP_BUFFER_SIZE);
|
|
|
|
if ((tempstr = ldap_get_values (ld, item->ldent, "dhcpRange")) != NULL)
|
|
{
|
|
- strncat (cfile->inbuf, "range", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, "range", LDAP_BUFFER_SIZE);
|
|
for (i=0; tempstr[i] != NULL; i++)
|
|
{
|
|
- strncat (cfile->inbuf, " ", LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, tempstr[i], LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, " ", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, tempstr[i], LDAP_BUFFER_SIZE);
|
|
}
|
|
- strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
|
|
ldap_value_free (tempstr);
|
|
}
|
|
|
|
@@ -280,8 +287,8 @@
|
|
{
|
|
for (i=0; tempstr[i] != NULL; i++)
|
|
{
|
|
- strncat (cfile->inbuf, tempstr[i], LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, tempstr[i], LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
|
|
}
|
|
ldap_value_free (tempstr);
|
|
}
|
|
@@ -293,7 +300,7 @@
|
|
static void
|
|
ldap_parse_group (struct ldap_config_stack *item, struct parse *cfile)
|
|
{
|
|
- strncat (cfile->inbuf, "group {\n", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, "group {\n", LDAP_BUFFER_SIZE);
|
|
item->close_brace = 1;
|
|
}
|
|
|
|
@@ -305,25 +312,25 @@
|
|
|
|
if ((tempstr = ldap_get_values (ld, item->ldent, "cn")) != NULL)
|
|
{
|
|
- strncat (cfile->inbuf, "key ", LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, "key ", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE);
|
|
ldap_value_free (tempstr);
|
|
}
|
|
|
|
if ((tempstr = ldap_get_values (ld, item->ldent, "dhcpKeyAlgorithm")) != NULL)
|
|
{
|
|
- strncat (cfile->inbuf, "algorithm ", LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, "algorithm ", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
|
|
ldap_value_free (tempstr);
|
|
}
|
|
|
|
if ((tempstr = ldap_get_values (ld, item->ldent, "dhcpKeySecret")) != NULL)
|
|
{
|
|
- strncat (cfile->inbuf, "secret ", LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, "secret ", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
|
|
ldap_value_free (tempstr);
|
|
}
|
|
|
|
@@ -341,18 +348,18 @@
|
|
|
|
if ((tempstr = ldap_get_values (ld, item->ldent, "cn")) != NULL)
|
|
{
|
|
- strncat (cfile->inbuf, "zone ", LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, "zone ", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE);
|
|
ldap_value_free (tempstr);
|
|
}
|
|
|
|
if ((tempstr = ldap_get_values (ld, item->ldent, "dhcpDnsZoneServer")) != NULL)
|
|
{
|
|
- strncat (cfile->inbuf, "primary ", LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, "primary ", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
|
|
|
|
- strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
|
|
ldap_value_free (tempstr);
|
|
}
|
|
|
|
@@ -380,9 +387,9 @@
|
|
strncpy (keyCn, cnFindStart, len);
|
|
keyCn[len] = '\0';
|
|
|
|
- strncat (cfile->inbuf, "key ", LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, keyCn, LDAP_BUFFER_SIZE);
|
|
- strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, "key ", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, keyCn, LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
|
|
|
|
dfree (keyCn, MDL);
|
|
}
|
|
@@ -731,7 +738,7 @@
|
|
|
|
if (ldap_stack != NULL && ldap_stack->close_brace)
|
|
{
|
|
- strncat (cfile->inbuf, "}\n", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, "}\n", LDAP_BUFFER_SIZE);
|
|
ldap_stack->close_brace = 0;
|
|
}
|
|
|
|
@@ -741,7 +748,7 @@
|
|
{
|
|
if (ldap_stack->close_brace)
|
|
{
|
|
- strncat (cfile->inbuf, "}\n", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, "}\n", LDAP_BUFFER_SIZE);
|
|
ldap_stack->close_brace = 0;
|
|
}
|
|
|
|
@@ -752,7 +759,7 @@
|
|
|
|
if (ldap_stack != NULL && ldap_stack->close_brace)
|
|
{
|
|
- strncat (cfile->inbuf, "}\n", LDAP_BUFFER_SIZE);
|
|
+ x_strncat (cfile->inbuf, "}\n", LDAP_BUFFER_SIZE);
|
|
ldap_stack->close_brace = 0;
|
|
}
|
|
}
|
|
@@ -828,16 +835,16 @@
|
|
continue;
|
|
}
|
|
|
|
- strncat (buffer, tempstr[i], size);
|
|
+ x_strncat (buffer, tempstr[i], size);
|
|
|
|
switch((int) check_statement_end (tempstr[i]))
|
|
{
|
|
case '}':
|
|
case ';':
|
|
- strncat (buffer, "\n", size);
|
|
+ x_strncat (buffer, "\n", size);
|
|
break;
|
|
default:
|
|
- strncat (buffer, ";\n", size);
|
|
+ x_strncat (buffer, ";\n", size);
|
|
break;
|
|
}
|
|
}
|
|
@@ -848,15 +855,15 @@
|
|
{
|
|
for (i=0; tempstr[i] != NULL; i++)
|
|
{
|
|
- strncat (buffer, "option ", size);
|
|
- strncat (buffer, tempstr[i], size);
|
|
+ x_strncat (buffer, "option ", size);
|
|
+ x_strncat (buffer, tempstr[i], size);
|
|
switch ((int) check_statement_end (tempstr[i]))
|
|
{
|
|
case ';':
|
|
- strncat (buffer, "\n", size);
|
|
+ x_strncat (buffer, "\n", size);
|
|
break;
|
|
default:
|
|
- strncat (buffer, ";\n", size);
|
|
+ x_strncat (buffer, ";\n", size);
|
|
break;
|
|
}
|
|
}
|