summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2009-07-28 23:01:11 +0000
committerStef Walter <stef@memberwebs.com>2009-07-28 23:01:11 +0000
commit07db95dcf0d3c065b79d805ab81ef2e9ed328dce (patch)
tree4292410014bbc47e0219d663804bec443df4d89a
parentb6afde4dc66db780c4bc832d8c66bf2c2df0c823 (diff)
Some skeleton bits for plugin code
git-svn-id: http://internal-svn-server/svn/network/slapi-suffix@1507 96c7dce7-e4ff-0310-afa0-05b99c2e9643
-rw-r--r--plugin/Makefile.am11
-rw-r--r--plugin/plugin.c93
-rw-r--r--plugin/plugin.h29
3 files changed, 32 insertions, 101 deletions
diff --git a/plugin/Makefile.am b/plugin/Makefile.am
new file mode 100644
index 0000000..8d07ee0
--- /dev/null
+++ b/plugin/Makefile.am
@@ -0,0 +1,11 @@
+
+INCLUDES = \
+ -I$(top_srcdir)
+
+lib_LTLIBRARIES = slapi-suffix.la
+
+slapi_suffix_la_SOURCES = \
+ plugin.c plugin.h
+
+slapi_suffix_la_LDFLAGS = -module -avoid-version \
+ -export-symbols-regex 'plugin_init'
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)) {
diff --git a/plugin/plugin.h b/plugin/plugin.h
index 400dc6f..cdd15ad 100644
--- a/plugin/plugin.h
+++ b/plugin/plugin.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, Stefan Walter
+ * Copyright (c) 2009, Stefan Walter
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -43,7 +43,7 @@
#include "include/slapi-plugin.h"
#endif
-#define PLUGIN_NAME "slapi-dnsnotify"
+#define PLUGIN_NAME "slapi-suffix"
/* ---------------------------------------------------------------------
* LOGGING
@@ -80,26 +80,13 @@ char* trim (char *data);
void lowercase (char *data);
/* ----------------------------------------------------------------------
- * AUTO SERIAL
+ * SUFFIX
*/
-int autoserial_init (void);
-void autoserial_destroy (void);
-int autoserial_config (const char *name, const char *value);
-void autoserial_post_add (const char *dn);
-void autoserial_post_modify (const char *dn, LDAPMod **mods);
-void autoserial_post_modrdn (const char *odn, const char *ndn);
-void autoserial_post_delete (const char *dn);
-
-/* ----------------------------------------------------------------------
- * DNS NOTIFY
- */
-
-int dnsnotify_init (void);
-void dnsnotify_destroy (void);
-int dnsnotify_config (const char *name, const char *value);
-void dnsnotify_post_add (const char *dn);
-void dnsnotify_post_modify (const char *dn, LDAPMod **mods);
-
+int suffix_init (void);
+void suffix_destroy (void);
+int suffix_config (const char *name, const char *value);
+void suffix_pre_add (const char *dn);
+void suffix_pre_modify (const char *dn, LDAPMod **mods);
#endif /*PLUGIN_H_*/