[PC-BSD Commits] r18401 - pcbsd/current/src-sh/pc-adctl/ldap

svn at pcbsd.org svn at pcbsd.org
Fri Aug 10 22:08:28 PDT 2012


Author: johnh
Date: 2012-08-11 05:08:28 +0000 (Sat, 11 Aug 2012)
New Revision: 18401

Modified:
   pcbsd/current/src-sh/pc-adctl/ldap/ldapconf.c
Log:
Bugfix. HOST, URI and SASL_SECPROP would not create new lists if a list
did not exist.



Modified: pcbsd/current/src-sh/pc-adctl/ldap/ldapconf.c
===================================================================
--- pcbsd/current/src-sh/pc-adctl/ldap/ldapconf.c	2012-08-11 04:11:23 UTC (rev 18400)
+++ pcbsd/current/src-sh/pc-adctl/ldap/ldapconf.c	2012-08-11 05:08:28 UTC (rev 18401)
@@ -523,7 +523,92 @@
 	return (le);
 }
 
+static struct ldap_entry *
+ldap_create_uri_list(struct ldap_modification *lm)
+{
+	struct ldap_uri *lu;
+	struct ldap_entry *le;
+	struct ldap_uri_list *lul;
 
+	if (lm == NULL)
+		return (NULL);
+
+	lu = xalloc(sizeof(*lu));
+	lu->uri = xstrdup(lm->value);
+
+	le = xalloc(sizeof(*le));
+
+	lul = xalloc(sizeof(*lul));
+	TAILQ_INIT(lul);
+
+	le->type = LDAP_ENTRY_URI_LIST;
+	le->entry = lul;
+
+	TAILQ_INSERT_TAIL(lul, lu, entries);
+	return (le);
+}
+
+static struct ldap_entry *
+ldap_create_host_list(struct ldap_modification *lm)
+{
+	struct ldap_host *lh;
+	struct ldap_entry *le;
+	struct ldap_host_list *lhl;
+
+	if (lm == NULL)
+		return (NULL);
+
+	lh = xalloc(sizeof(*lh));
+	lh->host = xstrdup(lm->value);
+
+	le = xalloc(sizeof(*le));
+
+	lhl = xalloc(sizeof(*lhl));
+	TAILQ_INIT(lhl);
+
+	le->type = LDAP_ENTRY_HOST_LIST;
+	le->entry = lhl;
+
+	TAILQ_INSERT_TAIL(lhl, lh, entries);
+	return (le);
+}
+
+static struct ldap_entry *
+ldap_create_sasl_secprops_list(struct ldap_modification *lm)
+{
+	struct ldap_entry *le;
+	struct sasl_secprops_list *lsl;
+	char *ptr, *str, *tmp, *save;
+
+	if (lm == NULL)
+		return (NULL);
+
+	lsl = xalloc(sizeof(*lsl));
+	TAILQ_INIT(lsl);
+
+	le->type = LDAP_ENTRY_SASL_SECPROPS_LIST;
+	le->entry = lsl;
+
+	ptr = xstrdup(lm->value);
+	save = ptr;
+
+	while ((tmp = strsep(&ptr, ",")) != NULL) {
+		struct sasl_secprops *ss = xalloc(sizeof(*ss));
+
+		str = strsep(&tmp, "=");
+		ss->properties = str2properties(str, NONE);
+		ss->factor = -1;
+
+		if (tmp != NULL)
+			ss->factor = strtol(tmp, 0, 10);
+
+		TAILQ_INSERT_TAIL(lsl, ss, entries);
+	}
+
+	xfree(&save);
+	return (le);
+}
+
 static int
 ldap_op_add(struct ldap_modification *lm)
 {
@@ -582,8 +667,31 @@
 	}
 
 	if (exists == 0) {
-		struct ldap_entry *new = option2entry(type, lm->value);
-		TAILQ_INSERT_TAIL(&ldapconf, new, entries);
+		switch (type) {
+			case URI: {
+				struct ldap_entry *new = ldap_create_uri_list(lm);
+				TAILQ_INSERT_TAIL(&ldapconf, new, entries);
+				break;
+			}
+			
+			case HOST: {
+				struct ldap_entry *new = ldap_create_host_list(lm);
+				TAILQ_INSERT_TAIL(&ldapconf, new, entries);
+				break;
+			}
+
+			case SASL_SECPROPS: {
+				struct ldap_entry *new = ldap_create_sasl_secprops_list(lm);
+				TAILQ_INSERT_TAIL(&ldapconf, new, entries);
+				break;
+			}
+
+			default: {
+				struct ldap_entry *new = option2entry(type, lm->value);
+				TAILQ_INSERT_TAIL(&ldapconf, new, entries);
+				break;
+			}
+		}
 	}
 
 	return (0);



More information about the Commits mailing list