From 3f65ea3cb042826f7343d80a2a1c048fba16edfa Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Mon, 9 Jun 2008 19:21:43 +0000 Subject: Bug fixes. --- plugin/autoserial.c | 21 ++++++++++++++++++++- plugin/dnsnotify.c | 8 +++++--- plugin/plugin.c | 6 ++++-- 3 files changed, 29 insertions(+), 6 deletions(-) (limited to 'plugin') diff --git a/plugin/autoserial.c b/plugin/autoserial.c index d10f8a5..16af5d7 100644 --- a/plugin/autoserial.c +++ b/plugin/autoserial.c @@ -18,12 +18,12 @@ * DECLARATIONS */ -/* TODO: Fill these in from settings */ static const char *dnsserial_soa_attribute = "sOARecord"; static const char *dnsserial_soa_base = ""; static Slapi_Mutex *dnsserial_mutex = NULL; static strset *dnsserial_soa_cache = NULL; +static int dnsserial_enable = 0; /* --------------------------------------------------------------------------------- * MEMORY ALLOCATION @@ -389,6 +389,9 @@ change_soa_attribute (const char *dn, const char *soa_old, const char *soa_new) return -1; } + /* Call the dns notify code, and note that we've changed a sOARecord */ + dnsnotify_post_modify (dn, mods); + trace ("success"); return 0; } @@ -433,6 +436,9 @@ autoserial_post_delete (const char *dn) return_if_fail (dn && dn[0]); + if (!dnsserial_enable) + return; + /* A DN that is an SOA? */ if (present_in_soa_cache (dn)) { remove_from_soa_cache (dn); @@ -455,6 +461,9 @@ autoserial_post_modify (const char *dn, LDAPMod **mods) return_if_fail (dn && dn[0]); + if (!dnsserial_enable) + return; + /* Add or remove from cache as appropriate */ soa = load_soa_attribute(dn); if (soa) { @@ -484,6 +493,9 @@ autoserial_post_modrdn (const char *odn, const char *ndn) return_if_fail (odn && odn[0]); return_if_fail (ndn && ndn[0]); + if (!dnsserial_enable) + return; + /* A DN that is an SOA? */ if (present_in_soa_cache (odn)) { @@ -507,6 +519,9 @@ autoserial_post_add (const char *dn) return_if_fail (dn && dn[0]); + if (!dnsserial_enable) + return; + /* A DN that is an SOA? */ soa = load_soa_attribute (dn); if (soa) { @@ -536,6 +551,10 @@ autoserial_config (const char *name, const char *value) } else if (strcmp ("base-dn", name) == 0 && value) { dnsserial_soa_base = value; return 1; + + } else if (strcmp ("enable-auto-serial", name) == 0 && !value) { + dnsserial_enable = 1; + return 1; } return 0; diff --git a/plugin/dnsnotify.c b/plugin/dnsnotify.c index 132726f..d610414 100644 --- a/plugin/dnsnotify.c +++ b/plugin/dnsnotify.c @@ -41,7 +41,7 @@ load_soa_ns_attributes (const char *dn, char **soa_result, char ***ns_result) Slapi_PBlock *pb; Slapi_Attr *attr; LDAPControl *ctrl; - char *attrs[2]; + char *attrs[3]; char *soa, **ns; int rc, code, num, i; @@ -52,7 +52,8 @@ load_soa_ns_attributes (const char *dn, char **soa_result, char ***ns_result) ctrl = NULL; /* No controls */ attrs[0] = (char*)dnsnotify_soa_attribute; - attrs[1] = NULL; + attrs[1] = (char*)dnsnotify_ns_attribute; + attrs[2] = NULL; trace ("performing internal search"); @@ -77,6 +78,7 @@ load_soa_ns_attributes (const char *dn, char **soa_result, char ***ns_result) return_val_if_fail (entries, 0); soa = NULL; + ns = NULL; if (entries[0]) { if (slapi_entry_attr_find (entries[0], (char*)dnsnotify_soa_attribute, &attr) >= 0 && attr && slapi_attr_get_values (attr, &values) >= 0 && values && values[0]) { @@ -108,7 +110,7 @@ load_soa_ns_attributes (const char *dn, char **soa_result, char ***ns_result) slapi_pblock_destroy (pb); /* Only proceed if we have all the data we need */ - if (soa && soa[0] && ns && ns[0] && ns[0]) { + if (soa && soa[0] && ns && ns[0]) { *soa_result = soa; *ns_result = ns; return 1; diff --git a/plugin/plugin.c b/plugin/plugin.c index c38eb67..c34294a 100644 --- a/plugin/plugin.c +++ b/plugin/plugin.c @@ -310,8 +310,10 @@ plugin_init (Slapi_PBlock *pb) plugin_arguments[i] = slapi_ch_strdup (argv[i]); arg = trim (plugin_arguments[i]); - value = strchr (arg, '='); - if (value) { + value = arg + strcspn (arg, ":="); + if (!*value) { + value = NULL; + } else { *value = 0; value = trim (value + 1); } -- cgit v1.2.3