|
|
dc8c34 |
From 4cf64c10bc92fd7627f452cd6b991671015ba8fa Mon Sep 17 00:00:00 2001
|
|
|
dc8c34 |
From: Mark Reynolds <mreynolds@redhat.com>
|
|
|
dc8c34 |
Date: Fri, 19 Oct 2012 10:22:21 -0400
|
|
|
dc8c34 |
Subject: [PATCH 16/16] Ticket 495 - internalModifiersname not updated by DNA
|
|
|
dc8c34 |
plugin
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Bug Description: If you are using the "nsslapd-plugin-binddn-tracking", and the DNA plugin
|
|
|
dc8c34 |
modifiers the entry, the internalmodifiersname is not updated.
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Fix Description: This is because the DNA plugin directly modifies the entry, and does not
|
|
|
dc8c34 |
use the internal modify functions that would trigger the last mod attributes
|
|
|
dc8c34 |
to be updated. So we have to call the last mod update funtciont directly from
|
|
|
dc8c34 |
the dna plugin.
|
|
|
dc8c34 |
|
|
|
dc8c34 |
There is also a slight change to the behavior now. The internalModifiersname &
|
|
|
dc8c34 |
internalCreatorsname will never be the bind dn, but instead it will be the plugin
|
|
|
dc8c34 |
that actually did the update. So if a entry was not touched by a DS plugin, then
|
|
|
dc8c34 |
the "database" plugin would be the internal modifier/creator:
|
|
|
dc8c34 |
|
|
|
dc8c34 |
cn=ldbm database,cn=plugins,cn=config
|
|
|
dc8c34 |
|
|
|
dc8c34 |
This would also allow us to detect if someone replaced the default backend.
|
|
|
dc8c34 |
|
|
|
dc8c34 |
https://fedorahosted.org/389/ticket/495
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Reviewed by: nhosoi(Thanks!)
|
|
|
dc8c34 |
(cherry picked from commit fb8c9f305398f713154bc3d8dddeb89d3c9d386a)
|
|
|
dc8c34 |
---
|
|
|
dc8c34 |
ldap/servers/plugins/dna/dna.c | 4 +++
|
|
|
dc8c34 |
ldap/servers/slapd/add.c | 56 ++++++++++++++++++++++++++++++++++----
|
|
|
dc8c34 |
ldap/servers/slapd/opshared.c | 8 ++++--
|
|
|
dc8c34 |
ldap/servers/slapd/proto-slap.h | 1 -
|
|
|
dc8c34 |
ldap/servers/slapd/slapi-private.h | 10 +++++++
|
|
|
dc8c34 |
5 files changed, 71 insertions(+), 8 deletions(-)
|
|
|
dc8c34 |
|
|
|
dc8c34 |
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
|
|
|
dc8c34 |
index ef01735..66d4a05 100644
|
|
|
dc8c34 |
--- a/ldap/servers/plugins/dna/dna.c
|
|
|
dc8c34 |
+++ b/ldap/servers/plugins/dna/dna.c
|
|
|
dc8c34 |
@@ -2846,6 +2846,8 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e)
|
|
|
dc8c34 |
/* no need to dup */
|
|
|
dc8c34 |
DNA_NEEDS_UPDATE);
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
+ /* Update the internalModifiersname for this add op */
|
|
|
dc8c34 |
+ add_internal_modifiersname(pb, e);
|
|
|
dc8c34 |
|
|
|
dc8c34 |
/* Make sure we don't generate for this
|
|
|
dc8c34 |
* type again by keeping a list of types
|
|
|
dc8c34 |
@@ -3101,6 +3103,8 @@ _dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods)
|
|
|
dc8c34 |
/* no need to dup */
|
|
|
dc8c34 |
DNA_NEEDS_UPDATE);
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
+ /* Update the internalModifersname for this mod op */
|
|
|
dc8c34 |
+ modify_update_last_modified_attr(pb, smods);
|
|
|
dc8c34 |
|
|
|
dc8c34 |
/* Make sure we don't generate for this
|
|
|
dc8c34 |
* type again by keeping a list of types
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c
|
|
|
dc8c34 |
index 55deeee..3206d5b 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/add.c
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/add.c
|
|
|
dc8c34 |
@@ -73,7 +73,7 @@
|
|
|
dc8c34 |
/* Forward declarations */
|
|
|
dc8c34 |
static int add_internal_pb (Slapi_PBlock *pb);
|
|
|
dc8c34 |
static void op_shared_add (Slapi_PBlock *pb);
|
|
|
dc8c34 |
-static int add_created_attrs(Operation *op, Slapi_Entry *e);
|
|
|
dc8c34 |
+static int add_created_attrs(Slapi_PBlock *pb, Slapi_Entry *e);
|
|
|
dc8c34 |
static int check_rdn_for_created_attrs(Slapi_Entry *e);
|
|
|
dc8c34 |
static void handle_fast_add(Slapi_PBlock *pb, Slapi_Entry *entry);
|
|
|
dc8c34 |
static int add_uniqueid (Slapi_Entry *e);
|
|
|
dc8c34 |
@@ -631,7 +631,7 @@ static void op_shared_add (Slapi_PBlock *pb)
|
|
|
dc8c34 |
/* can get lastmod only after backend is selected */
|
|
|
dc8c34 |
slapi_pblock_get(pb, SLAPI_BE_LASTMOD, &lastmod);
|
|
|
dc8c34 |
|
|
|
dc8c34 |
- if (lastmod && add_created_attrs(operation, e) != 0)
|
|
|
dc8c34 |
+ if (lastmod && add_created_attrs(pb, e) != 0)
|
|
|
dc8c34 |
{
|
|
|
dc8c34 |
send_ldap_result(pb, LDAP_UNWILLING_TO_PERFORM, NULL,
|
|
|
dc8c34 |
"cannot insert computed attributes", 0, NULL);
|
|
|
dc8c34 |
@@ -745,20 +745,25 @@ done:
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
static int
|
|
|
dc8c34 |
-add_created_attrs(Operation *op, Slapi_Entry *e)
|
|
|
dc8c34 |
+add_created_attrs(Slapi_PBlock *pb, Slapi_Entry *e)
|
|
|
dc8c34 |
{
|
|
|
dc8c34 |
char buf[20];
|
|
|
dc8c34 |
char *binddn = NULL;
|
|
|
dc8c34 |
+ char *plugin_dn = NULL;
|
|
|
dc8c34 |
struct berval bv;
|
|
|
dc8c34 |
struct berval *bvals[2];
|
|
|
dc8c34 |
time_t curtime;
|
|
|
dc8c34 |
struct tm ltm;
|
|
|
dc8c34 |
+ Operation *op;
|
|
|
dc8c34 |
+ struct slapdplugin *plugin = NULL;
|
|
|
dc8c34 |
+ struct slapi_componentid *cid = NULL;
|
|
|
dc8c34 |
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
|
|
|
dc8c34 |
|
|
|
dc8c34 |
LDAPDebug(LDAP_DEBUG_TRACE, "add_created_attrs\n", 0, 0, 0);
|
|
|
dc8c34 |
|
|
|
dc8c34 |
bvals[0] = &bv;
|
|
|
dc8c34 |
bvals[1] = NULL;
|
|
|
dc8c34 |
+ slapi_pblock_get(pb, SLAPI_OPERATION, &op);
|
|
|
dc8c34 |
|
|
|
dc8c34 |
if(slapdFrontendConfig->plugin_track){
|
|
|
dc8c34 |
/* plugin bindDN tracking is enabled, grab the dn from thread local storage */
|
|
|
dc8c34 |
@@ -766,8 +771,21 @@ add_created_attrs(Operation *op, Slapi_Entry *e)
|
|
|
dc8c34 |
bv.bv_val = "";
|
|
|
dc8c34 |
bv.bv_len = strlen(bv.bv_val);
|
|
|
dc8c34 |
} else {
|
|
|
dc8c34 |
- bv.bv_val = (char*)slapi_sdn_get_dn(&op->o_sdn);
|
|
|
dc8c34 |
- bv.bv_len = strlen(bv.bv_val);
|
|
|
dc8c34 |
+ slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &cid;;
|
|
|
dc8c34 |
+ if (cid){
|
|
|
dc8c34 |
+ plugin=(struct slapdplugin *) cid->sci_plugin;
|
|
|
dc8c34 |
+ } else {
|
|
|
dc8c34 |
+ slapi_pblock_get (pb, SLAPI_PLUGIN, &plugin);
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ if(plugin)
|
|
|
dc8c34 |
+ plugin_dn = plugin_get_dn (plugin);
|
|
|
dc8c34 |
+ if(plugin_dn){
|
|
|
dc8c34 |
+ bv.bv_val = plugin_dn;
|
|
|
dc8c34 |
+ bv.bv_len = strlen(bv.bv_val);
|
|
|
dc8c34 |
+ } else {
|
|
|
dc8c34 |
+ bv.bv_val = (char*)slapi_sdn_get_dn(&op->o_sdn);
|
|
|
dc8c34 |
+ bv.bv_len = strlen(bv.bv_val);
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
slapi_entry_attr_replace(e, "internalCreatorsName", bvals);
|
|
|
dc8c34 |
slapi_entry_attr_replace(e, "internalModifiersName", bvals);
|
|
|
dc8c34 |
@@ -971,3 +989,31 @@ check_oc_subentry(Slapi_Entry *e, struct berval **vals, char *normtype) {
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
return subentry;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+/*
|
|
|
dc8c34 |
+ * Used by plugins that modify entries on add operations, otherwise the internalModifiersname
|
|
|
dc8c34 |
+ * would be incorrect.
|
|
|
dc8c34 |
+ */
|
|
|
dc8c34 |
+void
|
|
|
dc8c34 |
+add_internal_modifiersname(Slapi_PBlock *pb, Slapi_Entry *e)
|
|
|
dc8c34 |
+{
|
|
|
dc8c34 |
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
|
|
|
dc8c34 |
+ struct slapi_componentid *cid = NULL;
|
|
|
dc8c34 |
+ struct slapdplugin *plugin = NULL;
|
|
|
dc8c34 |
+ char *plugin_dn = NULL;
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ if(slapdFrontendConfig->plugin_track){
|
|
|
dc8c34 |
+ /* plugin bindDN tracking is enabled, grab the bind dn from thread local storage */
|
|
|
dc8c34 |
+ slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &cid;;
|
|
|
dc8c34 |
+ if (cid){
|
|
|
dc8c34 |
+ plugin=(struct slapdplugin *) cid->sci_plugin;
|
|
|
dc8c34 |
+ } else {
|
|
|
dc8c34 |
+ slapi_pblock_get (pb, SLAPI_PLUGIN, &plugin);
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ if(plugin)
|
|
|
dc8c34 |
+ plugin_dn = plugin_get_dn (plugin);
|
|
|
dc8c34 |
+ if(plugin_dn){
|
|
|
dc8c34 |
+ slapi_entry_attr_set_charptr(e, "internalModifiersname", plugin_dn);
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+}
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
|
|
|
dc8c34 |
index 2701250..485763e 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/opshared.c
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/opshared.c
|
|
|
dc8c34 |
@@ -133,7 +133,8 @@ do_ps_service(Slapi_Entry *e, Slapi_Entry *eprev, ber_int_t chgtype, ber_int_t c
|
|
|
dc8c34 |
(ps_service_fn)(e, eprev, chgtype, chgnum);
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
-void modify_update_last_modified_attr(Slapi_PBlock *pb, Slapi_Mods *smods)
|
|
|
dc8c34 |
+void
|
|
|
dc8c34 |
+modify_update_last_modified_attr(Slapi_PBlock *pb, Slapi_Mods *smods)
|
|
|
dc8c34 |
{
|
|
|
dc8c34 |
char buf[20];
|
|
|
dc8c34 |
char *plugin_dn = NULL;
|
|
|
dc8c34 |
@@ -160,8 +161,11 @@ void modify_update_last_modified_attr(Slapi_PBlock *pb, Slapi_Mods *smods)
|
|
|
dc8c34 |
bv.bv_len = strlen(bv.bv_val);
|
|
|
dc8c34 |
} else {
|
|
|
dc8c34 |
slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &cid;;
|
|
|
dc8c34 |
- if (cid)
|
|
|
dc8c34 |
+ if (cid){
|
|
|
dc8c34 |
plugin=(struct slapdplugin *) cid->sci_plugin;
|
|
|
dc8c34 |
+ } else {
|
|
|
dc8c34 |
+ slapi_pblock_get (pb, SLAPI_PLUGIN, &plugin);
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
if(plugin)
|
|
|
dc8c34 |
plugin_dn = plugin_get_dn (plugin);
|
|
|
dc8c34 |
if(plugin_dn){
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
|
|
|
dc8c34 |
index 7e438b7..2289efa 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/proto-slap.h
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/proto-slap.h
|
|
|
dc8c34 |
@@ -1284,7 +1284,6 @@ void set_config_params (Slapi_PBlock *pb);
|
|
|
dc8c34 |
/* set parameters common for all internal operations */
|
|
|
dc8c34 |
void set_common_params (Slapi_PBlock *pb);
|
|
|
dc8c34 |
void do_ps_service(Slapi_Entry *e, Slapi_Entry *eprev, ber_int_t chgtype, ber_int_t chgnum);
|
|
|
dc8c34 |
-void modify_update_last_modified_attr(Slapi_PBlock *pb, Slapi_Mods *smods);
|
|
|
dc8c34 |
|
|
|
dc8c34 |
/*
|
|
|
dc8c34 |
* debugdump.cpp
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
|
|
|
dc8c34 |
index f995e30..f7b4d04 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/slapi-private.h
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/slapi-private.h
|
|
|
dc8c34 |
@@ -1247,6 +1247,16 @@ int is_slapd_running();
|
|
|
dc8c34 |
/* attrsyntax.c */
|
|
|
dc8c34 |
int slapi_add_internal_attr_syntax( const char *name, const char *oid, const char *syntax, const char *mr_equality, unsigned long extraflags );
|
|
|
dc8c34 |
|
|
|
dc8c34 |
+/* pw.c */
|
|
|
dc8c34 |
+void pw_exp_init ( void );
|
|
|
dc8c34 |
+int pw_copy_entry_ext(Slapi_Entry *src_e, Slapi_Entry *dest_e);
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+/* op_shared.c */
|
|
|
dc8c34 |
+void modify_update_last_modified_attr(Slapi_PBlock *pb, Slapi_Mods *smods);
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+/* add.c */
|
|
|
dc8c34 |
+void add_internal_modifiersname(Slapi_PBlock *pb, Slapi_Entry *e);
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
#ifdef __cplusplus
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
#endif
|
|
|
dc8c34 |
--
|
|
|
dc8c34 |
1.7.11.7
|
|
|
dc8c34 |
|