ldap/servers/plugins/linkedattrs/fixup_task.c | 15 +++++++++++++++
ldap/servers/plugins/linkedattrs/linked_attrs.c | 5 +++++
ldap/servers/plugins/linkedattrs/linked_attrs.h | 5 +++++
ldap/servers/plugins/memberof/memberof.c | 9 +++++++++
ldap/servers/plugins/usn/usn.c | 9 +++++++++
ldap/servers/plugins/usn/usn.h | 1 +
ldap/servers/plugins/usn/usn_cleanup.c | 8 ++++++++
ldap/servers/slapd/plugin.c | 5 ++++-
ldap/servers/slapd/slap.h | 3 ++-
9 files changed, 58 insertions(+), 2 deletions(-)
New commits:
commit 81737b9eed4f62825e16f13d59e5dc5aa684315f
Author: Mark Reynolds <mareynol(a)redhat.com>
Date: Fri Jan 20 09:21:57 2012 -0500
Updated for ticket#50
diff --git a/ldap/servers/plugins/linkedattrs/fixup_task.c
b/ldap/servers/plugins/linkedattrs/fixup_task.c
index a698a6c..b1c29d3 100644
--- a/ldap/servers/plugins/linkedattrs/fixup_task.c
+++ b/ldap/servers/plugins/linkedattrs/fixup_task.c
@@ -77,6 +77,13 @@ linked_attrs_fixup_task_add(Slapi_PBlock *pb, Slapi_Entry *e,
goto out;
}
+ /* make sure the plugin is not closed */
+ if(!linked_attrs_is_started()){
+ *returncode = LDAP_OPERATIONS_ERROR;
+ rv = SLAPI_DSE_CALLBACK_ERROR;
+ goto out;
+ }
+
/* get arg(s) */
linkdn = fetch_attr(e, "linkdn", 0);
commit 4daa0a6cd4d0db8df34e7466fb3877549d69e7d1
Author: Mark Reynolds <mareynol(a)redhat.com>
Date: Thu Jan 19 13:53:01 2012 -0500
Ticket #50 - server should not call a plugin after the plugin close function is calle
Bug Description: Its possible that a plugin's pre/post op function can be called
as
the plugin is shutting down. It is also possible that a queued
plugin
task can be run after the plugin is shut down.
Fix description: Added a new flag to plugin struct to mark when the plugin is
closed.
This flag is checked when we attempt to call a plugin function. We
also
now check if the plugin is closed before issuing a plugin task.
The
plugin task change only affected 3 plugins: usn, likedatttrs, &
memberOf
https://fedorahosted.org/389/ticket/50
diff --git a/ldap/servers/plugins/linkedattrs/fixup_task.c
b/ldap/servers/plugins/linkedattrs/fixup_task.c
index ee64d71..a698a6c 100644
--- a/ldap/servers/plugins/linkedattrs/fixup_task.c
+++ b/ldap/servers/plugins/linkedattrs/fixup_task.c
@@ -69,6 +69,14 @@ linked_attrs_fixup_task_add(Slapi_PBlock *pb, Slapi_Entry *e,
const char *linkdn = NULL;
*returncode = LDAP_SUCCESS;
+
+ /* make sure the plugin is not closed */
+ if(!linked_attrs_is_started()){
+ *returncode = LDAP_OPERATIONS_ERROR;
+ rv = SLAPI_DSE_CALLBACK_ERROR;
+ goto out;
+ }
+
/* get arg(s) */
linkdn = fetch_attr(e, "linkdn", 0);
diff --git a/ldap/servers/plugins/linkedattrs/linked_attrs.c
b/ldap/servers/plugins/linkedattrs/linked_attrs.c
index 2b5127d..1a647bc 100644
--- a/ldap/servers/plugins/linkedattrs/linked_attrs.c
+++ b/ldap/servers/plugins/linkedattrs/linked_attrs.c
@@ -2135,3 +2135,8 @@ linked_attrs_dump_config_entry(struct configEntry * entry)
slapi_log_error(SLAPI_LOG_FATAL, LINK_PLUGIN_SUBSYSTEM,
"<---- scope ---------------> %s\n",
entry->scope);
}
+
+int
+linked_attrs_is_started(){
+ return g_plugin_started;
+}
diff --git a/ldap/servers/plugins/linkedattrs/linked_attrs.h
b/ldap/servers/plugins/linkedattrs/linked_attrs.h
index 879513d..137e317 100644
--- a/ldap/servers/plugins/linkedattrs/linked_attrs.h
+++ b/ldap/servers/plugins/linkedattrs/linked_attrs.h
@@ -138,3 +138,8 @@ int linked_attrs_fixup_task_add(Slapi_PBlock *pb, Slapi_Entry *e,
char *returntext, void *arg);
int g_get_shutdown(); /* declared in proto-slap.h */
+
+/*
+ * misc
+ */
+int linked_attrs_is_started();
diff --git a/ldap/servers/plugins/memberof/memberof.c
b/ldap/servers/plugins/memberof/memberof.c
index e7fcf22..19c3085 100644
--- a/ldap/servers/plugins/memberof/memberof.c
+++ b/ldap/servers/plugins/memberof/memberof.c
@@ -2295,6 +2295,15 @@ int memberof_task_add(Slapi_PBlock *pb, Slapi_Entry *e,
const char *dn = 0;
*returncode = LDAP_SUCCESS;
+
+ /* make sure the plugin was not stopped from a shutdown */
+ if (!g_plugin_started)
+ {
+ *returncode = LDAP_OPERATIONS_ERROR;
+ rv = SLAPI_DSE_CALLBACK_ERROR;
+ goto out;
+ }
+
/* get arg(s) */
if ((dn = fetch_attr(e, "basedn", 0)) == NULL)
{
diff --git a/ldap/servers/plugins/usn/usn.c b/ldap/servers/plugins/usn/usn.c
index f5579c9..dbae1d5 100644
--- a/ldap/servers/plugins/usn/usn.c
+++ b/ldap/servers/plugins/usn/usn.c
@@ -68,6 +68,7 @@ static int usn_get_attr(Slapi_PBlock *pb, const char* type, void
*value);
static int usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e,
Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg);
+int g_plugin_started = 0;
/*
* Register USN plugin
* Note: USN counter initialization is done in the backend (ldbm_usn_init).
@@ -237,6 +238,7 @@ usn_start(Slapi_PBlock *pb)
value = slapi_value_new_string("(objectclass=*) $ EXCLUDE entryusn");
rc = slapi_set_plugin_default_config("nsds5ReplicatedAttributeList",
value);
slapi_value_free(&value);
+ g_plugin_started = 1;
bail:
slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
"<-- usn_start (rc: %d)\n", rc);
@@ -252,6 +254,7 @@ usn_close(Slapi_PBlock *pb)
slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM, "-->
usn_close\n");
csngen_free(&_usn_csngen);
+ g_plugin_started = 0;
slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM, "<--
usn_close\n");
@@ -708,3 +711,9 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry*
entryAfter,
"<-- usn_rootdse_search\n");
return SLAPI_DSE_CALLBACK_OK;
}
+
+int
+usn_is_started()
+{
+ return g_plugin_started;
+}
diff --git a/ldap/servers/plugins/usn/usn.h b/ldap/servers/plugins/usn/usn.h
index 8e6c5c8..46bcd16 100644
--- a/ldap/servers/plugins/usn/usn.h
+++ b/ldap/servers/plugins/usn/usn.h
@@ -51,6 +51,7 @@
/* usn.c */
void usn_set_identity(void *identity);
void *usn_get_identity();
+int usn_is_started();
/* usn_cleanup.c */
int usn_cleanup_start(Slapi_PBlock *pb);
diff --git a/ldap/servers/plugins/usn/usn_cleanup.c
b/ldap/servers/plugins/usn/usn_cleanup.c
index 16e6a95..12a48e3 100644
--- a/ldap/servers/plugins/usn/usn_cleanup.c
+++ b/ldap/servers/plugins/usn/usn_cleanup.c
@@ -252,6 +252,14 @@ usn_cleanup_add(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry
*eAfter,
"--> usn_cleanup_add\n");
*returncode = LDAP_SUCCESS;
+
+ /* make sure plugin is not closed*/
+ if(!usn_is_started()){
+ *returncode = LDAP_OPERATIONS_ERROR;
+ rv = SLAPI_DSE_CALLBACK_ERROR;
+ goto bail;
+ }
+
cn = slapi_entry_attr_get_charptr(e, "cn");
if (NULL == cn) {
*returncode = LDAP_OBJECT_CLASS_VIOLATION;
diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c
index 8179352..50df502 100644
--- a/ldap/servers/slapd/plugin.c
+++ b/ldap/servers/slapd/plugin.c
@@ -1360,6 +1360,8 @@ plugin_dependency_closeall()
{
pblock_init(&pb);
plugin_call_one( global_plugin_shutdown_order[index].plugin, SLAPI_PLUGIN_CLOSE_FN,
&pb );
+ /* set plg_closed to 1 to prevent any further plugin pre/post op function calls */
+ global_plugin_shutdown_order[index].plugin->plg_closed = 1;
plugins_closed++;
}
@@ -1440,7 +1442,7 @@ plugin_call_func (struct slapdplugin *list, int operation,
Slapi_PBlock *pb, int
slapi_pblock_set (pb, SLAPI_PLUGIN, list);
set_db_default_result_handlers (pb); /* JCM: What's this do? Is it needed here? */
if (slapi_pblock_get (pb, operation, &func) == 0 && func != NULL &&
- plugin_invoke_plugin_pb (list, operation, pb))
+ plugin_invoke_plugin_pb (list, operation, pb) && list->plg_closed == 0)
{
char *n= list->plg_name;
LDAPDebug( LDAP_DEBUG_TRACE, "Calling plugin '%s' #%d type %d\n",
(n==NULL?"noname":n), count, operation );
@@ -2102,6 +2104,7 @@ plugin_setup(Slapi_Entry *plugin_entry, struct slapi_componentid
*group,
plugin = (struct slapdplugin *)slapi_ch_calloc(1, sizeof(struct slapdplugin));
plugin->plg_dn = slapi_ch_strdup(slapi_entry_get_dn_const(plugin_entry));
+ plugin->plg_closed = 0;
if (!(value = slapi_entry_attr_get_charptr(plugin_entry,
ATTR_PLUGIN_TYPE)))
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index c5d658d..86d954d 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -799,7 +799,8 @@ struct slapdplugin {
struct pluginconfig plg_conf; /* plugin configuration parameters */
IFP plg_cleanup; /* cleanup function */
IFP plg_start; /* start function */
- IFP plg_poststart; /* poststart function */
+ IFP plg_poststart; /* poststart function */
+ int plg_closed; /* mark plugin as closed */
/* NOTE: These LDIF2DB and DB2LDIF fn pointers are internal only for now.
I don't believe you can get these functions from a plug-in and