[PC-BSD Commits] r18148 - pcbsd/current/src-sh/pc-adctl/ldap
svn at pcbsd.org
svn at pcbsd.org
Sat Aug 4 02:43:48 PDT 2012
Author: johnh
Date: 2012-08-04 09:43:47 +0000 (Sat, 04 Aug 2012)
New Revision: 18148
Modified:
pcbsd/current/src-sh/pc-adctl/ldap/ldapconf.c
Log:
Working modify
Modified: pcbsd/current/src-sh/pc-adctl/ldap/ldapconf.c
===================================================================
--- pcbsd/current/src-sh/pc-adctl/ldap/ldapconf.c 2012-08-04 09:17:38 UTC (rev 18147)
+++ pcbsd/current/src-sh/pc-adctl/ldap/ldapconf.c 2012-08-04 09:43:47 UTC (rev 18148)
@@ -592,26 +592,95 @@
static int
ldap_op_modify(struct ldap_modification *lm)
{
-#if 0
int exists = 0;
+ unsigned long type;
struct ldap_entry *le, *letmp;
if (lm == NULL)
return (-1);
+ type = str2type(lm->name);
TAILQ_FOREACH_SAFE(le, &ldapconf, entries, letmp) {
- if (le->type == LDAP_ENTRY_PAIR &&
- strcasecmp(le->lep_name, lm->name) == 0) {
- xfree(&le->lep_value);
- le->lep_value = xstrdup(lm->value);
- exists = 1;
- break;
+ switch (le->type) {
+ case LDAP_ENTRY_URI_LIST: {
+ if (type == URI) {
+ struct ldap_uri *lu, *lutmp;
+ struct ldap_uri_list *lul = le->entry;
+ struct ldap_entry *new = option2entry(type, lm->value);
+
+ TAILQ_FOREACH_SAFE(lu, lul, entries, lutmp) {
+ TAILQ_REMOVE(lul, lu, entries);
+ xfree(&lu->uri);
+ xfree(&lu);
+ }
+
+ lu = new->entry;
+ xfree(&new);
+
+ TAILQ_INSERT_TAIL(lul, lu, entries);
+ exists = 1;
+ }
+ break;
+ }
+
+ case LDAP_ENTRY_HOST_LIST: {
+ if (type == HOST) {
+ struct ldap_host *lh, *lhtmp;
+ struct ldap_host_list *lhl = le->entry;
+ struct ldap_entry *new = option2entry(type, lm->value);
+
+ TAILQ_FOREACH_SAFE(lh, lhl, entries, lhtmp) {
+ TAILQ_REMOVE(lhl, lh, entries);
+ xfree(&lh->host);
+ xfree(&lh);
+ }
+
+ lh = new->entry;
+ xfree(&new);
+
+ TAILQ_INSERT_TAIL(lhl, lh, entries);
+ exists = 1;
+ }
+ break;
+ }
+
+ case LDAP_ENTRY_SASL_SECPROPS_LIST: {
+ if (type == SASL_SECPROPS) {
+ struct sasl_secprops *ss, *sstmp;
+ struct sasl_secprops_list *lsl = le->entry;
+ struct ldap_entry *new = option2entry(type, lm->value);
+
+ TAILQ_FOREACH_SAFE(ss, lsl, entries, sstmp) {
+ TAILQ_REMOVE(lsl, ss, entries);
+ xfree(&ss);
+ }
+
+ ss = new->entry;
+ xfree(&new);
+
+ TAILQ_INSERT_TAIL(lsl, ss, entries);
+ exists = 1;
+ }
+ break;
+ }
+
+ default:
+ if (le->type == type) {
+ struct ldap_entry *new = option2entry(le->type, lm->value);
+
+ TAILQ_INSERT_AFTER(&ldapconf, le, new, entries);
+ TAILQ_REMOVE(&ldapconf, le, entries);
+ ldap_entry_free(&le);
+
+ exists = 1;
+ }
+
+ break;
}
}
if (exists == 0 && lm->create > 0)
return (ldap_op_add(lm));
-#endif
return (0);
}
More information about the Commits
mailing list