summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRich Megginson <rmeggins@redhat.com>2008-11-07 13:16:20 -0700
committerRob Crittenden <rcritten@redhat.com>2008-11-10 09:38:39 -0500
commit47863ac169e7ad96cd6bafb6730f5d5b03c2903a (patch)
tree2b11d98c1e4ac6f59f1c3c4d12927ca51fe5f538
parentc7c2cf0956ab11ce79adb0323dd34bfc8b3303ac (diff)
downloadfreeipa-47863ac169e7ad96cd6bafb6730f5d5b03c2903a.tar.gz
freeipa-47863ac169e7ad96cd6bafb6730f5d5b03c2903a.tar.xz
freeipa-47863ac169e7ad96cd6bafb6730f5d5b03c2903a.zip
Make DNA work with internal operations
-rw-r--r--ipa-server/ipa-slapi-plugins/dna/dna.c52
1 files changed, 49 insertions, 3 deletions
diff --git a/ipa-server/ipa-slapi-plugins/dna/dna.c b/ipa-server/ipa-slapi-plugins/dna/dna.c
index a092d1bc2..cb6a0629c 100644
--- a/ipa-server/ipa-slapi-plugins/dna/dna.c
+++ b/ipa-server/ipa-slapi-plugins/dna/dna.c
@@ -100,6 +100,9 @@
#define FEATURE_DESC "IPA Distributed Numeric Assignment"
#define PLUGIN_DESC "IPA Distributed Numeric Assignment plugin"
+#define PLUGIN_DESC_INT_PREOP PLUGIN_DESC " preop internal"
+#define PLUGIN_DESC_POSTOP PLUGIN_DESC " postop"
+#define PLUGIN_DESC_INT_POSTOP PLUGIN_DESC " postop internal"
static Slapi_PluginDesc pdesc = { FEATURE_DESC,
"FreeIPA project", "FreeIPA/1.0",
@@ -131,6 +134,8 @@ static PRRWLock *g_dna_cache_lock;
static void *_PluginID = NULL;
static char *_PluginDN = NULL;
+static int g_plugin_started = 0;
+
/*
* new value lock
@@ -145,6 +150,7 @@ static Slapi_Mutex *g_new_value_lock;
int ipa_dna_init(Slapi_PBlock * pb);
static int dna_start(Slapi_PBlock * pb);
static int dna_close(Slapi_PBlock * pb);
+static int dna_internal_preop_init(Slapi_PBlock *pb);
static int dna_postop_init(Slapi_PBlock * pb);
/**
@@ -265,7 +271,7 @@ int ipa_dna_init(Slapi_PBlock * pb)
* Store the plugin identity for later use.
* Used for internal operations
*/
-
+
slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &plugin_identity);
PR_ASSERT(plugin_identity);
setPluginID(plugin_identity);
@@ -282,12 +288,21 @@ int ipa_dna_init(Slapi_PBlock * pb)
(void *) dna_mod_pre_op) != 0 ||
slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_ADD_FN,
(void *) dna_add_pre_op) != 0 ||
+ /* internal preoperation */
+ slapi_register_plugin("internalpreoperation", /* op type */
+ 1, /* Enabled */
+ "dna_internal_preop_init", /* this function desc */
+ dna_internal_preop_init, /* init func */
+ PLUGIN_DESC_INT_PREOP, /* plugin desc */
+ NULL, /* ? */
+ plugin_identity /* access control */
+ ) ||
/* the config change checking post op */
slapi_register_plugin("postoperation", /* op type */
1, /* Enabled */
- "ipa_dna_init", /* this function desc */
+ "dna_postop_init", /* this function desc */
dna_postop_init, /* init func for post op */
- PLUGIN_DESC, /* plugin desc */
+ PLUGIN_DESC_POSTOP, /* plugin desc */
NULL, /* ? */
plugin_identity /* access control */
)
@@ -303,6 +318,26 @@ int ipa_dna_init(Slapi_PBlock * pb)
}
+static int
+dna_internal_preop_init(Slapi_PBlock *pb)
+{
+ int status = DNA_SUCCESS;
+
+ if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION,
+ SLAPI_PLUGIN_VERSION_01) != 0 ||
+ slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION,
+ (void *) &pdesc) != 0 ||
+ slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN,
+ (void *) dna_mod_pre_op) != 0 ||
+ slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_PRE_ADD_FN,
+ (void *) dna_add_pre_op) != 0) {
+ status = DNA_FAILURE;
+ }
+
+ return status;
+}
+
+
static int dna_postop_init(Slapi_PBlock * pb)
{
int status = DNA_SUCCESS;
@@ -340,6 +375,11 @@ static int dna_start(Slapi_PBlock * pb)
slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
"--> dna_start\n");
+ /* Check if we're already started */
+ if (g_plugin_started) {
+ goto done;
+ }
+
g_dna_cache_lock = PR_NewRWLock(PR_RWLOCK_RANK_NONE, "dna");
g_new_value_lock = slapi_new_mutex();
@@ -381,11 +421,13 @@ static int dna_start(Slapi_PBlock * pb)
return DNA_FAILURE;
}
+ g_plugin_started = 1;
slapi_log_error(SLAPI_LOG_PLUGIN, DNA_PLUGIN_SUBSYSTEM,
"dna: ready for service\n");
slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
"<-- dna_start\n");
+done:
return DNA_SUCCESS;
}
@@ -1152,6 +1194,10 @@ static int dna_pre_op(Slapi_PBlock * pb, int modtype)
slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
"--> dna_pre_op\n");
+ /* Just bail if we aren't ready to service requests yet. */
+ if (!g_plugin_started)
+ goto bail;
+
if (0 == (dn = dna_get_dn(pb)))
goto bail;