diff options
Diffstat (limited to 'plugin/plugin.c')
-rw-r--r-- | plugin/plugin.c | 93 |
1 files changed, 13 insertions, 80 deletions
diff --git a/plugin/plugin.c b/plugin/plugin.c index 8f91f52..76a493d 100644 --- a/plugin/plugin.c +++ b/plugin/plugin.c @@ -184,68 +184,7 @@ dn_build_normalize (const char *dn, const char *rdn) } static int -post_delete (Slapi_PBlock *pb) -{ - int rc, code; - char *dn; - - return_val_if_fail (pb, -1); - - /* Make sure it was successful, don't process errors */ - rc = slapi_pblock_get (pb, SLAPI_RESULT_CODE, &code); - return_val_if_fail (rc >= 0, -1); - if (code != LDAP_SUCCESS) - return 0; - - /* Get out the DN and normalize it */ - rc = slapi_pblock_get (pb, SLAPI_DELETE_TARGET, &dn); - return_val_if_fail (rc >= 0 && dn, -1); - dn = slapi_ch_strdup (dn); - slapi_dn_normalize_case (dn); - - /* Send off to components */ - autoserial_post_delete (dn); - - slapi_ch_free_string (&dn); - return 0; -} - -static int -post_modrdn (Slapi_PBlock *pb) -{ - char *rdn, *odn, *ndn; - int rc, code; - - return_val_if_fail (pb, -1); - - /* Make sure it was successful, don't process errors */ - rc = slapi_pblock_get (pb, SLAPI_RESULT_CODE, &code); - return_val_if_fail (rc >= 0, -1); - if (code != LDAP_SUCCESS) - return 0; - - /* Get out the DN and normalize it */ - rc = slapi_pblock_get (pb, SLAPI_MODRDN_TARGET, &odn); - return_val_if_fail (rc >= 0 && odn, -1); - odn = slapi_ch_strdup (odn); - slapi_dn_normalize_case (odn); - - /* Get out the changed DN and calculate it */ - rc = slapi_pblock_get(pb, SLAPI_MODRDN_NEWRDN, &rdn); - return_val_if_fail (rc >= 0 && rdn, -1); - ndn = dn_build_normalize (odn, rdn); - return_val_if_fail (ndn, -1); - - /* Send off to components */ - autoserial_post_modrdn (odn, ndn); - - slapi_ch_free_string (&odn); - slapi_ch_free_string (&ndn); - return 0; -} - -static int -post_modify (Slapi_PBlock *pb) +pre_modify (Slapi_PBlock *pb) { LDAPMod **mods; char *dn; @@ -253,12 +192,6 @@ post_modify (Slapi_PBlock *pb) return_val_if_fail (pb, -1); - /* Make sure it was successful, don't process errors */ - rc = slapi_pblock_get (pb, SLAPI_RESULT_CODE, &code); - return_val_if_fail (rc >= 0, -1); - if (code != LDAP_SUCCESS) - return 0; - /* Get out the DN and normalize it */ rc = slapi_pblock_get (pb, SLAPI_MODIFY_TARGET, &dn); return_val_if_fail (rc >= 0 && dn, -1); @@ -269,15 +202,14 @@ post_modify (Slapi_PBlock *pb) return_val_if_fail (rc >= 0 && mods, -1); /* Send off to components */ - autoserial_post_modify (dn, mods); - dnsnotify_post_modify (dn, mods); + rc = serial_pre_modify (dn, mods); slapi_ch_free_string (&dn); - return 0; + return rc; } static int -post_add (Slapi_PBlock *pb) +pre_add (Slapi_PBlock *pb) { char *dn; int rc, code; @@ -297,25 +229,23 @@ post_add (Slapi_PBlock *pb) slapi_dn_normalize_case (dn); /* Send off to components */ - autoserial_post_add (dn); - dnsnotify_post_add (dn); + rc = serial_post_add (dn); slapi_ch_free_string (&dn); - return 0; + return rc; } static Slapi_PluginDesc plugin_description = { PLUGIN_NAME, /* plug-in identifier */ "stef@memberwebs.com", /* vendor name */ VERSION, /* plug-in revision number */ - "Notify's DNS slaves when SOA change is made" /* plug-in description */ + "Limit attr values to those that have a suffix which equals parent's attribute" }; static int plugin_destroy (Slapi_PBlock *pb) { - autoserial_destroy (); - dnsnotify_destroy (); + suffix_destroy (); slapi_ch_array_free (plugin_arguments); plugin_arguments = NULL; @@ -357,8 +287,7 @@ plugin_init (Slapi_PBlock *pb) lowercase (arg); - rc = autoserial_config (arg, value); - rc |= dnsnotify_config (arg, value); + rc = suffix_config (arg, value); if (!rc) log_plugin ("unrecognized plugin argument: %s", argv[i]); @@ -367,6 +296,10 @@ plugin_init (Slapi_PBlock *pb) /* Null terminate */ plugin_arguments[i] = NULL; + /* Next we initialize all components */ + if (suffix_init () < 0) + return -1; + if (slapi_pblock_set (pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_03) != 0 || slapi_pblock_set (pb, SLAPI_PLUGIN_DESCRIPTION, &plugin_description) != 0 || slapi_pblock_set (pb, SLAPI_PLUGIN_DESTROY_FN, plugin_destroy)) { |