ldap/servers
by Richard Allen Megginson
ldap/servers/plugins/acl/aclparse.c | 5 +++++
1 file changed, 5 insertions(+)
New commits:
commit 8ba2982457e7d2143ae0c2af212412122592c284
Author: Charles Lopes <clopes(a)amazon.com>
Date: Tue May 8 15:37:59 2012 +0000
Bug #361: Bad DNs in ACIs can segfault ns-slapd
A bad userdn will make the DN normalization fail. This sets dn to NULL,
and the server will attempt to access the NULL dn.
The fix is to just return with an error if the normalization fails since
the DN is invalid.
Reviewed by: rmeggins
diff --git a/ldap/servers/plugins/acl/aclparse.c b/ldap/servers/plugins/acl/aclparse.c
index 15b373b..39d9f6c 100644
--- a/ldap/servers/plugins/acl/aclparse.c
+++ b/ldap/servers/plugins/acl/aclparse.c
@@ -566,6 +566,11 @@ __aclp__copy_normalized_str (char *src, char *endsrc, char *start,
/* Normalize the value of userdn and append it to ret_str */
slapi_sdn_init_dn_byref(&sdn, p);
dn = slapi_sdn_get_dn(&sdn);
+ /* Normalization failed so return an error (-1) */
+ if (!dn) {
+ slapi_sdn_done(&sdn);
+ return -1;
+ }
/* append up to ldap(s):/// */
aclutil_str_append_ext(dest, destlen, start, p - start);
/* append the DN part */
11 years, 11 months
ldap/servers
by Noriko Hosoi
ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
New commits:
commit 197a8f5c6a4def3915cd07d07602e3ed80b082b0
Author: Noriko Hosoi <nhosoi(a)totoro.usersys.redhat.com>
Date: Thu May 17 11:37:44 2012 -0700
Trac Ticket #338 - letters in object's cn get converted to
lowercase when renaming object
Fix description: In modrdn, if newrdn is different from the oldrdn
only by upper/lower cases, it was ignored in the entryrdn code.
This patch recognizes the change and updates the entryrdn index.
commit b1ed11117e02c0ae670f05f9850b20fd9334d567
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
index 5281f22..b548b29 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
@@ -542,7 +542,8 @@ entryrdn_rename_subtree(backend *be,
if (newsrdn && slapi_rdn_get_rdn(newsrdn)) {
/* if the new RDN value is identical to the old RDN,
* we don't have to do "rename" */
- if (strcmp(slapi_rdn_get_nrdn(newsrdn), slapi_rdn_get_nrdn(&oldsrdn))) {
+ /* Don't miss the case changes, too. */
+ if (strcmp(slapi_rdn_get_rdn(newsrdn), slapi_rdn_get_rdn(&oldsrdn))) {
/* did not match; let's rename it */
mynewsrdn = newsrdn;
}
11 years, 11 months
ldap/servers
by Mark Reynolds
ldap/servers/slapd/auditlog.c | 17 +++++++++++++++++
ldap/servers/slapd/libglobs.c | 19 +++++++++++++++++++
ldap/servers/slapd/proto-slap.h | 3 +++
ldap/servers/slapd/slap.h | 2 ++
4 files changed, 41 insertions(+)
New commits:
commit 43fb648fd4d7663c61c7ea7ff649ffddb9cbf006
Author: Mark Reynolds <mareynol(a)redhat.com>
Date: Wed May 16 17:53:27 2012 -0400
Ticket 365 - passwords in clear text in the audit log
Bug Description: after changing a user password, an additional modify is added to the
mods: "unhashed#user#password: <clear text password>"
e.g. PSEUDO_ATTR_UNHASHEDUSERPASSWORD
Fix Description: Added new config param "nsslapd-audit-logging-hide-unhashed-pw".
The default is "off". When "on" that single modify op is skipped from
the audit logging.
https://fedorahosted.org/389/ticket/365
Reviewed by: Noriko (Thanks!)
diff --git a/ldap/servers/slapd/auditlog.c b/ldap/servers/slapd/auditlog.c
index 79cd407..16c0f7e 100644
--- a/ldap/servers/slapd/auditlog.c
+++ b/ldap/servers/slapd/auditlog.c
@@ -55,6 +55,7 @@ char *attr_changetype = ATTR_CHANGETYPE;
char *attr_newrdn = ATTR_NEWRDN;
char *attr_deleteoldrdn = ATTR_DELETEOLDRDN;
char *attr_modifiersname = ATTR_MODIFIERSNAME;
+static int hide_unhashed_pw = 0;
/* Forward Declarations */
static void write_audit_file( int optype, const char *dn, void *change, int flag, time_t curtime );
@@ -152,6 +153,10 @@ write_audit_file(
for ( j = 0; mods[j] != NULL; j++ )
{
int operationtype= mods[j]->mod_op & ~LDAP_MOD_BVALUES;
+
+ if((strcmp(mods[j]->mod_type, PSEUDO_ATTR_UNHASHEDUSERPASSWORD) == 0) && hide_unhashed_pw){
+ continue;
+ }
switch ( operationtype )
{
case LDAP_MOD_ADD:
@@ -246,3 +251,15 @@ write_audit_file(
lenstr_free( &l );
}
+
+void
+auditlog_hide_unhashed_pw()
+{
+ hide_unhashed_pw = 1;
+}
+
+void
+auditlog_expose_unhashed_pw()
+{
+ hide_unhashed_pw = 0;
+}
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 6d0db36..2540e25 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -459,6 +459,9 @@ static struct config_get_and_set {
{CONFIG_AUDITLOG_LOGGING_ENABLED_ATTRIBUTE, NULL,
log_set_logging, SLAPD_AUDIT_LOG,
(void**)&global_slapdFrontendConfig.auditlog_logging_enabled, CONFIG_ON_OFF, NULL},
+ {CONFIG_AUDITLOG_LOGGING_HIDE_UNHASHED_PW, config_set_auditlog_unhashed_pw,
+ NULL, 0,
+ (void**)&global_slapdFrontendConfig.auditlog_logging_hide_unhashed_pw, CONFIG_ON_OFF, NULL},
{CONFIG_ACCESSLOG_BUFFERING_ATTRIBUTE, config_set_accesslogbuffering,
NULL, 0,
(void**)&global_slapdFrontendConfig.accesslogbuffering, CONFIG_ON_OFF, NULL},
@@ -1072,6 +1075,7 @@ FrontendConfig_init () {
cfg->auditlog_minfreespace = 5;
cfg->auditlog_exptime = 1;
cfg->auditlog_exptimeunit = slapi_ch_strdup("month");
+ cfg->auditlog_logging_hide_unhashed_pw = LDAP_OFF;
cfg->entryusn_global = LDAP_OFF;
cfg->entryusn_import_init = slapi_ch_strdup("0");
@@ -1171,6 +1175,21 @@ get_entry_point( int ep_name, caddr_t *ep_addr )
return rc;
}
+int
+config_set_auditlog_unhashed_pw(const char *attrname, char *value, char *errorbuf, int apply)
+{
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ int retVal = LDAP_SUCCESS;
+
+ retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->auditlog_logging_hide_unhashed_pw),
+ errorbuf, apply);
+ if(strcasecmp(value,"on") == 0){
+ auditlog_hide_unhashed_pw();
+ } else {
+ auditlog_expose_unhashed_pw();
+ }
+ return retVal;
+}
/*
* Utility function called by many of the config_set_XXX() functions.
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index ea6f610..c3ebd79 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -387,6 +387,7 @@ int config_set_disk_threshold( const char *attrname, char *value, char *errorbuf
int config_set_disk_grace_period( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_disk_preserve_logging( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_disk_logging_critical( const char *attrname, char *value, char *errorbuf, int apply );
+int config_set_auditlog_unhashed_pw(const char *attrname, char *value, char *errorbuf, int apply);
#if !defined(_WIN32) && !defined(AIX)
int config_set_maxdescriptors( const char *attrname, char *value, char *errorbuf, int apply );
@@ -1190,6 +1191,8 @@ void factory_destroy_extension(int type,void *object,void *parent,void **extensi
*/
void write_audit_log_entry( Slapi_PBlock *pb);
+void auditlog_hide_unhashed_pw();
+void auditlog_expose_unhashed_pw();
/*
* eventq.c
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 2e4db56..22237ce 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -1874,6 +1874,7 @@ typedef struct _slapdEntryPoints {
#define CONFIG_ACCESSLOG_LOGGING_ENABLED_ATTRIBUTE "nsslapd-accesslog-logging-enabled"
#define CONFIG_ERRORLOG_LOGGING_ENABLED_ATTRIBUTE "nsslapd-errorlog-logging-enabled"
#define CONFIG_AUDITLOG_LOGGING_ENABLED_ATTRIBUTE "nsslapd-auditlog-logging-enabled"
+#define CONFIG_AUDITLOG_LOGGING_HIDE_UNHASHED_PW "nsslapd-auditlog-logging-hide-unhashed-pw"
#define CONFIG_ROOTDN_ATTRIBUTE "nsslapd-rootdn"
#define CONFIG_ROOTPW_ATTRIBUTE "nsslapd-rootpw"
#define CONFIG_ROOTPWSTORAGESCHEME_ATTRIBUTE "nsslapd-rootpwstoragescheme"
@@ -2163,6 +2164,7 @@ typedef struct _slapdFrontendConfig {
int auditlog_minfreespace;
int auditlog_exptime;
char *auditlog_exptimeunit;
+ int auditlog_logging_hide_unhashed_pw;
int return_exact_case; /* Return attribute names with the same case
* as they appear in at.conf */
11 years, 11 months
2 commits - ldap/servers
by Mark Reynolds
ldap/servers/plugins/chainingdb/cb_instance.c | 192 ++--
ldap/servers/plugins/referint/referint.c | 903 ++++++++++-------------
ldap/servers/plugins/replication/repl5_plugins.c | 7
3 files changed, 527 insertions(+), 575 deletions(-)
New commits:
commit dc379838f8e4cfd2c736e8c2fb8366fb3b4f73d4
Author: Mark Reynolds <mareynol(a)redhat.com>
Date: Fri May 11 13:00:50 2012 -0400
Ticket 367 - Invalid chaining config triggers a disk full error and shutdown
Bug Description: If you use the root DN for the chaining bind DN a error -2 (LDAP_LOCAL_ERROR)
is returned from the callback. This is the same error code for SLAPI_FAIL_DISKFULL.
Once the error -2 is retuned, the server thinks we are out of disk space and the
instance is shutdown.
Fix Description: Return -1, instead of -2(LDAP_LOCAL_ERROR)
https://fedorahosted.org/389/ticket/367
Note: also did a little code cleanup with indentation
Reviewed by:
diff --git a/ldap/servers/plugins/chainingdb/cb_instance.c b/ldap/servers/plugins/chainingdb/cb_instance.c
index 9a33916..8fb694a 100644
--- a/ldap/servers/plugins/chainingdb/cb_instance.c
+++ b/ldap/servers/plugins/chainingdb/cb_instance.c
@@ -511,15 +511,15 @@ int cb_instance_modify_config_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor
*/
int
-cb_parse_instance_config_entry(cb_backend * cb, Slapi_Entry * e) {
-
- int rc =LDAP_SUCCESS;
- Slapi_Attr *attr = NULL;
- Slapi_Value *sval;
- const struct berval *attrValue;
- cb_backend_instance *inst=NULL;
- char *instname;
- char retmsg[CB_BUFSIZE];
+cb_parse_instance_config_entry(cb_backend * cb, Slapi_Entry * e)
+{
+ cb_backend_instance *inst = NULL;
+ Slapi_Attr *attr = NULL;
+ Slapi_Value *sval;
+ const struct berval *attrValue;
+ char *instname;
+ char retmsg[CB_BUFSIZE];
+ int rc = LDAP_SUCCESS;
CB_ASSERT(e!=NULL);
@@ -529,17 +529,17 @@ cb_parse_instance_config_entry(cb_backend * cb, Slapi_Entry * e) {
*/
if ( 0 == slapi_entry_attr_find( e, CB_CONFIG_INSTNAME, &attr )) {
- slapi_attr_first_value(attr, &sval);
- attrValue = slapi_value_get_berval(sval);
- instname=attrValue->bv_val;
+ slapi_attr_first_value(attr, &sval);
+ attrValue = slapi_value_get_berval(sval);
+ instname = attrValue->bv_val;
} else {
slapi_log_error( SLAPI_LOG_PLUGIN, CB_PLUGIN_SUBSYSTEM,
"Malformed backend instance (<%s> missing)>\n", CB_CONFIG_INSTNAME);
- return LDAP_LOCAL_ERROR;
+ return -1;
}
- /* Allocate a new backend internal data structure */
- inst = cb_instance_alloc(cb,instname,slapi_entry_get_dn(e));
+ /* Allocate a new backend internal data structure */
+ inst = cb_instance_alloc(cb,instname,slapi_entry_get_dn(e));
/* Emulate a add config entry to configure */
/* this backend instance. */
@@ -556,99 +556,96 @@ cb_parse_instance_config_entry(cb_backend * cb, Slapi_Entry * e) {
*/
static int
-cb_instance_config_initialize(cb_backend_instance * inst, Slapi_Entry * e , int phase, int apply) {
-
- int rc =LDAP_SUCCESS;
- Slapi_Attr *attr = NULL;
- Slapi_Value *sval;
- struct berval * bval;
- int using_def_connlifetime,i;
- char err_buf[SLAPI_DSE_RETURNTEXT_SIZE];
- int urlfound=0;
- char *rootdn;
+cb_instance_config_initialize(cb_backend_instance * inst, Slapi_Entry * e , int phase, int apply)
+{
+ Slapi_Attr *attr = NULL;
+ Slapi_Value *sval;
+ Slapi_DN *suffix;
+ struct berval *bval;
+ char err_buf[SLAPI_DSE_RETURNTEXT_SIZE];
+ char *attr_name = NULL;
+ char *rootdn;
+ int using_def_connlifetime, i;
+ int urlfound = 0;
+ int rc = LDAP_SUCCESS;
using_def_connlifetime=1;
- for (slapi_entry_first_attr(e, &attr); attr; slapi_entry_next_attr(e, attr, &attr)) {
- char * attr_name=NULL;
- slapi_attr_get_type(attr, &attr_name);
+ for (slapi_entry_first_attr(e, &attr); attr; slapi_entry_next_attr(e, attr, &attr)) {
+ attr_name = NULL;
+ slapi_attr_get_type(attr, &attr_name);
if ( !strcasecmp ( attr_name, CB_CONFIG_SUFFIX )) {
if (apply && ( inst->inst_be != NULL )) {
- Slapi_DN *suffix;
suffix = slapi_sdn_new();
- i = slapi_attr_first_value(attr, &sval);
- while (i != -1 ) {
- bval = (struct berval *) slapi_value_get_berval(sval);
- slapi_sdn_set_dn_byref(suffix, bval->bv_val);
-
- if (!slapi_be_issuffix(inst->inst_be, suffix)) {
- slapi_be_addsuffix(inst->inst_be, suffix);
- }
- i = slapi_attr_next_value(attr, i, &sval);
- }
+ i = slapi_attr_first_value(attr, &sval);
+ while (i != -1 ) {
+ bval = (struct berval *) slapi_value_get_berval(sval);
+ slapi_sdn_set_dn_byref(suffix, bval->bv_val);
+
+ if (!slapi_be_issuffix(inst->inst_be, suffix)) {
+ slapi_be_addsuffix(inst->inst_be, suffix);
+ }
+ i = slapi_attr_next_value(attr, i, &sval);
+ }
slapi_sdn_free(&suffix);
}
- continue;
- } else
- if ( !strcasecmp ( attr_name, CB_CONFIG_CHAINING_COMPONENTS )) {
-
- if (apply) {
- slapi_rwlock_wrlock(inst->rwl_config_lock);
- i = slapi_attr_first_value(attr, &sval);
+ continue;
+ } else if ( !strcasecmp ( attr_name, CB_CONFIG_CHAINING_COMPONENTS )) {
+ if (apply) {
+ slapi_rwlock_wrlock(inst->rwl_config_lock);
+ i = slapi_attr_first_value(attr, &sval);
charray_free(inst->chaining_components);
inst->chaining_components=NULL;
- while (i != -1 ) {
- bval = (struct berval *) slapi_value_get_berval(sval);
+ while (i != -1 ) {
+ bval = (struct berval *) slapi_value_get_berval(sval);
charray_add(&inst->chaining_components,
- slapi_dn_normalize(slapi_ch_strdup(bval->bv_val)));
- i = slapi_attr_next_value(attr, i, &sval);
- }
- slapi_rwlock_unlock(inst->rwl_config_lock);
- }
- continue;
- } else
- if ( !strcasecmp ( attr_name, CB_CONFIG_ILLEGAL_ATTRS )) {
-
- if (apply) {
- slapi_rwlock_wrlock(inst->rwl_config_lock);
- i = slapi_attr_first_value(attr, &sval);
+ slapi_dn_normalize(slapi_ch_strdup(bval->bv_val)));
+ i = slapi_attr_next_value(attr, i, &sval);
+ }
+ slapi_rwlock_unlock(inst->rwl_config_lock);
+ }
+ continue;
+ } else if ( !strcasecmp ( attr_name, CB_CONFIG_ILLEGAL_ATTRS )) {
+ if (apply) {
+ slapi_rwlock_wrlock(inst->rwl_config_lock);
+ i = slapi_attr_first_value(attr, &sval);
charray_free(inst->illegal_attributes);
inst->illegal_attributes=NULL;
- while (i != -1 ) {
- bval = (struct berval *) slapi_value_get_berval(sval);
+ while (i != -1 ) {
+ bval = (struct berval *) slapi_value_get_berval(sval);
charray_add(&inst->illegal_attributes,
- slapi_ch_strdup(bval->bv_val));
- i = slapi_attr_next_value(attr, i, &sval);
- }
- slapi_rwlock_unlock(inst->rwl_config_lock);
- }
- continue;
+ slapi_ch_strdup(bval->bv_val));
+ i = slapi_attr_next_value(attr, i, &sval);
+ }
+ slapi_rwlock_unlock(inst->rwl_config_lock);
+ }
+ continue;
}
if ( !strcasecmp ( attr_name, CB_CONFIG_HOSTURL )) {
urlfound=1;
}
-
- /* We are assuming that each of these attributes are to have
- * only one value. If they have more than one value, like
- * the nsslapd-suffix attribute, then they need to be
- * handled differently. */
+ /*
+ * We are assuming that each of these attributes are to have
+ * only one value. If they have more than one value, like
+ * the nsslapd-suffix attribute, then they need to be
+ * handled differently.
+ */
- slapi_attr_first_value(attr, &sval);
- bval = (struct berval *) slapi_value_get_berval(sval);
-
- if (cb_instance_config_set((void *) inst, attr_name,
+ slapi_attr_first_value(attr, &sval);
+ bval = (struct berval *) slapi_value_get_berval(sval);
+
+ if (cb_instance_config_set((void *) inst, attr_name,
cb_the_instance_config, bval, err_buf, phase, apply ) != LDAP_SUCCESS) {
- slapi_log_error( SLAPI_LOG_FATAL,
- CB_PLUGIN_SUBSYSTEM,"Error with config attribute %s : %s\n",
+ slapi_log_error( SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,"Error with config attribute %s : %s\n",
attr_name, err_buf);
- rc=LDAP_LOCAL_ERROR;
- break;
- }
- if ( !strcasecmp ( attr_name, CB_CONFIG_CONNLIFETIME )) {
+ rc = -1;
+ break;
+ }
+ if ( !strcasecmp ( attr_name, CB_CONFIG_CONNLIFETIME )) {
using_def_connlifetime=0;
}
}
@@ -661,20 +658,17 @@ cb_instance_config_initialize(cb_backend_instance * inst, Slapi_Entry * e , int
if (LDAP_SUCCESS == rc) {
if (!urlfound) {
- slapi_log_error( SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,
- "Malformed backend instance entry. Mandatory attr <%s> missing\n",
- CB_CONFIG_HOSTURL);
- rc= LDAP_LOCAL_ERROR;
+ slapi_log_error( SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,
+ "Malformed backend instance entry. Mandatory attr <%s> missing\n",CB_CONFIG_HOSTURL);
+ rc = -1;
}
if (apply ) {
- if ( using_def_connlifetime &&
- strchr( inst->pool->hostname, ' ' ) != NULL ) {
-
- cb_instance_config_set((void *)inst, CB_CONFIG_CONNLIFETIME,
- cb_the_instance_config, NULL /* use default */, err_buf,
+ if ( using_def_connlifetime && strchr( inst->pool->hostname, ' ' ) != NULL ) {
+ cb_instance_config_set((void *)inst, CB_CONFIG_CONNLIFETIME,
+ cb_the_instance_config, NULL /* use default */, err_buf,
CB_CONFIG_PHASE_INITIALIZATION, 1 );
- }
+ }
}
}
@@ -683,15 +677,13 @@ cb_instance_config_initialize(cb_backend_instance * inst, Slapi_Entry * e , int
** It is forbidden to use directory manager as proxy user
** due to a bug in the acl check
*/
-
- rootdn=cb_get_rootdn();
+ rootdn = cb_get_rootdn();
if (inst->impersonate && inst->pool && inst->pool->binddn &&
!strcmp(inst->pool->binddn,rootdn)) { /* UTF8 aware */
- slapi_log_error( SLAPI_LOG_FATAL,
- CB_PLUGIN_SUBSYSTEM,"Error with config attribute %s (%s: forbidden value)\n",
- CB_CONFIG_BINDUSER, rootdn);
- rc=LDAP_LOCAL_ERROR;
+ slapi_log_error( SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,
+ "Error with config attribute %s (%s: forbidden value)\n", CB_CONFIG_BINDUSER, rootdn);
+ rc= -1;
}
slapi_ch_free((void **)&rootdn);
@@ -1494,7 +1486,7 @@ struct berval *bval, char *err_buf, int phase, int apply_mod)
int use_default;
int int_val;
long long_val;
- int retval=LDAP_LOCAL_ERROR;
+ int retval = -1;
config = cb_get_config_info(config_array, attr_name);
if (NULL == config) {
commit 162f41da35a88cfe5f8b49d8f182eb33c27be579
Author: Mark Reynolds <mareynol(a)redhat.com>
Date: Thu May 10 14:30:44 2012 -0400
Ticket #218 - Make RI Plugin worked with replicated updates
Bug Description: If a user is deleted from AD (or a master not using RI Plugin),
the operation comes in as a replicated op, and RI aborts its
processing.
Fix Description: Added a new config attribute to the plugin "nsslapd-pluginAllowReplUpdates: on".
We check for this setting at startup and set a flag. We then allow these
operations, and we also attach OP_FLAG_REPLICATED flag to pblock for
slapi_modify_internal().
Side note: Cleaned up all the indentation/comments in referint.c
https://fedorahosted.org/389/ticket/218
reviewed by:
diff --git a/ldap/servers/plugins/referint/referint.c b/ldap/servers/plugins/referint/referint.c
index e8d4ead..266a7d1 100644
--- a/ldap/servers/plugins/referint/referint.c
+++ b/ldap/servers/plugins/referint/referint.c
@@ -58,15 +58,13 @@
#include <sys/stat.h>
#endif
-#define REFERINT_PLUGIN_SUBSYSTEM "referint-plugin" /* used for logging */
-
#ifdef _WIN32
#define REFERINT_DEFAULT_FILE_MODE 0
#else
#define REFERINT_DEFAULT_FILE_MODE S_IRUSR | S_IWUSR
#endif
-
+#define REFERINT_PLUGIN_SUBSYSTEM "referint-plugin" /* used for logging */
#define MAX_LINE 2048
#define READ_BUFSIZE 4096
#define MY_EOF 0
@@ -78,23 +76,21 @@ int referint_postop_modrdn( Slapi_PBlock *pb );
int referint_postop_start( Slapi_PBlock *pb);
int referint_postop_close( Slapi_PBlock *pb);
int update_integrity(char **argv, Slapi_DN *sDN, char *newrDN, Slapi_DN *newsuperior, int logChanges);
-void referint_thread_func(void *arg);
-int GetNextLine(char *dest, int size_dest, PRFileDesc *stream);
-void writeintegritylog(Slapi_PBlock *pb, char *logfilename, Slapi_DN *sdn, char *newrdn, Slapi_DN *newsuperior, Slapi_DN *requestorsdn);
+int GetNextLine(char *dest, int size_dest, PRFileDesc *stream);
int my_fgetc(PRFileDesc *stream);
+void referint_thread_func(void *arg);
+void writeintegritylog(Slapi_PBlock *pb, char *logfilename, Slapi_DN *sdn, char *newrdn,
+ Slapi_DN *newsuperior, Slapi_DN *requestorsdn);
/* global thread control stuff */
-
static PRLock *referint_mutex = NULL;
static PRThread *referint_tid = NULL;
+static PRLock *keeprunning_mutex = NULL;
+static PRCondVar *keeprunning_cv = NULL;
int keeprunning = 0;
-static PRLock *keeprunning_mutex = NULL;
-static PRCondVar *keeprunning_cv = NULL;
-
-static Slapi_PluginDesc pdesc = { "referint", VENDOR, DS_PACKAGE_VERSION,
- "referential integrity plugin" };
-
+static Slapi_PluginDesc pdesc = { "referint", VENDOR, DS_PACKAGE_VERSION, "referential integrity plugin" };
+static int allow_repl = 0;
static void* referint_plugin_identity = NULL;
#ifdef _WIN32
@@ -109,221 +105,213 @@ void plugin_init_debug_level(int *level_ptr)
int
referint_postop_init( Slapi_PBlock *pb )
{
- Slapi_Entry *plugin_entry = NULL;
- char *plugin_type = NULL;
- int delfn = SLAPI_PLUGIN_POST_DELETE_FN;
- int mdnfn = SLAPI_PLUGIN_POST_MODRDN_FN;
-
- /*
- * Get plugin identity and stored it for later use
- * Used for internal operations
- */
-
- slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &referint_plugin_identity);
- PR_ASSERT (referint_plugin_identity);
-
- /* get args */
- if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &plugin_entry) == 0) &&
- plugin_entry &&
- (plugin_type = slapi_entry_attr_get_charptr(plugin_entry, "nsslapd-plugintype")) &&
- plugin_type && strstr(plugin_type, "betxn")) {
- delfn = SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN;
- mdnfn = SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN;
- }
- slapi_ch_free_string(&plugin_type);
-
- 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, delfn,
- (void *) referint_postop_del ) != 0 ||
- slapi_pblock_set( pb, mdnfn,
- (void *) referint_postop_modrdn ) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_START_FN,
- (void *) referint_postop_start ) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_CLOSE_FN,
- (void *) referint_postop_close ) != 0)
- {
- slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
- "referint_postop_init failed\n" );
- return( -1 );
+ Slapi_Entry *plugin_entry = NULL;
+ char *plugin_type = NULL;
+ int delfn = SLAPI_PLUGIN_POST_DELETE_FN;
+ int mdnfn = SLAPI_PLUGIN_POST_MODRDN_FN;
+
+ /*
+ * Get plugin identity and stored it for later use.
+ * Used for internal operations.
+ */
+ slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &referint_plugin_identity);
+ PR_ASSERT (referint_plugin_identity);
+
+ /* get the args */
+ if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &plugin_entry) == 0) &&
+ plugin_entry &&
+ (plugin_type = slapi_entry_attr_get_charptr(plugin_entry, "nsslapd-plugintype")) &&
+ plugin_type && strstr(plugin_type, "betxn"))
+ {
+ delfn = SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN;
+ mdnfn = SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN;
+ }
+ if(plugin_entry){
+ char *allow_repl_updates;
+
+ allow_repl_updates = slapi_entry_attr_get_charptr(plugin_entry, "nsslapd-pluginAllowReplUpdates");
+ if(allow_repl_updates && strcasecmp(allow_repl_updates,"on")==0){
+ allow_repl = 1;
}
+ slapi_ch_free_string(&allow_repl_updates);
+ }
+ slapi_ch_free_string(&plugin_type);
+
+ 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, delfn, (void *) referint_postop_del ) != 0 ||
+ slapi_pblock_set( pb, mdnfn, (void *) referint_postop_modrdn ) != 0 ||
+ slapi_pblock_set( pb, SLAPI_PLUGIN_START_FN, (void *) referint_postop_start ) != 0 ||
+ slapi_pblock_set( pb, SLAPI_PLUGIN_CLOSE_FN, (void *) referint_postop_close ) != 0)
+ {
+ slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM, "referint_postop_init failed\n" );
+ return( -1 );
+ }
- return( 0 );
+ return( 0 );
}
int
referint_postop_del( Slapi_PBlock *pb )
{
- Slapi_DN *sdn = NULL;
- int rc;
- int oprc;
- char **argv;
- int argc;
- int delay;
- int logChanges=0;
- int isrepop = 0;
-
- if ( slapi_pblock_get( pb, SLAPI_IS_REPLICATED_OPERATION, &isrepop ) != 0 ||
- slapi_pblock_get( pb, SLAPI_DELETE_TARGET_SDN, &sdn ) != 0 ||
- slapi_pblock_get(pb, SLAPI_PLUGIN_OPRETURN, &oprc) != 0)
- {
- slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
- "referint_postop_del: could not get parameters\n" );
- return( -1 );
- }
+ Slapi_DN *sdn = NULL;
+ char **argv;
+ int argc;
+ int delay;
+ int logChanges=0;
+ int isrepop = 0;
+ int oprc;
+ int rc;
- /* this plugin should only execute if the delete was successful
- and this is not a replicated op
- */
- if(oprc != 0 || isrepop)
- {
- return( 0 );
- }
- /* get args */
- if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGC, &argc ) != 0) {
- slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
- "referint_postop failed to get argc\n" );
- return( -1 );
- }
- if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGV, &argv ) != 0) {
- slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
- "referint_postop failed to get argv\n" );
- return( -1 );
- }
+ if ( slapi_pblock_get( pb, SLAPI_IS_REPLICATED_OPERATION, &isrepop ) != 0 ||
+ slapi_pblock_get( pb, SLAPI_DELETE_TARGET_SDN, &sdn ) != 0 ||
+ slapi_pblock_get(pb, SLAPI_PLUGIN_OPRETURN, &oprc) != 0)
+ {
+ slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
+ "referint_postop_del: could not get parameters\n" );
+ return( -1 );
+ }
+ /*
+ * This plugin should only execute if the delete was successful
+ * and this is not a replicated op(unless its allowed)
+ */
+ if(oprc != 0 || (isrepop && !allow_repl)){
+ return( 0 );
+ }
+ /* get the args */
+ if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGC, &argc ) != 0) {
+ slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
+ "referint_postop failed to get argc\n" );
+ return( -1 );
+ }
+ if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGV, &argv ) != 0) {
+ slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
+ "referint_postop failed to get argv\n" );
+ return( -1 );
+ }
- if(argv == NULL){
- slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
- "referint_postop_modrdn, args are NULL\n" );
- return( -1 );
- }
+ if(argv == NULL){
+ slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
+ "referint_postop_modrdn, args are NULL\n" );
+ return( -1 );
+ }
- if (argc >= 3) {
- /* argv[0] will be the delay */
- delay = atoi(argv[0]);
-
- /* argv[2] will be wether or not to log changes */
- logChanges = atoi(argv[2]);
-
- if(delay == -1){
- /* integrity updating is off */
- rc = 0;
- }else if(delay == 0){
- /* no delay */
- /* call function to update references to entry */
- rc = update_integrity(argv, sdn, NULL, NULL, logChanges);
- }else{
- /* write the entry to integrity log */
- writeintegritylog(pb, argv[1], sdn, NULL, NULL, NULL /* slapi_get_requestor_sdn(pb) */);
- rc = 0;
- }
- } else {
- slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
- "referint_postop insufficient arguments supplied\n" );
- return( -1 );
- }
-
- return( rc );
+ if (argc >= 3) {
+ /* argv[0] will be the delay */
+ delay = atoi(argv[0]);
+
+ /* argv[2] will be wether or not to log changes */
+ logChanges = atoi(argv[2]);
+
+ if(delay == -1){
+ /* integrity updating is off */
+ rc = 0;
+ } else if(delay == 0){ /* no delay */
+ /* call function to update references to entry */
+ rc = update_integrity(argv, sdn, NULL, NULL, logChanges);
+ } else {
+ /* write the entry to integrity log */
+ writeintegritylog(pb, argv[1], sdn, NULL, NULL, NULL /* slapi_get_requestor_sdn(pb) */);
+ rc = 0;
+ }
+ } else {
+ slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
+ "referint_postop insufficient arguments supplied\n" );
+ return( -1 );
+ }
+ return( rc );
}
int
referint_postop_modrdn( Slapi_PBlock *pb )
{
- Slapi_DN *sdn = NULL;
- char *newrdn;
- Slapi_DN *newsuperior;
- int oprc;
- int rc;
- char **argv;
- int argc = 0;
- int delay;
- int logChanges=0;
- int isrepop = 0;
-
- if ( slapi_pblock_get( pb, SLAPI_IS_REPLICATED_OPERATION, &isrepop ) != 0 ||
- slapi_pblock_get( pb, SLAPI_MODRDN_TARGET_SDN, &sdn ) != 0 ||
- slapi_pblock_get( pb, SLAPI_MODRDN_NEWRDN, &newrdn ) != 0 ||
- slapi_pblock_get( pb, SLAPI_MODRDN_NEWSUPERIOR_SDN, &newsuperior ) != 0 ||
- slapi_pblock_get(pb, SLAPI_PLUGIN_OPRETURN, &oprc) != 0 ){
-
- slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
- "referint_postop_modrdn: could not get parameters\n" );
- return( -1 );
- }
-
- /* this plugin should only execute if the delete was successful
- and this is not a replicated op
- */
- if(oprc != 0 || isrepop){
- return( 0 );
- }
- /* get args */
- if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGC, &argc ) != 0) {
- slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
- "referint_postop failed to get argv\n" );
- return( -1 );
- }
- if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGV, &argv ) != 0) {
- slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
- "referint_postop failed to get argv\n" );
- return( -1 );
- }
-
- if(argv == NULL){
- slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
- "referint_postop_modrdn, args are NULL\n" );
- return( -1 );
- }
-
- if (argc >= 3) {
- /* argv[0] will always be the delay */
- delay = atoi(argv[0]);
-
- /* argv[2] will be wether or not to log changes */
- logChanges = atoi(argv[2]);
- } else {
- slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
- "referint_postop_modrdn insufficient arguments supplied\n" );
- return( -1 );
- }
-
- if(delay == -1){
- /* integrity updating is off */
- rc = 0;
- }else if(delay == 0){
- /* no delay */
- /* call function to update references to entry */
- rc = update_integrity(argv, sdn, newrdn, newsuperior, logChanges);
- }else{
- /* write the entry to integrity log */
- writeintegritylog(pb, argv[1], sdn, newrdn, newsuperior, NULL /* slapi_get_requestor_sdn(pb) */);
- rc = 0;
- }
-
- return( rc );
+ Slapi_DN *sdn = NULL;
+ Slapi_DN *newsuperior;
+ char *newrdn;
+ char **argv;
+ int oprc;
+ int rc;
+ int argc = 0;
+ int delay;
+ int logChanges=0;
+ int isrepop = 0;
+
+ if ( slapi_pblock_get( pb, SLAPI_IS_REPLICATED_OPERATION, &isrepop ) != 0 ||
+ slapi_pblock_get( pb, SLAPI_MODRDN_TARGET_SDN, &sdn ) != 0 ||
+ slapi_pblock_get( pb, SLAPI_MODRDN_NEWRDN, &newrdn ) != 0 ||
+ slapi_pblock_get( pb, SLAPI_MODRDN_NEWSUPERIOR_SDN, &newsuperior ) != 0 ||
+ slapi_pblock_get( pb, SLAPI_PLUGIN_OPRETURN, &oprc) != 0 )
+ {
+ slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
+ "referint_postop_modrdn: could not get parameters\n" );
+ return( -1 );
+ }
+ /*
+ * This plugin should only execute if the delete was successful
+ * and this is not a replicated op (unless its allowed)
+ */
+ if(oprc != 0 || (isrepop && !allow_repl)){
+ return( 0 );
+ }
+ /* get the args */
+ if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGC, &argc ) != 0) {
+ slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
+ "referint_postop failed to get argv\n" );
+ return( -1 );
+ }
+ if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGV, &argv ) != 0) {
+ slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
+ "referint_postop failed to get argv\n" );
+ return( -1 );
+ }
+ if(argv == NULL){
+ slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
+ "referint_postop_modrdn, args are NULL\n" );
+ return( -1 );
+ }
+
+ if (argc >= 3) {
+ /* argv[0] will always be the delay */
+ delay = atoi(argv[0]);
+
+ /* argv[2] will be wether or not to log changes */
+ logChanges = atoi(argv[2]);
+ } else {
+ slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
+ "referint_postop_modrdn insufficient arguments supplied\n" );
+ return( -1 );
+ }
+
+ if(delay == -1){
+ /* integrity updating is off */
+ rc = 0;
+ } else if(delay == 0){ /* no delay */
+ /* call function to update references to entry */
+ rc = update_integrity(argv, sdn, newrdn, newsuperior, logChanges);
+ } else {
+ /* write the entry to integrity log */
+ writeintegritylog(pb, argv[1], sdn, newrdn, newsuperior, NULL /* slapi_get_requestor_sdn(pb) */);
+ rc = 0;
+ }
+
+ return( rc );
}
int isFatalSearchError(int search_result)
{
-
/* Make sure search result is fatal
* Some conditions that happen quite often are not fatal
* for example if you have two suffixes and one is null, you will always
- * get no such object, howerever this is not a fatal error.
+ * get no such object, however this is not a fatal error.
* Add other conditions to the if statement as they are found
*/
-
- /* NPCTE fix for bugid 531225, esc 0. <P.R> <30-May-2001> */
- switch(search_result) {
- case LDAP_REFERRAL:
- case LDAP_NO_SUCH_OBJECT: return 0 ;
- }
- return 1;
- /* end of NPCTE fix for bugid 531225 */
-
+ switch(search_result) {
+ case LDAP_REFERRAL:
+ case LDAP_NO_SUCH_OBJECT: return 0 ;
+ }
+ return 1;
}
static int
@@ -333,9 +321,14 @@ _do_modify(Slapi_PBlock *mod_pb, Slapi_DN *entrySDN, LDAPMod **mods)
slapi_pblock_init(mod_pb);
- /* Use internal operation API */
- slapi_modify_internal_set_pb_ext(mod_pb, entrySDN, mods, NULL, NULL,
- referint_plugin_identity, 0);
+ if(allow_repl){
+ /* Must set as a replicated operation */
+ slapi_modify_internal_set_pb_ext(mod_pb, entrySDN, mods, NULL, NULL,
+ referint_plugin_identity, OP_FLAG_REPLICATED);
+ } else {
+ slapi_modify_internal_set_pb_ext(mod_pb, entrySDN, mods, NULL, NULL,
+ referint_plugin_identity, 0);
+ }
slapi_modify_internal_pb(mod_pb);
slapi_pblock_get(mod_pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
@@ -354,6 +347,7 @@ _update_one_per_mod(Slapi_DN *entrySDN, /* DN of the searched entry */
const char *newsuperior, /* new superior from modrdn */
Slapi_PBlock *mod_pb)
{
+ LDAPMod attribute1, attribute2;
LDAPMod *list_of_mods[3];
char *values_del[2];
char *values_add[2];
@@ -361,7 +355,8 @@ _update_one_per_mod(Slapi_DN *entrySDN, /* DN of the searched entry */
char **dnParts = NULL;
char *sval = NULL;
char *newvalue = NULL;
- LDAPMod attribute1, attribute2;
+ char *p = NULL;
+ size_t dnlen = 0;
int rc = 0;
if (NULL == newRDN && NULL == newsuperior) {
@@ -431,11 +426,11 @@ _update_one_per_mod(Slapi_DN *entrySDN, /* DN of the searched entry */
* member: uid=A,ou=B,ou=C --> uid=A,ou=B',ou=C
* (sval) (sval' + newDN)
*/
- for (nval = slapi_attr_first_value(attr, &v);
- nval != -1;
+ for (nval = slapi_attr_first_value(attr, &v); nval != -1;
nval = slapi_attr_next_value(attr, nval, &v)) {
- char *p = NULL;
- size_t dnlen = 0;
+ p = NULL;
+ dnlen = 0;
+
/* DN syntax, which should be a string */
sval = slapi_ch_strdup(slapi_value_get_string(v));
rc = slapi_dn_normalize_case_ext(sval, 0, &p, &dnlen);
@@ -536,6 +531,8 @@ _update_all_per_mod(Slapi_DN *entrySDN, /* DN of the searched entry */
char **dnParts = NULL;
char *sval = NULL;
char *newvalue = NULL;
+ char *p = NULL;
+ size_t dnlen = 0;
int rc = 0;
int nval = 0;
@@ -619,8 +616,9 @@ _update_all_per_mod(Slapi_DN *entrySDN, /* DN of the searched entry */
for (nval = slapi_attr_first_value(attr, &v);
nval != -1;
nval = slapi_attr_next_value(attr, nval, &v)) {
- char *p = NULL;
- size_t dnlen = 0;
+ p = NULL;
+ dnlen = 0;
+
/* DN syntax, which should be a string */
sval = slapi_ch_strdup(slapi_value_get_string(v));
rc = slapi_dn_normalize_case_ext(sval, 0, &p, &dnlen);
@@ -665,6 +663,7 @@ _update_all_per_mod(Slapi_DN *entrySDN, /* DN of the searched entry */
slapi_ch_free_string(&newDN);
slapi_mods_free(&smods);
}
+
bail:
return rc;
}
@@ -677,25 +676,30 @@ update_integrity(char **argv, Slapi_DN *origSDN,
Slapi_PBlock *search_result_pb = NULL;
Slapi_PBlock *mod_pb = slapi_pblock_new();
Slapi_Entry **search_entries = NULL;
- int search_result;
Slapi_DN *sdn = NULL;
+ Slapi_Attr *attr = NULL;
void *node = NULL;
+ const char *origDN = slapi_sdn_get_dn(origSDN);
+ const char *search_base = NULL;
+ char *attrName = NULL;
char *filter = NULL;
+ char *attrs[2];
+ size_t len = slapi_sdn_get_ndn_len(origSDN);
+ int search_result;
+ int nval = 0;
int i, j;
- const char *search_base = NULL;
int rc;
- size_t len = slapi_sdn_get_ndn_len(origSDN);
- const char *origDN = slapi_sdn_get_dn(origSDN);
-
- if ( argv == NULL ) {
+
+ if ( argv == NULL ){
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
"referint_postop required config file arguments missing\n" );
rc = -1;
goto free_and_return;
}
-
- /* for now, just putting attributes to keep integrity on in conf file,
- until resolve the other timing mode issue */
+ /*
+ * For now, just putting attributes to keep integrity on in conf file,
+ * until resolve the other timing mode issue
+ */
search_result_pb = slapi_pblock_new();
/* Search each namingContext in turn */
@@ -704,14 +708,12 @@ update_integrity(char **argv, Slapi_DN *origSDN,
{
search_base = slapi_sdn_get_dn( sdn );
- for(i = 3; argv[i] != NULL; i++)
- {
+ for(i = 3; argv[i] != NULL; i++){
char buf[BUFSIZ];
filter = slapi_ch_smprintf("(%s=*%s)", argv[i],
escape_filter_value(origDN, len, buf));
if ( filter ) {
/* Need only the current attribute and its subtypes */
- char *attrs[2];
attrs[0] = argv[i];
attrs[1] = NULL;
@@ -722,35 +724,34 @@ update_integrity(char **argv, Slapi_DN *origSDN,
NULL, NULL, referint_plugin_identity, 0);
slapi_search_internal_pb(search_result_pb);
- slapi_pblock_get( search_result_pb, SLAPI_PLUGIN_INTOP_RESULT,
- &search_result);
+ slapi_pblock_get( search_result_pb, SLAPI_PLUGIN_INTOP_RESULT, &search_result);
/* if search successfull then do integrity update */
if(search_result == LDAP_SUCCESS)
{
- slapi_pblock_get(search_result_pb,
- SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES,
+ slapi_pblock_get(search_result_pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES,
&search_entries);
- for(j=0; search_entries[j] != NULL; j++)
- {
- Slapi_Attr *attr = NULL;
- char *attrName = NULL;
-
- /* Loop over all the attributes of the entry and search
- * for the integrity attribute and its subtypes */
+ for(j = 0; search_entries[j] != NULL; j++){
+ attr = NULL;
+ attrName = NULL;
+ /*
+ * Loop over all the attributes of the entry and search
+ * for the integrity attribute and its subtypes
+ */
for (slapi_entry_first_attr(search_entries[j], &attr); attr;
slapi_entry_next_attr(search_entries[j], attr, &attr))
{
- /* Take into account only the subtypes of the attribute
- * in argv[i] having the necessary value - origDN */
+ /*
+ * Take into account only the subtypes of the attribute
+ * in argv[i] having the necessary value - origDN
+ */
slapi_attr_get_type(attr, &attrName);
if (slapi_attr_type_cmp(argv[i], attrName,
SLAPI_TYPE_CMP_SUBTYPE) == 0)
{
- int nval = 0;
+ nval = 0;
slapi_attr_get_numvalues(attr, &nval);
-
/*
* We want to reduce the "modify" call as much as
* possible. But if an entry contains 1000s of
@@ -781,21 +782,16 @@ update_integrity(char **argv, Slapi_DN *origSDN,
}
}
} else {
- if (isFatalSearchError(search_result))
- {
- /* NPCTE fix for bugid 531225, esc 0. <P.R> <30-May-2001> */
+ if (isFatalSearchError(search_result)){
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
"update_integrity search (base=%s filter=%s) returned "
"error %d\n", search_base, filter, search_result);
- /* end of NPCTE fix for bugid 531225 */
rc = -1;
goto free_and_return;
}
}
-
slapi_ch_free_string(&filter);
}
-
slapi_free_search_results_internal(search_result_pb);
}
}
@@ -817,221 +813,197 @@ free_and_return:
int referint_postop_start( Slapi_PBlock *pb)
{
-
char **argv;
- int argc = 0;
+ int argc = 0;
/* get args */
if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGC, &argc ) != 0 ) {
- slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
- "referint_postop failed to get argv\n" );
- return( -1 );
+ slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
+ "referint_postop failed to get argv\n" );
+ return( -1 );
}
if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGV, &argv ) != 0 ) {
- slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
- "referint_postop failed to get argv\n" );
- return( -1 );
+ slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
+ "referint_postop failed to get argv\n" );
+ return( -1 );
}
-
if(argv == NULL){
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
- "args were null in referint_postop_start\n" );
- return( -1 );
+ "args were null in referint_postop_start\n" );
+ return( -1 );
}
-
- /* only bother to start the thread if you are in delay mode.
- 0 = no delay,
- -1 = integrity off */
-
- if (argc >= 1) {
- if(atoi(argv[0]) > 0){
-
- /* initialize cv and lock */
-
- referint_mutex = PR_NewLock();
- keeprunning_mutex = PR_NewLock();
- keeprunning_cv = PR_NewCondVar(keeprunning_mutex);
- keeprunning =1;
+ /*
+ * Only bother to start the thread if you are in delay mode.
+ * 0 = no delay,
+ * -1 = integrity off
+ */
+ if (argc >= 1) {
+ if(atoi(argv[0]) > 0){
+ /* initialize the cv and lock */
+ referint_mutex = PR_NewLock();
+ keeprunning_mutex = PR_NewLock();
+ keeprunning_cv = PR_NewCondVar(keeprunning_mutex);
+ keeprunning =1;
- referint_tid = PR_CreateThread (PR_USER_THREAD,
- referint_thread_func,
- (void *)argv,
- PR_PRIORITY_NORMAL,
- PR_GLOBAL_THREAD,
- PR_UNJOINABLE_THREAD,
- SLAPD_DEFAULT_THREAD_STACKSIZE);
- if ( referint_tid == NULL ) {
- slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
- "referint_postop_start PR_CreateThread failed\n" );
- exit( 1 );
- }
- }
- } else {
- slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
- "referint_postop_start insufficient arguments supplied\n" );
- return( -1 );
- }
+ referint_tid = PR_CreateThread (PR_USER_THREAD,
+ referint_thread_func,
+ (void *)argv,
+ PR_PRIORITY_NORMAL,
+ PR_GLOBAL_THREAD,
+ PR_UNJOINABLE_THREAD,
+ SLAPD_DEFAULT_THREAD_STACKSIZE);
+ if ( referint_tid == NULL ) {
+ slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
+ "referint_postop_start PR_CreateThread failed\n" );
+ exit( 1 );
+ }
+ }
+ } else {
+ slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
+ "referint_postop_start insufficient arguments supplied\n" );
+ return( -1 );
+ }
return(0);
-
}
int referint_postop_close( Slapi_PBlock *pb)
{
+ /* signal the thread to exit */
+ if (NULL != keeprunning_mutex) {
+ PR_Lock(keeprunning_mutex);
+ keeprunning=0;
+ if (NULL != keeprunning_cv) {
+ PR_NotifyCondVar(keeprunning_cv);
+ }
+ PR_Unlock(keeprunning_mutex);
+ }
- /* signal the thread to exit */
- if (NULL != keeprunning_mutex) {
- PR_Lock(keeprunning_mutex);
- keeprunning=0;
- if (NULL != keeprunning_cv) {
- PR_NotifyCondVar(keeprunning_cv);
- }
- PR_Unlock(keeprunning_mutex);
- }
-
- return(0);
+ return(0);
}
void
referint_thread_func(void *arg)
{
- char **plugin_argv = (char **)arg;
PRFileDesc *prfd;
+ char **plugin_argv = (char **)arg;
char *logfilename;
char thisline[MAX_LINE];
- int delay;
- int no_changes;
char delimiter[]="\t\n";
char *ptoken;
- Slapi_DN *sdn = NULL;
char *tmprdn;
+ char *iter = NULL;
+ Slapi_DN *sdn = NULL;
Slapi_DN *tmpsuperior = NULL;
- int logChanges=0;
- char * iter = NULL;
+ int logChanges = 0;
+ int delay;
+ int no_changes;
if(plugin_argv == NULL){
- slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
- "referint_thread_func not get args \n" );
- return;
+ slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
+ "referint_thread_func not get args \n" );
+ return;
}
- /* initialize the thread data index
- if(slapi_td_dn_init()){
- slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,"Failed to create thread data index\n");
-
- } */
-
delay = atoi(plugin_argv[0]);
logfilename = plugin_argv[1];
- logChanges = atoi(plugin_argv[2]);
-
- /* keep running this thread until plugin is signalled to close */
-
+ logChanges = atoi(plugin_argv[2]);
+ /*
+ * keep running this thread until plugin is signaled to close
+ */
while(1){
-
no_changes=1;
-
while(no_changes){
-
- PR_Lock(keeprunning_mutex);
- if(keeprunning == 0){
- PR_Unlock(keeprunning_mutex);
- break;
- }
- PR_Unlock(keeprunning_mutex);
-
-
- PR_Lock(referint_mutex);
- if (( prfd = PR_Open( logfilename, PR_RDONLY,
- REFERINT_DEFAULT_FILE_MODE )) == NULL )
- {
- PR_Unlock(referint_mutex);
- /* go back to sleep and wait for this file */
- PR_Lock(keeprunning_mutex);
- PR_WaitCondVar(keeprunning_cv, PR_SecondsToInterval(delay));
+ PR_Lock(keeprunning_mutex);
+ if(keeprunning == 0){
+ PR_Unlock(keeprunning_mutex);
+ break;
+ }
PR_Unlock(keeprunning_mutex);
- }else{
- no_changes = 0;
- }
- }
-
- /* check keep running here, because after break out of no
- * changes loop on shutdown, also need to break out of this
- * loop before trying to do the changes. The server
- * will pick them up on next startup as file still exists
- */
+
+ PR_Lock(referint_mutex);
+ if (( prfd = PR_Open( logfilename, PR_RDONLY, REFERINT_DEFAULT_FILE_MODE )) == NULL ){
+ PR_Unlock(referint_mutex);
+ /* go back to sleep and wait for this file */
+ PR_Lock(keeprunning_mutex);
+ PR_WaitCondVar(keeprunning_cv, PR_SecondsToInterval(delay));
+ PR_Unlock(keeprunning_mutex);
+ } else {
+ no_changes = 0;
+ }
+ }
+ /*
+ * Check keep running here, because after break out of no
+ * changes loop on shutdown, also need to break out of this
+ * loop before trying to do the changes. The server
+ * will pick them up on next startup as file still exists
+ */
PR_Lock(keeprunning_mutex);
if(keeprunning == 0){
- PR_Unlock(keeprunning_mutex);
- break;
+ PR_Unlock(keeprunning_mutex);
+ break;
}
PR_Unlock(keeprunning_mutex);
-
-
- while( GetNextLine(thisline, MAX_LINE, prfd) ){
- ptoken = ldap_utf8strtok_r(thisline, delimiter, &iter);
- sdn = slapi_sdn_new_normdn_byref(ptoken);
-
- ptoken = ldap_utf8strtok_r (NULL, delimiter, &iter);
- if(!strcasecmp(ptoken, "NULL")) {
- tmprdn = NULL;
- } else {
- tmprdn = slapi_ch_smprintf("%s", ptoken);
- }
-
- ptoken = ldap_utf8strtok_r (NULL, delimiter, &iter);
- if (!strcasecmp(ptoken, "NULL")) {
- tmpsuperior = NULL;
- } else {
- tmpsuperior = slapi_sdn_new_normdn_byref(ptoken);
- }
- ptoken = ldap_utf8strtok_r (NULL, delimiter, &iter);
- if (strcasecmp(ptoken, "NULL") != 0) {
- /* Set the bind DN in the thread data */
- if(slapi_td_set_dn(slapi_ch_strdup(ptoken))){
- slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,"Failed to set thread data\n");
- }
- }
-
- update_integrity(plugin_argv, sdn, tmprdn,
- tmpsuperior, logChanges);
-
- slapi_sdn_free(&sdn);
- slapi_ch_free_string(&tmprdn);
- slapi_sdn_free(&tmpsuperior);
- }
-
- PR_Close(prfd);
-
- /* remove the original file */
- if( PR_SUCCESS != PR_Delete(logfilename) )
- {
- slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
- "referint_postop_close could not delete \"%s\"\n",
- logfilename );
- }
- /* unlock and let other writers back at the file */
- PR_Unlock(referint_mutex);
-
- /* wait on condition here */
- PR_Lock(keeprunning_mutex);
- PR_WaitCondVar(keeprunning_cv, PR_SecondsToInterval(delay));
- PR_Unlock(keeprunning_mutex);
- }
+ while( GetNextLine(thisline, MAX_LINE, prfd) ){
+ ptoken = ldap_utf8strtok_r(thisline, delimiter, &iter);
+ sdn = slapi_sdn_new_normdn_byref(ptoken);
+ ptoken = ldap_utf8strtok_r (NULL, delimiter, &iter);
- /* cleanup resources allocated in start */
- if (NULL != keeprunning_mutex) {
- PR_DestroyLock(keeprunning_mutex);
- }
- if (NULL != referint_mutex) {
- PR_DestroyLock(referint_mutex);
- }
- if (NULL != keeprunning_cv) {
- PR_DestroyCondVar(keeprunning_cv);
- }
+ if(!strcasecmp(ptoken, "NULL")) {
+ tmprdn = NULL;
+ } else {
+ tmprdn = slapi_ch_smprintf("%s", ptoken);
+ }
+
+ ptoken = ldap_utf8strtok_r (NULL, delimiter, &iter);
+ if (!strcasecmp(ptoken, "NULL")) {
+ tmpsuperior = NULL;
+ } else {
+ tmpsuperior = slapi_sdn_new_normdn_byref(ptoken);
+ }
+ ptoken = ldap_utf8strtok_r (NULL, delimiter, &iter);
+ if (strcasecmp(ptoken, "NULL") != 0) {
+ /* Set the bind DN in the thread data */
+ if(slapi_td_set_dn(slapi_ch_strdup(ptoken))){
+ slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,"Failed to set thread data\n");
+ }
+ }
+
+ update_integrity(plugin_argv, sdn, tmprdn, tmpsuperior, logChanges);
+
+ slapi_sdn_free(&sdn);
+ slapi_ch_free_string(&tmprdn);
+ slapi_sdn_free(&tmpsuperior);
+ }
+
+ PR_Close(prfd);
+
+ /* remove the original file */
+ if( PR_SUCCESS != PR_Delete(logfilename) ){
+ slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
+ "referint_postop_close could not delete \"%s\"\n", logfilename );
+ }
+
+ /* unlock and let other writers back at the file */
+ PR_Unlock(referint_mutex);
+ /* wait on condition here */
+ PR_Lock(keeprunning_mutex);
+ PR_WaitCondVar(keeprunning_cv, PR_SecondsToInterval(delay));
+ PR_Unlock(keeprunning_mutex);
+ }
+ /* cleanup resources allocated in start */
+ if (NULL != keeprunning_mutex) {
+ PR_DestroyLock(keeprunning_mutex);
+ }
+ if (NULL != referint_mutex) {
+ PR_DestroyLock(referint_mutex);
+ }
+ if (NULL != keeprunning_cv) {
+ PR_DestroyCondVar(keeprunning_cv);
+ }
}
int my_fgetc(PRFileDesc *stream)
@@ -1042,7 +1014,6 @@ int my_fgetc(PRFileDesc *stream)
int err;
/* check if we need to load the buffer */
-
if( READ_BUFSIZE == position )
{
memset(buf, '\0', READ_BUFSIZE);
@@ -1055,7 +1026,7 @@ int my_fgetc(PRFileDesc *stream)
return err;
}
}
-
+
/* try to read some data */
if( '\0' == buf[position])
{
@@ -1066,9 +1037,8 @@ int my_fgetc(PRFileDesc *stream)
retval = buf[position];
position++;
}
-
- return retval;
+ return retval;
}
int
@@ -1078,38 +1048,33 @@ GetNextLine(char *dest, int size_dest, PRFileDesc *stream) {
int done = 0;
int i = 0;
- while(!done)
- {
- if( ( nextchar = my_fgetc(stream) ) != 0)
- {
- if( i < (size_dest - 1) )
- {
+ while(!done){
+ if( ( nextchar = my_fgetc(stream) ) != 0){
+ if( i < (size_dest - 1) ){
dest[i] = nextchar;
i++;
-
- if(nextchar == '\n')
- {
+ if(nextchar == '\n'){
/* end of line reached */
done = 1;
}
-
- }else{
+ } else {
/* no more room in buffer */
done = 1;
}
-
- }else{
+ } else {
/* error or end of file */
done = 1;
}
}
-
dest[i] = '\0';
/* return size of string read */
return i;
}
+/*
+ * Write this record to the log file
+ */
void
writeintegritylog(Slapi_PBlock *pb, char *logfilename, Slapi_DN *sdn,
char *newrdn, Slapi_DN *newsuperior, Slapi_DN *requestorsdn)
@@ -1120,44 +1085,40 @@ writeintegritylog(Slapi_PBlock *pb, char *logfilename, Slapi_DN *sdn,
int rc;
const char *requestordn = NULL;
size_t reqdn_len = 0;
- /* write this record to the file */
-
- /* use this lock to protect file data when update integrity is occuring */
- /* should hopefully not be a big issue on concurrency */
+ /*
+ * Use this lock to protect file data when update integrity is occuring
+ * should hopefully not be a big issue on concurrency
+ */
PR_Lock(referint_mutex);
if (( prfd = PR_Open( logfilename, PR_WRONLY | PR_CREATE_FILE | PR_APPEND,
REFERINT_DEFAULT_FILE_MODE )) == NULL )
{
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
- "referint_postop could not write integrity log \"%s\" "
- SLAPI_COMPONENT_NAME_NSPR " %d (%s)\n",
- logfilename, PR_GetError(), slapd_pr_strerror(PR_GetError()) );
-
+ "referint_postop could not write integrity log \"%s\" "
+ SLAPI_COMPONENT_NAME_NSPR " %d (%s)\n",
+ logfilename, PR_GetError(), slapd_pr_strerror(PR_GetError()) );
+
PR_Unlock(referint_mutex);
- return;
+ return;
}
-
- /* make sure we have enough room in our buffer
- before trying to write it
+ /*
+ * Make sure we have enough room in our buffer before trying to write it.
+ * add length of dn + 5(three tabs, a newline, and terminating \0)
*/
-
- /* add length of dn + 5(three tabs, a newline, and terminating \0) */
len_to_write = slapi_sdn_get_ndn_len(sdn) + 5;
- if(newrdn == NULL)
- {
+ if(newrdn == NULL){
/* add the length of "NULL" */
len_to_write += 4;
- }else{
+ } else {
/* add the length of the newrdn */
len_to_write += strlen(newrdn);
}
- if(NULL == newsuperior)
- {
+ if(NULL == newsuperior){
/* add the length of "NULL" */
len_to_write += 4;
- }else{
+ } else {
/* add the length of the newsuperior */
len_to_write += slapi_sdn_get_ndn_len(newsuperior);
}
@@ -1169,36 +1130,30 @@ writeintegritylog(Slapi_PBlock *pb, char *logfilename, Slapi_DN *sdn,
len_to_write += 4; /* "NULL" */
}
- if(len_to_write > MAX_LINE )
- {
+ if(len_to_write > MAX_LINE ){
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
"referint_postop could not write integrity log:"
" line length exceeded. It will not be able"
" to update references to this entry.\n");
- }else{
- PR_snprintf(buffer, MAX_LINE, "%s\t%s\t%s\t%s\t\n",
- slapi_sdn_get_dn(sdn),
- (newrdn != NULL) ? newrdn : "NULL",
- (newsuperior != NULL) ? slapi_sdn_get_dn(newsuperior) :
- "NULL",
- requestordn ? requestordn : "NULL");
+ } else {
+ PR_snprintf(buffer, MAX_LINE, "%s\t%s\t%s\t%s\t\n", slapi_sdn_get_dn(sdn),
+ (newrdn != NULL) ? newrdn : "NULL",
+ (newsuperior != NULL) ? slapi_sdn_get_dn(newsuperior) : "NULL",
+ requestordn ? requestordn : "NULL");
if (PR_Write(prfd,buffer,strlen(buffer)) < 0){
- slapi_log_error(SLAPI_LOG_FATAL,REFERINT_PLUGIN_SUBSYSTEM,
- " writeintegritylog: PR_Write failed : The disk"
- " may be full or the file is unwritable :: NSPR error - %d\n",
- PR_GetError());
- }
- }
+ slapi_log_error(SLAPI_LOG_FATAL,REFERINT_PLUGIN_SUBSYSTEM,
+ " writeintegritylog: PR_Write failed : The disk"
+ " may be full or the file is unwritable :: NSPR error - %d\n",
+ PR_GetError());
+ }
+ }
/* If file descriptor is closed successfully, PR_SUCCESS */
-
rc = PR_Close(prfd);
- if (rc != PR_SUCCESS)
- {
- slapi_log_error(SLAPI_LOG_FATAL,REFERINT_PLUGIN_SUBSYSTEM,
- " writeintegritylog: failed to close the file"
- " descriptor prfd; NSPR error - %d\n",
- PR_GetError());
- }
+ if (rc != PR_SUCCESS){
+ slapi_log_error(SLAPI_LOG_FATAL,REFERINT_PLUGIN_SUBSYSTEM,
+ " writeintegritylog: failed to close the file descriptor prfd; NSPR error - %d\n",
+ PR_GetError());
+ }
PR_Unlock(referint_mutex);
- }
+}
diff --git a/ldap/servers/plugins/replication/repl5_plugins.c b/ldap/servers/plugins/replication/repl5_plugins.c
index 9358daf..a768edb 100644
--- a/ldap/servers/plugins/replication/repl5_plugins.c
+++ b/ldap/servers/plugins/replication/repl5_plugins.c
@@ -479,7 +479,12 @@ multimaster_preop_modify (Slapi_PBlock *pb)
}
else
{
- PR_ASSERT(0); /* JCMREPL - A Replicated Operation with no Repl Baggage control... What does that mean? */
+ /* PR_ASSERT(0); JCMREPL - A Replicated Operation with no Repl Baggage control... What does that mean? */
+ /*
+ * This could be RI plugin responding to a replicated update from AD or some other master that is not
+ * using the RI plugin, so don't PR_ASSERT here. This only happens if we configure the RI plugin with
+ * "nsslapd-pluginAllowReplUpdates: on", also the RI plugin only issues "modifies".
+ */
}
}
else
11 years, 11 months
ldap/servers
by Noriko Hosoi
ldap/servers/plugins/replication/llist.c | 6 +--
ldap/servers/plugins/replication/urp.c | 57 ++++++++++++++++++++++-------
ldap/servers/slapd/back-ldbm/ldbm_add.c | 29 +++++++-------
ldap/servers/slapd/back-ldbm/ldbm_modrdn.c | 29 +++++++-------
4 files changed, 76 insertions(+), 45 deletions(-)
New commits:
commit ff601de4c21224f6fa5b995fd877907671f75575
Author: Noriko Hosoi <nhosoi(a)totoro.usersys.redhat.com>
Date: Tue May 15 10:43:59 2012 -0700
Trac Ticket #359 - Database RUV could mismatch the one
in changelog under the stress
https://fedorahosted.org/389/ticket/359
Fix Description:
. Fix for llistRemoveCurrentAndGetNext (llist.c) in commit
f0f74b57f81998a325dc7472b9ea9b44c5ff6439 was not correct.
. Undo the changes made in ldbm_back_add, ldbm_back_modrdn
(ldbm_add.c, ldbm_modrdn.c) in commit
f0f74b57f81998a325dc7472b9ea9b44c5ff6439.
. urp.c: In the original design, if op_result is LDA_SUCCESS and
the return code is -1, the operation is skipped, but the max
csn is updated in RUV. Currently, we have no way to do so.
This patch eliminates the cases: 2 in urp_add_operation and 1
in urp_modrdn_operation are now LDAP_UNWILLING_TO_PERFORM; 1 in
urp_modrdn_operation (the existing entry is the same as the
target one) returns 0.
diff --git a/ldap/servers/plugins/replication/llist.c b/ldap/servers/plugins/replication/llist.c
index e80f532..05cfa48 100644
--- a/ldap/servers/plugins/replication/llist.c
+++ b/ldap/servers/plugins/replication/llist.c
@@ -165,14 +165,14 @@ void* llistRemoveCurrentAndGetNext (LList *list, void **iterator)
if (node)
{
prevNode->next = node->next;
+ if (list->tail == node) {
+ list->tail = prevNode;
+ }
_llistDestroyNode (&node, NULL);
node = prevNode->next;
if (node) {
return node->data;
} else {
- if (list->head->next == NULL) {
- list->tail = NULL;
- }
return NULL;
}
}
diff --git a/ldap/servers/plugins/replication/urp.c b/ldap/servers/plugins/replication/urp.c
index bc32473..1d8799a 100644
--- a/ldap/servers/plugins/replication/urp.c
+++ b/ldap/servers/plugins/replication/urp.c
@@ -137,7 +137,17 @@ urp_add_operation( Slapi_PBlock *pb )
* - It could be a replay of the same Add, or
* - It could be a UUID generation collision, or
*/
- op_result = LDAP_SUCCESS;
+ /*
+ * This operation won't be replayed. That is, this CSN won't update
+ * the max csn in RUV. The CSN is left uncommitted in RUV unless an
+ * error is set to op_result. Just to get rid of this CSN from RUV,
+ * setting an error to op_result
+ */
+ /* op_result = LDAP_SUCCESS; */
+ slapi_log_error(slapi_log_urp, sessionid,
+ "urp_add (%s): an entry with this uniqueid already exists.\n",
+ slapi_entry_get_dn_const(existing_uniqueid_entry));
+ op_result= LDAP_UNWILLING_TO_PERFORM;
slapi_pblock_set(pb, SLAPI_RESULT_CODE, &op_result);
rc= -1; /* Ignore this Operation */
PROFILE_POINT; /* Add Conflict; UniqueID Exists; Ignore */
@@ -249,7 +259,17 @@ urp_add_operation( Slapi_PBlock *pb )
* b) We've seen the Operation before.
* Let's go with (b) and ignore the little bastard.
*/
- op_result= LDAP_SUCCESS;
+ /*
+ * This operation won't be replayed. That is, this CSN won't update
+ * the max csn in RUV. The CSN is left uncommitted in RUV unless an
+ * error is set to op_result. Just to get rid of this CSN from RUV,
+ * setting an error to op_result
+ */
+ /* op_result = LDAP_SUCCESS; */
+ slapi_log_error(slapi_log_urp, sessionid,
+ "urp_add (%s): The CSN of the Operation and the Entry DN are the same.",
+ slapi_entry_get_dn_const(existing_dn_entry));
+ op_result= LDAP_UNWILLING_TO_PERFORM;
slapi_pblock_set(pb, SLAPI_RESULT_CODE, &op_result);
rc= -1; /* Ignore this Operation */
PROFILE_POINT; /* Add Conflict; Entry Exists; Same CSN */
@@ -311,7 +331,17 @@ urp_modrdn_operation( Slapi_PBlock *pb )
* The Operation CSN is not newer than the DN CSN.
* Either we're beaten by another ModRDN or we've applied the op.
*/
- op_result= LDAP_SUCCESS;
+ /* op_result= LDAP_SUCCESS; */
+ /*
+ * This operation won't be replayed. That is, this CSN won't update
+ * the max csn in RUV. The CSN is left uncommitted in RUV unless an
+ * error is set to op_result. Just to get rid of this CSN from RUV,
+ * setting an error to op_result
+ */
+ slapi_log_error(slapi_log_urp, sessionid,
+ "urp_modrdn (%s): operation CSN is newer than the DN CSN.\n",
+ slapi_entry_get_dn_const(target_entry));
+ op_result= LDAP_UNWILLING_TO_PERFORM;
slapi_pblock_set(pb, SLAPI_RESULT_CODE, &op_result);
rc= -1; /* Ignore the modrdn */
PROFILE_POINT; /* ModRDN Conflict; Entry with Target DN Exists; OPCSN is not newer. */
@@ -323,8 +353,8 @@ urp_modrdn_operation( Slapi_PBlock *pb )
/* newrdn is no need to be case-ignored (get_rdn_plus_uniqueid) */
slapi_pblock_get(pb, SLAPI_MODRDN_NEWRDN, &newrdn);
slapi_pblock_get(pb, SLAPI_TARGET_UNIQUEID, &op_uniqueid);
- slapi_pblock_get(pb, SLAPI_MODRDN_PARENT_ENTRY, &parent_entry);
- slapi_pblock_get(pb, SLAPI_MODRDN_NEWPARENT_ENTRY, &new_parent_entry);
+ slapi_pblock_get(pb, SLAPI_MODRDN_PARENT_ENTRY, &parent_entry);
+ slapi_pblock_get(pb, SLAPI_MODRDN_NEWPARENT_ENTRY, &new_parent_entry);
slapi_pblock_get(pb, SLAPI_MODRDN_NEWSUPERIOR_SDN, &newsuperior);
if ( is_tombstone_entry (target_entry) )
@@ -361,26 +391,29 @@ urp_modrdn_operation( Slapi_PBlock *pb )
goto bailout;
}
- slapi_pblock_get(pb, SLAPI_MODRDN_EXISTING_ENTRY, &existing_entry);
- if(existing_entry!=NULL)
+ slapi_pblock_get(pb, SLAPI_MODRDN_EXISTING_ENTRY, &existing_entry);
+ if(existing_entry!=NULL)
{
/*
* An entry with the target DN already exists.
- * The smaller dncsn wins. The loser changes its RDN to
- * uniqueid+baserdn, and adds operational attribute
- * ATTR_NSDS5_REPLCONFLIC
+ * The smaller dncsn wins. The loser changes its RDN to
+ * uniqueid+baserdn, and adds operational attribute
+ * ATTR_NSDS5_REPLCONFLIC
*/
existing_uniqueid = slapi_entry_get_uniqueid (existing_entry);
existing_sdn = slapi_entry_get_sdn_const ( existing_entry);
/*
- * Dismiss the operation if the existing entry is the same as the target one.
+ * It used to dismiss the operation if the existing entry is
+ * the same as the target one.
+ * But renaming the RDN with the one which only cases are different,
+ * cn=ABC --> cn=Abc, this case matches. We should go forward the op.
*/
if (strcmp(op_uniqueid, existing_uniqueid) == 0) {
op_result= LDAP_SUCCESS;
slapi_pblock_set(pb, SLAPI_RESULT_CODE, &op_result);
- rc = -1; /* Ignore the op */
+ rc = 0; /* Don't ignore the op */
PROFILE_POINT; /* ModRDN Replay */
goto bailout;
}
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c b/ldap/servers/slapd/back-ldbm/ldbm_add.c
index fc7ed80..1539c7c 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_add.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c
@@ -117,7 +117,6 @@ ldbm_back_add( Slapi_PBlock *pb )
int is_ruv = 0; /* True if the current entry is RUV */
CSN *opcsn = NULL;
entry_address addr = {0};
- int val = 0;
slapi_pblock_get( pb, SLAPI_PLUGIN_PRIVATE, &li );
slapi_pblock_get( pb, SLAPI_ADD_ENTRY, &e );
@@ -1044,26 +1043,26 @@ error_return:
disk_full = 1;
}
- /* make sure SLAPI_RESULT_CODE and SLAPI_PLUGIN_OPRETURN are set */
- slapi_pblock_get(pb, SLAPI_RESULT_CODE, &val);
- if (!val) {
- if (!ldap_result_code) {
- ldap_result_code = LDAP_OPERATIONS_ERROR;
- }
- slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code);
- }
- slapi_pblock_get( pb, SLAPI_PLUGIN_OPRETURN, &val );
- if (!val) {
- val = -1;
- slapi_pblock_set( pb, SLAPI_PLUGIN_OPRETURN, &val );
- }
-
diskfull_return:
if (disk_full) {
rc= return_on_disk_full(li);
} else {
/* It is safer not to abort when the transaction is not started. */
if (txn.back_txn_txn && (txn.back_txn_txn != parent_txn)) {
+ /* make sure SLAPI_RESULT_CODE and SLAPI_PLUGIN_OPRETURN are set */
+ int val = 0;
+ slapi_pblock_get(pb, SLAPI_RESULT_CODE, &val);
+ if (!val) {
+ if (!ldap_result_code) {
+ ldap_result_code = LDAP_OPERATIONS_ERROR;
+ }
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code);
+ }
+ slapi_pblock_get( pb, SLAPI_PLUGIN_OPRETURN, &val );
+ if (!val) {
+ val = -1;
+ slapi_pblock_set( pb, SLAPI_PLUGIN_OPRETURN, &val );
+ }
/* call the transaction post add plugins just before the abort */
if ((retval = plugin_call_plugins(pb, SLAPI_PLUGIN_BE_TXN_POST_ADD_FN))) {
int opreturn = 0;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
index 2e180f2..b3d8111 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
@@ -120,7 +120,6 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
const char *newdn = NULL;
char *newrdn = NULL;
int opreturn = 0;
- int val = 0;
/* sdn & parentsdn need to be initialized before "goto *_return" */
slapi_sdn_init(&dn_newdn);
@@ -1199,20 +1198,6 @@ error_return:
disk_full = 1;
}
- /* make sure SLAPI_RESULT_CODE and SLAPI_PLUGIN_OPRETURN are set */
- slapi_pblock_get(pb, SLAPI_RESULT_CODE, &val);
- if (!val) {
- if (!ldap_result_code) {
- ldap_result_code = LDAP_OPERATIONS_ERROR;
- }
- slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code);
- }
- slapi_pblock_get( pb, SLAPI_PLUGIN_OPRETURN, &val );
- if (!val) {
- opreturn = -1;
- slapi_pblock_set( pb, SLAPI_PLUGIN_OPRETURN, &opreturn );
- }
-
if (disk_full)
{
retval = return_on_disk_full(li);
@@ -1222,6 +1207,20 @@ error_return:
/* It is safer not to abort when the transaction is not started. */
if (txn.back_txn_txn && (txn.back_txn_txn != parent_txn))
{
+ /* make sure SLAPI_RESULT_CODE and SLAPI_PLUGIN_OPRETURN are set */
+ int val = 0;
+ slapi_pblock_get(pb, SLAPI_RESULT_CODE, &val);
+ if (!val) {
+ if (!ldap_result_code) {
+ ldap_result_code = LDAP_OPERATIONS_ERROR;
+ }
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code);
+ }
+ slapi_pblock_get( pb, SLAPI_PLUGIN_OPRETURN, &val );
+ if (!val) {
+ opreturn = -1;
+ slapi_pblock_set( pb, SLAPI_PLUGIN_OPRETURN, &opreturn );
+ }
/* call the transaction post modrdn plugins just before the commit */
if ((retval = plugin_call_plugins(pb, SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN))) {
LDAPDebug1Arg( LDAP_DEBUG_TRACE, "SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN plugin "
11 years, 11 months
Branch '389-ds-base-1.2.10' - 2 commits - ldap/servers
by Noriko Hosoi
ldap/servers/plugins/acl/acl.c | 16 +++++--
ldap/servers/plugins/acl/acllist.c | 4 -
ldap/servers/plugins/chainingdb/cb_add.c | 2
ldap/servers/plugins/chainingdb/cb_compare.c | 2
ldap/servers/plugins/chainingdb/cb_delete.c | 2
ldap/servers/plugins/chainingdb/cb_modify.c | 2
ldap/servers/plugins/chainingdb/cb_modrdn.c | 32 +--------------
ldap/servers/plugins/chainingdb/cb_search.c | 4 -
ldap/servers/plugins/referint/referint.c | 6 +-
ldap/servers/plugins/replication/llist.c | 6 +-
ldap/servers/plugins/replication/urp.c | 57 +++++++++++++++++++++------
ldap/servers/plugins/uiduniq/7bit.c | 4 -
ldap/servers/slapd/back-ldbm/ldbm_add.c | 15 -------
ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c | 3 -
ldap/servers/slapd/back-ldbm/ldbm_modrdn.c | 15 -------
ldap/servers/slapd/modrdn.c | 7 ++-
16 files changed, 84 insertions(+), 93 deletions(-)
New commits:
commit 2bead40718b7729df9435c44ab11f796d76848bf
Author: Noriko Hosoi <nhosoi(a)totoro.usersys.redhat.com>
Date: Sun May 13 17:10:04 2012 -0700
Trac Ticket #359 - Database RUV could mismatch the one
in changelog under the stress
https://fedorahosted.org/389/ticket/359
Fix Description:
. Fix for llistRemoveCurrentAndGetNext (llist.c) in commit
f92f3a6e91498770aa8e93b6842ba752d4ed279a was not correct.
. Undo the changes made in ldbm_back_add, ldbm_back_modrdn
(ldbm_add.c, ldbm_modrdn.c) in commit
f92f3a6e91498770aa8e93b6842ba752d4ed279a.
. urp.c: In the original design, if op_result is LDA_SUCCESS and
the return code is -1, the operation is skipped, but the max
csn is updated in RUV. Currently, we have no way to do so.
This patch eliminates the cases: 2 in urp_add_operation and 1
in urp_modrdn_operation are now LDAP_UNWILLING_TO_PERFORM; 1 in
urp_modrdn_operation (the existing entry is the same as the
target one) returns 0.
diff --git a/ldap/servers/plugins/replication/llist.c b/ldap/servers/plugins/replication/llist.c
index e80f532..05cfa48 100644
--- a/ldap/servers/plugins/replication/llist.c
+++ b/ldap/servers/plugins/replication/llist.c
@@ -165,14 +165,14 @@ void* llistRemoveCurrentAndGetNext (LList *list, void **iterator)
if (node)
{
prevNode->next = node->next;
+ if (list->tail == node) {
+ list->tail = prevNode;
+ }
_llistDestroyNode (&node, NULL);
node = prevNode->next;
if (node) {
return node->data;
} else {
- if (list->head->next == NULL) {
- list->tail = NULL;
- }
return NULL;
}
}
diff --git a/ldap/servers/plugins/replication/urp.c b/ldap/servers/plugins/replication/urp.c
index 25dfd5c..e70ae5b 100644
--- a/ldap/servers/plugins/replication/urp.c
+++ b/ldap/servers/plugins/replication/urp.c
@@ -139,7 +139,17 @@ urp_add_operation( Slapi_PBlock *pb )
* - It could be a replay of the same Add, or
* - It could be a UUID generation collision, or
*/
- op_result = LDAP_SUCCESS;
+ /*
+ * This operation won't be replayed. That is, this CSN won't update
+ * the max csn in RUV. The CSN is left uncommitted in RUV unless an
+ * error is set to op_result. Just to get rid of this CSN from RUV,
+ * setting an error to op_result
+ */
+ /* op_result = LDAP_SUCCESS; */
+ slapi_log_error(slapi_log_urp, sessionid,
+ "urp_add (%s): an entry with this uniqueid already exists.\n",
+ slapi_entry_get_dn_const(existing_uniqueid_entry));
+ op_result= LDAP_UNWILLING_TO_PERFORM;
slapi_pblock_set(pb, SLAPI_RESULT_CODE, &op_result);
rc= -1; /* Ignore this Operation */
PROFILE_POINT; /* Add Conflict; UniqueID Exists; Ignore */
@@ -251,7 +261,17 @@ urp_add_operation( Slapi_PBlock *pb )
* b) We've seen the Operation before.
* Let's go with (b) and ignore the little bastard.
*/
- op_result= LDAP_SUCCESS;
+ /*
+ * This operation won't be replayed. That is, this CSN won't update
+ * the max csn in RUV. The CSN is left uncommitted in RUV unless an
+ * error is set to op_result. Just to get rid of this CSN from RUV,
+ * setting an error to op_result
+ */
+ /* op_result = LDAP_SUCCESS; */
+ slapi_log_error(slapi_log_urp, sessionid,
+ "urp_add (%s): The CSN of the Operation and the Entry DN are the same.",
+ slapi_entry_get_dn_const(existing_dn_entry));
+ op_result= LDAP_UNWILLING_TO_PERFORM;
slapi_pblock_set(pb, SLAPI_RESULT_CODE, &op_result);
rc= -1; /* Ignore this Operation */
PROFILE_POINT; /* Add Conflict; Entry Exists; Same CSN */
@@ -315,7 +335,17 @@ urp_modrdn_operation( Slapi_PBlock *pb )
* The Operation CSN is not newer than the DN CSN.
* Either we're beaten by another ModRDN or we've applied the op.
*/
- op_result= LDAP_SUCCESS;
+ /* op_result= LDAP_SUCCESS; */
+ /*
+ * This operation won't be replayed. That is, this CSN won't update
+ * the max csn in RUV. The CSN is left uncommitted in RUV unless an
+ * error is set to op_result. Just to get rid of this CSN from RUV,
+ * setting an error to op_result
+ */
+ slapi_log_error(slapi_log_urp, sessionid,
+ "urp_modrdn (%s): operation CSN is newer than the DN CSN.\n",
+ slapi_entry_get_dn_const(target_entry));
+ op_result= LDAP_UNWILLING_TO_PERFORM;
slapi_pblock_set(pb, SLAPI_RESULT_CODE, &op_result);
rc= -1; /* Ignore the modrdn */
PROFILE_POINT; /* ModRDN Conflict; Entry with Target DN Exists; OPCSN is not newer. */
@@ -326,8 +356,8 @@ urp_modrdn_operation( Slapi_PBlock *pb )
target_sdn = slapi_entry_get_sdn_const (target_entry);
slapi_pblock_get(pb, SLAPI_MODRDN_NEWRDN, &newrdn);
slapi_pblock_get(pb, SLAPI_TARGET_UNIQUEID, &op_uniqueid);
- slapi_pblock_get(pb, SLAPI_MODRDN_PARENT_ENTRY, &parent_entry);
- slapi_pblock_get(pb, SLAPI_MODRDN_NEWPARENT_ENTRY, &new_parent_entry);
+ slapi_pblock_get(pb, SLAPI_MODRDN_PARENT_ENTRY, &parent_entry);
+ slapi_pblock_get(pb, SLAPI_MODRDN_NEWPARENT_ENTRY, &new_parent_entry);
slapi_pblock_get(pb, SLAPI_MODRDN_NEWSUPERIOR_SDN, &newsuperior);
if ( is_tombstone_entry (target_entry) )
@@ -364,26 +394,29 @@ urp_modrdn_operation( Slapi_PBlock *pb )
goto bailout;
}
- slapi_pblock_get(pb, SLAPI_MODRDN_EXISTING_ENTRY, &existing_entry);
- if(existing_entry!=NULL)
+ slapi_pblock_get(pb, SLAPI_MODRDN_EXISTING_ENTRY, &existing_entry);
+ if(existing_entry!=NULL)
{
/*
* An entry with the target DN already exists.
- * The smaller dncsn wins. The loser changes its RDN to
- * uniqueid+baserdn, and adds operational attribute
- * ATTR_NSDS5_REPLCONFLIC
+ * The smaller dncsn wins. The loser changes its RDN to
+ * uniqueid+baserdn, and adds operational attribute
+ * ATTR_NSDS5_REPLCONFLIC
*/
existing_uniqueid = slapi_entry_get_uniqueid (existing_entry);
existing_sdn = slapi_entry_get_sdn_const ( existing_entry);
/*
- * Dismiss the operation if the existing entry is the same as the target one.
+ * It used to dismiss the operation if the existing entry is
+ * the same as the target one.
+ * But renaming the RDN with the one which only cases are different,
+ * cn=ABC --> cn=Abc, this case matches. We should go forward the op.
*/
if (strcmp(op_uniqueid, existing_uniqueid) == 0) {
op_result= LDAP_SUCCESS;
slapi_pblock_set(pb, SLAPI_RESULT_CODE, &op_result);
- rc = -1; /* Ignore the op */
+ rc = 0; /* Don't ignore the op */
PROFILE_POINT; /* ModRDN Replay */
goto bailout;
}
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c b/ldap/servers/slapd/back-ldbm/ldbm_add.c
index 132b125..df09c64 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_add.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c
@@ -116,7 +116,6 @@ ldbm_back_add( Slapi_PBlock *pb )
int is_ruv = 0; /* True if the current entry is RUV */
CSN *opcsn = NULL;
entry_address addr = {0};
- int val = 0;
slapi_pblock_get( pb, SLAPI_PLUGIN_PRIVATE, &li );
slapi_pblock_get( pb, SLAPI_ADD_ENTRY, &e );
@@ -965,20 +964,6 @@ error_return:
disk_full = 1;
}
- /* make sure SLAPI_RESULT_CODE and SLAPI_PLUGIN_OPRETURN are set */
- slapi_pblock_get(pb, SLAPI_RESULT_CODE, &val);
- if (!val) {
- if (!ldap_result_code) {
- ldap_result_code = LDAP_OPERATIONS_ERROR;
- }
- slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code);
- }
- slapi_pblock_get( pb, SLAPI_PLUGIN_OPRETURN, &val );
- if (!val) {
- val = -1;
- slapi_pblock_set( pb, SLAPI_PLUGIN_OPRETURN, &val );
- }
-
diskfull_return:
if (disk_full) {
rc= return_on_disk_full(li);
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
index 0b56219..6b0fa34 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
@@ -111,7 +111,6 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
entry_address *newsuperior_addr;
char ebuf[BUFSIZ];
CSN *opcsn = NULL;
- int val = 0;
/* sdn & parentsdn need to be initialized before "goto *_return" */
slapi_sdn_init(&dn_newdn);
@@ -1066,20 +1065,6 @@ error_return:
disk_full = 1;
}
- /* make sure SLAPI_RESULT_CODE and SLAPI_PLUGIN_OPRETURN are set */
- slapi_pblock_get(pb, SLAPI_RESULT_CODE, &val);
- if (!val) {
- if (!ldap_result_code) {
- ldap_result_code = LDAP_OPERATIONS_ERROR;
- }
- slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code);
- }
- slapi_pblock_get(pb, SLAPI_PLUGIN_OPRETURN, &val);
- if (!val) {
- val = -1;
- slapi_pblock_set(pb, SLAPI_PLUGIN_OPRETURN, &val);
- }
-
if (disk_full)
{
retval = return_on_disk_full(li);
commit ff29d1793e3bdfe19751d2e40b7ae5aa9963a3ba
Author: Noriko Hosoi <nhosoi(a)totoro.usersys.redhat.com>
Date: Sun May 13 17:05:05 2012 -0700
Trac Ticket #338 - letters in object's cn get converted to
lowercase when renaming object
https://fedorahosted.org/389/ticket/338
Fix description: The value of newrdn was normalized as dn then
decapitalized. The decapitalization was not just needed but
the cause of the reported bug.
This patch removes the decapitalization call (slapi_dn_ignore_case)
and adds slapi_dn_ignore_case to acl_access_allowed_modrdn (acl.c)
and referint_postop_modrdn (referint/referint.c).
Additionally, unnecessary code is being removed from chaining_
back_modrdn (chainingdb/cb_modrdn.c).
(Ported from commit 178fe6a74c793b3c6adc71f571bba40a6271325c)
diff --git a/ldap/servers/plugins/acl/acl.c b/ldap/servers/plugins/acl/acl.c
index c8a221e..5a7b446 100644
--- a/ldap/servers/plugins/acl/acl.c
+++ b/ldap/servers/plugins/acl/acl.c
@@ -118,6 +118,7 @@ acl_access_allowed_modrdn(
{
int retCode ;
char *newrdn;
+ char *ci_newrdn;
const char *oldrdn;
Slapi_DN *target_sdn = NULL;
int deleteoldrdn = 0;
@@ -139,8 +140,11 @@ acl_access_allowed_modrdn(
slapi_pblock_get( pb, SLAPI_MODRDN_TARGET_SDN, &target_sdn );
slapi_pblock_get( pb, SLAPI_MODRDN_NEWRDN, &newrdn );
+ ci_newrdn = slapi_ch_strdup(newrdn);
+ slapi_dn_ignore_case(ci_newrdn);
/* Check can add the new naming attribute */
- retCode = check_rdn_access( pb, e, newrdn, ACLPB_SLAPI_ACL_WRITE_ADD) ;
+ retCode = check_rdn_access( pb, e, ci_newrdn, ACLPB_SLAPI_ACL_WRITE_ADD) ;
+ slapi_ch_free_string(&ci_newrdn);
if ( retCode != LDAP_SUCCESS ) {
slapi_log_error( SLAPI_LOG_ACL, plugin_name,
"modrdn:write permission to add new naming attribute not allowed\n");
@@ -150,7 +154,7 @@ acl_access_allowed_modrdn(
/* Check can delete the new naming attribute--if required */
slapi_pblock_get( pb, SLAPI_MODRDN_DELOLDRDN, &deleteoldrdn );
if ( deleteoldrdn ) {
- oldrdn = slapi_sdn_get_dn(target_sdn);
+ oldrdn = slapi_sdn_get_ndn(target_sdn);
retCode = check_rdn_access( pb, e, oldrdn, ACLPB_SLAPI_ACL_WRITE_DEL) ;
if ( retCode != LDAP_SUCCESS ) {
slapi_log_error( SLAPI_LOG_ACL, plugin_name,
@@ -1793,8 +1797,10 @@ acl_modified (Slapi_PBlock *pb, int optype, char *n_dn, void *change)
/* Change the acls */
acllist_acicache_WRITE_LOCK();
+ /* acllist_moddn_aci_needsLock expects normalized new_DN,
+ * which is no need to be case-ignored */
acllist_moddn_aci_needsLock ( e_sdn, new_DN );
- acllist_acicache_WRITE_UNLOCK();
+ acllist_acicache_WRITE_UNLOCK();
/* deallocat the parent_DN */
if (parent_DN != NULL) {
@@ -1987,7 +1993,7 @@ acl__resource_match_aci( Acl_PBlock *aclpb, aci_t *aci, int skip_attrEval, int *
int rv; /* return value */
/* Assume that resource matches */
int matches = ACL_TRUE;
- int attr_matched;
+ int attr_matched = ACL_TRUE;
int attr_matched_in_targetattrfilters = 0;
int dn_matched;
char *res_attr;
@@ -2713,7 +2719,7 @@ acl__TestRights(Acl_PBlock *aclpb,int access, char **right, char ** map_generic,
char *acl_tag;
int expr_num;
char *testRights[2];
- aci_t *aci;
+ aci_t *aci = NULL;
int numHandles = 0;
TNF_PROBE_0_DEBUG(acl__TestRights_start,"ACL","");
diff --git a/ldap/servers/plugins/acl/acllist.c b/ldap/servers/plugins/acl/acllist.c
index 8eb39b9..9b5363a 100644
--- a/ldap/servers/plugins/acl/acllist.c
+++ b/ldap/servers/plugins/acl/acllist.c
@@ -889,7 +889,7 @@ acllist_acicache_WRITE_LOCK( )
}
/* This routine must be called with the acicache write lock taken */
-/* newdn is normalized & case-ignored */
+/* newdn is normalized (no need to be case-ignored) */
int
acllist_moddn_aci_needsLock ( Slapi_DN *oldsdn, char *newdn )
{
@@ -919,7 +919,7 @@ acllist_moddn_aci_needsLock ( Slapi_DN *oldsdn, char *newdn )
/* Now set the new DN */
slapi_sdn_done ( head->acic_sdn );
- slapi_sdn_set_ndn_byval ( head->acic_sdn, newdn );
+ slapi_sdn_set_normdn_byval ( head->acic_sdn, newdn );
aciListHead->acic_sdn = NULL;
__acllist_free_aciContainer ( &aciListHead );
diff --git a/ldap/servers/plugins/chainingdb/cb_add.c b/ldap/servers/plugins/chainingdb/cb_add.c
index 116ac92..07b90fa 100644
--- a/ldap/servers/plugins/chainingdb/cb_add.c
+++ b/ldap/servers/plugins/chainingdb/cb_add.c
@@ -69,7 +69,7 @@ chaining_back_add ( Slapi_PBlock *pb )
const char *dn = NULL;
Slapi_DN *sdn = NULL;
char *cnxerrbuf=NULL;
- time_t endtime;
+ time_t endtime = 0;
cb_outgoing_conn *cnx;
if ( (rc=cb_forward_operation(pb)) != LDAP_SUCCESS ) {
diff --git a/ldap/servers/plugins/chainingdb/cb_compare.c b/ldap/servers/plugins/chainingdb/cb_compare.c
index 16f6c7b..594c4bb 100644
--- a/ldap/servers/plugins/chainingdb/cb_compare.c
+++ b/ldap/servers/plugins/chainingdb/cb_compare.c
@@ -67,7 +67,7 @@ chaining_back_compare ( Slapi_PBlock *pb )
const char *dn = NULL;
Slapi_DN *sdn = NULL;
char *cnxerrbuf=NULL;
- time_t endtime;
+ time_t endtime = 0;
cb_outgoing_conn *cnx;
if ( LDAP_SUCCESS != (rc=cb_forward_operation(pb) )) {
diff --git a/ldap/servers/plugins/chainingdb/cb_delete.c b/ldap/servers/plugins/chainingdb/cb_delete.c
index 87a69a2..09972b2 100644
--- a/ldap/servers/plugins/chainingdb/cb_delete.c
+++ b/ldap/servers/plugins/chainingdb/cb_delete.c
@@ -66,7 +66,7 @@ chaining_back_delete ( Slapi_PBlock *pb )
Slapi_DN *sdn = NULL;
char *matched_msg, *error_msg;
char *cnxerrbuf=NULL;
- time_t endtime;
+ time_t endtime = 0;
cb_outgoing_conn *cnx;
if ( LDAP_SUCCESS != (rc=cb_forward_operation(pb) )) {
diff --git a/ldap/servers/plugins/chainingdb/cb_modify.c b/ldap/servers/plugins/chainingdb/cb_modify.c
index aa914b9..06e6b82 100644
--- a/ldap/servers/plugins/chainingdb/cb_modify.c
+++ b/ldap/servers/plugins/chainingdb/cb_modify.c
@@ -69,7 +69,7 @@ chaining_back_modify ( Slapi_PBlock *pb )
Slapi_DN *sdn = NULL;
char *matched_msg, *error_msg;
char *cnxerrbuf=NULL;
- time_t endtime;
+ time_t endtime = 0;
cb_outgoing_conn *cnx;
if ( LDAP_SUCCESS != (rc=cb_forward_operation(pb) )) {
diff --git a/ldap/servers/plugins/chainingdb/cb_modrdn.c b/ldap/servers/plugins/chainingdb/cb_modrdn.c
index b6b882b..1ce6c60 100644
--- a/ldap/servers/plugins/chainingdb/cb_modrdn.c
+++ b/ldap/servers/plugins/chainingdb/cb_modrdn.c
@@ -62,16 +62,13 @@ chaining_back_modrdn ( Slapi_PBlock *pb )
char **referrals=NULL;
LDAPMessage *res;
char *matched_msg, *error_msg;
- char *newdn = NULL;
- const char *pdn = NULL;
char *ndn = NULL;
Slapi_DN *sdn = NULL;
- Slapi_DN *psdn = NULL;
int deleteoldrdn = 0;
Slapi_DN *newsuperior = NULL;
char *newrdn = NULL;
char * cnxerrbuf=NULL;
- time_t endtime;
+ time_t endtime = 0;
cb_outgoing_conn *cnx;
if ( LDAP_SUCCESS != (rc=cb_forward_operation(pb) )) {
@@ -90,36 +87,13 @@ chaining_back_modrdn ( Slapi_PBlock *pb )
}
slapi_pblock_get( pb, SLAPI_MODRDN_TARGET_SDN, &sdn );
+ /* newrdn is passed to ldap_rename, which does not require case-ignored
+ * newrdn. */
slapi_pblock_get( pb, SLAPI_MODRDN_NEWRDN, &newrdn );
slapi_pblock_get( pb, SLAPI_MODRDN_NEWSUPERIOR_SDN, &newsuperior );
slapi_pblock_get( pb, SLAPI_MODRDN_DELOLDRDN, &deleteoldrdn );
ndn = (char *)slapi_sdn_get_ndn(sdn);
-
- /*
- * Construct the new dn
- */
- psdn = slapi_sdn_new();
- slapi_sdn_get_parent(sdn, psdn);
- pdn = slapi_sdn_get_ndn(psdn);
-
- if ( pdn ) {
- /* parent + rdn + separator(s) + null */
- newdn = slapi_ch_smprintf("%s,%s", newrdn, pdn);
- } else {
- newdn = slapi_ch_strdup( newrdn );
- }
- slapi_sdn_free(&psdn);
-
- /*
- * Make sure the current backend is managing
- * the new dn. We won't support moving entries
- * across backend this way.
- * Done in the front-end.
- */
-
- slapi_ch_free((void **)&newdn);
-
if (cb->local_acl && !cb->associated_be_is_disabled) {
/*
* Check local acls
diff --git a/ldap/servers/plugins/chainingdb/cb_search.c b/ldap/servers/plugins/chainingdb/cb_search.c
index 92eb2ea..a27e767 100644
--- a/ldap/servers/plugins/chainingdb/cb_search.c
+++ b/ldap/servers/plugins/chainingdb/cb_search.c
@@ -77,7 +77,7 @@ chainingdb_build_candidate_list ( Slapi_PBlock *pb )
char **referrals=NULL;
char *cnxerrbuf=NULL;
time_t endbefore=0;
- time_t endtime;
+ time_t endtime = 0;
cb_outgoing_conn *cnx;
slapi_pblock_get( pb, SLAPI_BACKEND, &be );
@@ -459,7 +459,7 @@ chainingdb_next_search_entry ( Slapi_PBlock *pb )
char **referrals=NULL;
cb_backend_instance * cb=NULL;
Slapi_Backend * be;
- time_t endtime;
+ time_t endtime = 0;
matched_msg=error_msg=NULL;
diff --git a/ldap/servers/plugins/referint/referint.c b/ldap/servers/plugins/referint/referint.c
index 195ff2b..4db5d6d 100644
--- a/ldap/servers/plugins/referint/referint.c
+++ b/ldap/servers/plugins/referint/referint.c
@@ -300,8 +300,7 @@ referint_postop_modrdn( Slapi_PBlock *pb )
}else if(delay == 0){
/* no delay */
/* call function to update references to entry */
- rc = update_integrity(argv, sdn, newrdn,
- newsuperior, logChanges, txn);
+ rc = update_integrity(argv, sdn, newrdn, newsuperior, logChanges, txn);
}else{
/* write the entry to integrity log */
writeintegritylog(argv[1], sdn, newrdn, newsuperior);
@@ -418,6 +417,7 @@ _update_one_per_mod(Slapi_DN *entrySDN, /* DN of the searched entry */
}
/* newRDN and superior are already normalized. */
newDN = slapi_ch_smprintf("%s,%s", newRDN, superior);
+ slapi_dn_ignore_case(newDN);
/*
* Compare the modified dn with the value of
* the target attribute of referint to find out
@@ -596,7 +596,9 @@ _update_all_per_mod(Slapi_DN *entrySDN, /* DN of the searched entry */
/* no need to free superior */
superior = slapi_dn_find_parent(origDN);
}
+ /* newRDN and superior are already normalized. */
newDN = slapi_ch_smprintf("%s,%s", newRDN, superior);
+ slapi_dn_ignore_case(newDN);
/*
* Compare the modified dn with the value of
* the target attribute of referint to find out
diff --git a/ldap/servers/plugins/uiduniq/7bit.c b/ldap/servers/plugins/uiduniq/7bit.c
index 3e0b921..3509044 100644
--- a/ldap/servers/plugins/uiduniq/7bit.c
+++ b/ldap/servers/plugins/uiduniq/7bit.c
@@ -606,8 +606,8 @@ preop_modrdn(Slapi_PBlock *pb)
/* NOTE: strdup on the rdn, since it will be freed when
* the entry is freed */
-
- slapi_entry_set_dn(e, slapi_ch_strdup(rdn));
+ /* slapi_entry_set_normdn expects rdn normalized, but not decapitalized */
+ slapi_entry_set_normdn(e, slapi_ch_strdup(rdn));
err = slapi_entry_add_rdn_values(e);
if (err)
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
index 4eba4ed..c602a1c 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
@@ -497,7 +497,8 @@ entryrdn_rename_subtree(backend *be,
if (newsrdn && slapi_rdn_get_rdn(newsrdn)) {
/* if the new RDN value is identical to the old RDN,
* we don't have to do "rename" */
- if (strcmp(slapi_rdn_get_nrdn(newsrdn), slapi_rdn_get_nrdn(&oldsrdn))) {
+ /* Don't miss the case changes, too. */
+ if (strcmp(slapi_rdn_get_rdn(newsrdn), slapi_rdn_get_rdn(&oldsrdn))) {
/* did not match; let's rename it */
mynewsrdn = newsrdn;
}
diff --git a/ldap/servers/slapd/modrdn.c b/ldap/servers/slapd/modrdn.c
index a7bb1a6..c270ed5 100644
--- a/ldap/servers/slapd/modrdn.c
+++ b/ldap/servers/slapd/modrdn.c
@@ -191,7 +191,6 @@ do_modrdn( Slapi_PBlock *pb )
slapi_ch_free_string( &rawnewsuperior );
goto free_and_return;
}
- slapi_dn_ignore_case( newrdn );
slapi_ch_free_string( &rawnewrdn );
if (rawnewsuperior) {
@@ -218,6 +217,8 @@ do_modrdn( Slapi_PBlock *pb )
*/
parent = slapi_dn_parent(slapi_sdn_get_ndn(&sdn));
newdn = slapi_ch_smprintf("%s,%s", newrdn, parent);
+ /* slapi_sdn_init_normdn_passin expects normalized but NOT
+ * decapitalized dn */
slapi_sdn_init_normdn_passin(&snewdn, newdn); /* newdn is normalized */
if (0 == slapi_sdn_compare(&sdn, snewsuperior) ||
0 == slapi_sdn_compare(&snewdn, snewsuperior)) {
@@ -560,6 +561,7 @@ op_shared_rename(Slapi_PBlock *pb, int passin_args)
}
/* check if created attributes are used in the new RDN */
+ /* check_rdn_for_created_attrs ignores the cases */
if (check_rdn_for_created_attrs((const char *)newrdn)) {
send_ldap_result(pb, LDAP_INVALID_DN_SYNTAX, NULL, "invalid attribute in RDN", 0, NULL);
goto free_and_return_nolock;
@@ -607,6 +609,8 @@ op_shared_rename(Slapi_PBlock *pb, int passin_args)
* appropriate one, or send a referral to our "referral server"
* if we don't hold it.
*/
+ /* slapi_mapping_tree_select_and_check ignores the case of newdn
+ * which is generated using newrdn above. */
if ((err = slapi_mapping_tree_select_and_check(pb, newdn, &be, &referral, errorbuf)) != LDAP_SUCCESS)
{
send_ldap_result(pb, err, NULL, errorbuf, 0, NULL);
@@ -707,6 +711,7 @@ free_and_return_nolock:
} else {
slapi_pblock_get(pb, SLAPI_MODRDN_TARGET_SDN, &sdn);
slapi_sdn_free(&sdn);
+ /* get newrdn to free the string */
slapi_pblock_get(pb, SLAPI_MODRDN_NEWRDN, &newrdn);
slapi_ch_free_string(&newrdn);
slapi_pblock_get(pb, SLAPI_MODRDN_NEWSUPERIOR_SDN, &newsuperiorsdn);
11 years, 11 months
Changes to 'private-ticket-359-rhel-6.3'
by Noriko Hosoi
New branch 'private-ticket-359-rhel-6.3' available with the following commits:
commit f92f3a6e91498770aa8e93b6842ba752d4ed279a
Author: Noriko Hosoi <nhosoi(a)totoro.usersys.redhat.com>
Date: Wed May 9 15:39:17 2012 -0700
Trac Ticket #359 - Database RUV could mismatch the one
in changelog under the stress
https://fedorahosted.org/389/ticket/359
Fix description:
. csnplRollUp (csnpl.c) - To get the first committed csndata, if
there are preceded uncommitted csn's in the csnpl list, this
patch skips them and returns the first committed csn.
. llistRemoveCurrentAndGetNext (llist.c) - when the last item
in the list is removed, tail pointer is initialized, too.
. ldbm_back_add, ldbm_back_modrdn (ldbm_add.c, ldbm_modrdn.c) -
make sure SLAPI_RESULT_CODE and SLAPI_PLUGIN_OPRETURN are set
not just when the transaction is started, but in general.
If an error occurs the RESULT_CODE triggers to remove the CSN
from the RUV element.
. plugin_call_func (plugin.c) - when the plugin type is be pre/
post op, respect the fatal error code (-1) instead of OR the
results from all the plugins. The error code -1 is checked
in ldap_back_add and ldbm_back_modrdn to distinguish from the
URP operation bits.
Ported commit f0f74b57f81998a325dc7472b9ea9b44c5ff6439.
(cherry picked from commit ed1ebf66451a16144563d2d3d636fee6451009a4)
commit 409a85203e2185bb69e76532831386103204a41f
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Thu May 3 08:21:53 2012 -0600
Ticket #348 - crash in ldap_initialize with multiple threads
https://fedorahosted.org/389/ticket/348
Resolves: Ticket #348
Bug Description: crash in ldap_initialize with multiple threads
Reviewed by: mreynolds (Thanks!)
Branch: rhel-6.3
Fix Description: ldclt was not calling PR_Init - needed in order to use
PR_CallOnce
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 9368250f2db4353cec7b489cb48c9c1f192f5c90)
commit feff1524c2864e1dcb347218597f74bdd1b96fcb
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Tue Apr 24 20:09:38 2012 -0600
Ticket #348 - crash in ldap_initialize with multiple threads
https://fedorahosted.org/389/ticket/348
Resolves: Ticket #348
Bug Description: crash in ldap_initialize with multiple threads
Reviewed by: mreynolds (Thanks!)
Branch: master
Fix Description: Protect calls to ldap_initialize() with a mutex to prevent
multiple threads from calling it at the same time.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 23c088919f66de014ee7f9aad407468e51451405)
(cherry picked from commit 3f73fa545d6e0edb9b4620be057e564ee5067276)
commit 47b11e178ef21b61712462795c154f57210873e0
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Fri Apr 20 20:15:21 2012 -0600
Ticket #347 - IPA dirsvr seg-fault during system longevity test
https://fedorahosted.org/389/ticket/347
Resolves: Ticket 347
Bug Description: IPA dirsvr seg-fault during system longevity test
Reviewed by: nhosoi, mreynolds (Thanks!)
Branch: rhel-6.3
Fix Description: Somehow the DB_MULTIPLE_NEXT pointer is being set to
an invalid value (-5). This causes the next iteration to return memory
that points to before the stack buffer, causing a seg fault. Valid
values for the pointer are > -1. The value -1 is used as the list terminator
value. The code that constructs the buffer is in the libdb function
__bam_bulk in bt_cursor.c. The fix is to check for a value < -1,
assume the page or value has been deleted out from under us, and do
a dbc->get to get the next buffer full, if any. The code also needs to
check for duplicate IDs being returned. In the failure case described
above, it is possible that the last ID returned in the multiple buffer is
the first ID in the next buffer. In that case, we want to skip the ID that
was already added to the IDL.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 5d45dd8de06aaee3e0a52c85fa5b3e18febd7a27)
commit 1442b8dfe240f6abb9d0e5b582fc2b7e883425dd
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Tue Apr 10 13:49:26 2012 -0600
Ticket #336 - [abrt] 389-ds-base-1.2.10.4-2.fc16: index_range_read_ext: Process /usr/sbin/ns-slapd was killed by signal 11 (SIGSEGV)
https://fedorahosted.org/389/ticket/336
Resolves: Ticket #336
Bug Description: [abrt] 389-ds-base-1.2.10.4-2.fc16: index_range_read_ext: Process /usr/sbin/ns-slapd was killed by signal 11 (SIGSEGV)
Reviewed by: nhosoi (Thanks!)
Branch: rhel-6.3
Fix Description: previous fix had a typo and failed index tests
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
BZ: 808770
(cherry picked from commit a50f8c048801dfa50b692055aa7eabd7486a0051)
(cherry picked from commit 182ab2e0229fc3bd66b6c0301a9c564f5afcac68)
commit e373134642dd23848c50be56f173b8bd34c03c4d
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Sat Apr 7 09:05:18 2012 -0600
Ticket #336 - [abrt] 389-ds-base-1.2.10.4-2.fc16: index_range_read_ext: Process /usr/sbin/ns-slapd was killed by signal 11 (SIGSEGV)
https://fedorahosted.org/389/ticket/336
Resolves: Ticket #336
Bug Description: [abrt] 389-ds-base-1.2.10.4-2.fc16: index_range_read_ext: Process /usr/sbin/ns-slapd was killed by signal 11 (SIGSEGV)
Reviewed by: nhosoi (Thanks!)
Branch: rhel-6.3
Fix Description:
1) Entries can be deleted out from under a search operation. The range read
code was not handling this situation correctly. The code should notice that
the index query was empty, and continue to the next highest key in the range.
2) DB cursor c_close() functions can return DB_LOCK_DEADLOCK that must be
reported to the higher level operation functions. If not, then subsequent
operations in the same transaction fail. When a DB_LOCK_DEADLOCK is returned
by any DB update operation in the transaction, the transaction must be aborted
and a new transaction begun before any other transacted db operations can
occur.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
BZ: 808770
(cherry picked from commit d09ce0e3ab2ea24496ee44622b050e007bb3cb8a)
(cherry picked from commit a2fb904458713b493e3b84bafa1771675d1bced9)
commit 4dae58f116cb0541f4d0a8ffc4a4947fce51d12e
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Sat Apr 7 09:05:18 2012 -0600
Bug 808770 - [abrt] 389-ds-base-1.2.10.4-2.fc16: index_range_read_ext: Process /usr/sbin/ns-slapd was killed by signal 11 (SIGSEGV)
https://bugzilla.redhat.com/show_bug.cgi?id=808770
Resolves: bug 808770
Bug Description: [abrt] 389-ds-base-1.2.10.4-2.fc16: index_range_read_ext: Process /usr/sbin/ns-slapd was killed by signal 11 (SIGSEGV)
Reviewed by: ???
Branch: rhel-6.3
Fix Description:
1) Entries can be deleted out from under a search operation. The range read
code was not handling this situation correctly. The code should notice that
the index query was empty, and continue to the next highest key in the range.
2) DB cursor c_close() functions can return DB_LOCK_DEADLOCK that must be
reported to the higher level operation functions. If not, then subsequent
operations in the same transaction fail. When a DB_LOCK_DEADLOCK is returned
by any DB update operation in the transaction, the transaction must be aborted
and a new transaction begun before any other transacted db operations can
occur.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit dcb46ca16114e51108c1a0549235af5623f7596b)
commit 0af193c3a5c5bac9b77b933de3ba6fc96c310b3f
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Tue Mar 13 11:45:32 2012 -0600
Ticket #305 - Certain CMP operations hang or cause ns-slapd to crash
https://fedorahosted.org/389/ticket/305
Resolves: Ticket #305
Bug Description: Certain CMP operations hang or cause ns-slapd to crash
Reviewed by: nkinder, nhosoi (Thanks!)
Branch: rhel-6.3
Fix Description: This addresses the hang part, which I incorrectly assumed
was related to the crash part. The code using vattr_map_sp_next() was causing
an infinite loop (and hang) by passing the list head every time rather than
the previous next pointer.
In addition, LDAP compare operations were not working if a vattr service
provider was in effect for an attribute, and there was a real value for
the attribute in the entry. The rc code was being set to -1 to indicate
no vattr service providers provided the value, but it was not being reset
to 0 when the value was found in the actual entry. The fix is to reset
rc to 0 (success) and *result to 0 (compare false) when testing the real
attribute.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 55135e37a9e330f084ab7d254306cbf155526b25)
(cherry picked from commit f00c678e36c138a7991b6c3c4780d40af30dc7c4)
commit 48776fe36afe559ee21cd450154805a2f30ee1de
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Thu Mar 1 18:50:05 2012 -0700
memleak in normalize_mods2bvals
do not re malloc the berval again - only need to do it once
Reviewed by: nhosoi (Thanks!)
(cherry picked from commit f6e4d3d0d4313ef9b4396ab8433a1c260989274b)
(cherry picked from commit b05139ba374e947fad681d6c97af5dc3800c4bda)
commit 5d1a743db2ecbe93d7c5892be2912997f5a1b78e
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Thu Mar 1 18:47:34 2012 -0700
memleak in mep_parse_config_entry
pass in value to slapi_sdn_new_dn_passin() so that entry->template_sdn
will own the memory
Reviewed by: nhosoi (Thanks!)
(cherry picked from commit 54fbe0b3b3669a0379a4b0a50769b4855539c225)
(cherry picked from commit c0eea24cb59f234903839604dd1be521897c3c58)
commit d7e36b3dd5f023aa209109c8974dffc0d07e7542
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Wed Feb 29 17:27:32 2012 -0700
handle null smods
Under certain error conditions, smods will be NULL at the end of the function.
Do not call passout if smods is NULL.
Reviewed by: nhosoi (Thanks!)
(cherry picked from commit afd6b1fd63c48642dd050e0e821b3d7c69fc4991)
(cherry picked from commit 90bc9eb924e373f38ad1a8ccd25aecd74a2799e0)
commit 86045935a2f9ef3dd3d727cad9b468d7398393d5
Author: Mark Reynolds <mareynol(a)redhat.com>
Date: Fri Mar 2 11:51:58 2012 -0500
Ticket #305 - Certain CMP operations hang or cause ns-slapd to crash
Bug Description: There is a potential double free in cos_cache_query_attr(). If you
run concurrent search or compares its very easy to crash the
server in this code
Fix Description: Moved the DN normalization into the cache rebuilding code.
https://fedorahosted.org/389/ticket/305
(cherry picked from commit 142c8f0fe93d77990df8ce991a8020918276ddd8)
(cherry picked from commit b9ab70a3594830daed65035031520f6d310b2540)
11 years, 11 months
Branch '389-ds-base-1.2.11' - 2 commits - ldap/servers
by Noriko Hosoi
ldap/servers/plugins/replication/cl5_api.c | 6 ++---
ldap/servers/plugins/replication/csnpl.c | 23 +++++++++++---------
ldap/servers/plugins/replication/llist.c | 8 +++++--
ldap/servers/plugins/replication/repl_extop.c | 2 -
ldap/servers/plugins/usn/usn.c | 4 ++-
ldap/servers/slapd/back-ldbm/ldbm_add.c | 29 +++++++++++++-------------
ldap/servers/slapd/back-ldbm/ldbm_modrdn.c | 29 +++++++++++++-------------
ldap/servers/slapd/plugin.c | 10 +++++++-
8 files changed, 64 insertions(+), 47 deletions(-)
New commits:
commit c89ea2f6b9aebeb8d2190ef9e4d1eee78bd63f06
Author: Noriko Hosoi <nhosoi(a)totoro.usersys.redhat.com>
Date: Wed May 9 15:51:58 2012 -0700
Trac Ticket #359 - Database RUV could mismatch the one
in changelog under the stress
https://fedorahosted.org/389/ticket/359
Fix description:
. csnplRollUp (csnpl.c) - To get the first committed csndata, if
there are preceded uncommitted csn's in the csnpl list, this
patch skips them and returns the first committed csn.
. llistRemoveCurrentAndGetNext (llist.c) - when the last item
in the list is removed, tail pointer is initialized, too.
. ldbm_back_add, ldbm_back_modrdn (ldbm_add.c, ldbm_modrdn.c) -
make sure SLAPI_RESULT_CODE and SLAPI_PLUGIN_OPRETURN are set
not just when the transaction is started, but in general.
If an error occurs the RESULT_CODE triggers to remove the CSN
from the RUV element.
. plugin_call_func (plugin.c) - when the plugin type is be pre/
post op, respect the fatal error code (-1) instead of OR the
results from all the plugins. The error code -1 is checked
in ldap_back_add and ldbm_back_modrdn to distinguish from the
URP operation bits.
(cherry-picked from commit f0f74b57f81998a325dc7472b9ea9b44c5ff6439)
diff --git a/ldap/servers/plugins/replication/csnpl.c b/ldap/servers/plugins/replication/csnpl.c
index 62f4fc4..16cebf1 100644
--- a/ldap/servers/plugins/replication/csnpl.c
+++ b/ldap/servers/plugins/replication/csnpl.c
@@ -298,28 +298,31 @@ csnplRollUp(CSNPL *csnpl, CSN **first_commited)
CSN *largest_committed_csn = NULL;
csnpldata *data;
PRBool freeit = PR_TRUE;
+ void *iterator;
slapi_rwlock_wrlock (csnpl->csnLock);
if (first_commited) {
/* Avoid non-initialization issues due to careless callers */
*first_commited = NULL;
}
- data = (csnpldata *)llistGetHead(csnpl->csnList);
- while (NULL != data && data->committed)
+ data = (csnpldata *)llistGetFirst(csnpl->csnList, &iterator);
+ while (NULL != data)
{
if (NULL != largest_committed_csn && freeit)
{
csn_free(&largest_committed_csn);
}
- freeit = PR_TRUE;
- largest_committed_csn = data->csn; /* Save it */
- if (first_commited && (*first_commited == NULL)) {
- *first_commited = data->csn;
- freeit = PR_FALSE;
+ if (data->committed) {
+ freeit = PR_TRUE;
+ largest_committed_csn = data->csn; /* Save it */
+ if (first_commited && (*first_commited == NULL)) {
+ *first_commited = data->csn;
+ freeit = PR_FALSE;
+ }
+ data = (csnpldata *)llistRemoveCurrentAndGetNext(csnpl->csnList, &iterator);
+ } else {
+ data = (csnpldata *)llistGetNext (csnpl->csnList, &iterator);
}
- data = (csnpldata*)llistRemoveHead (csnpl->csnList);
- slapi_ch_free((void **)&data);
- data = (csnpldata *)llistGetHead(csnpl->csnList);
}
#ifdef DEBUG
diff --git a/ldap/servers/plugins/replication/llist.c b/ldap/servers/plugins/replication/llist.c
index bd0bc1d..e80f532 100644
--- a/ldap/servers/plugins/replication/llist.c
+++ b/ldap/servers/plugins/replication/llist.c
@@ -167,10 +167,14 @@ void* llistRemoveCurrentAndGetNext (LList *list, void **iterator)
prevNode->next = node->next;
_llistDestroyNode (&node, NULL);
node = prevNode->next;
- if (node)
+ if (node) {
return node->data;
- else
+ } else {
+ if (list->head->next == NULL) {
+ list->tail = NULL;
+ }
return NULL;
+ }
}
else
return NULL;
diff --git a/ldap/servers/plugins/usn/usn.c b/ldap/servers/plugins/usn/usn.c
index 0d8a065..812d83d 100644
--- a/ldap/servers/plugins/usn/usn.c
+++ b/ldap/servers/plugins/usn/usn.c
@@ -501,6 +501,7 @@ bail:
/*
* usn_bepreop_modify - add/replace next USN to the mods;
* shared by modify and modrdn
+ * Note: bepreop should not return other than LDAP_SUCCESS.
*/
static int
usn_bepreop_modify (Slapi_PBlock *pb)
@@ -516,7 +517,8 @@ usn_bepreop_modify (Slapi_PBlock *pb)
slapi_pblock_get(pb, SLAPI_MODIFY_MODS, &mods);
slapi_pblock_get(pb, SLAPI_BACKEND, &be);
if (NULL == be) {
- rc = LDAP_PARAM_ERROR;
+ slapi_log_error(SLAPI_LOG_FATAL, USN_PLUGIN_SUBSYSTEM,
+ "usn_bepreop_modify: no backend.\n");
goto bail;
}
if (LDAP_SUCCESS == _usn_mod_next_usn(&mods, be)) {
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c b/ldap/servers/slapd/back-ldbm/ldbm_add.c
index 1539c7c..fc7ed80 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_add.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c
@@ -117,6 +117,7 @@ ldbm_back_add( Slapi_PBlock *pb )
int is_ruv = 0; /* True if the current entry is RUV */
CSN *opcsn = NULL;
entry_address addr = {0};
+ int val = 0;
slapi_pblock_get( pb, SLAPI_PLUGIN_PRIVATE, &li );
slapi_pblock_get( pb, SLAPI_ADD_ENTRY, &e );
@@ -1043,26 +1044,26 @@ error_return:
disk_full = 1;
}
+ /* make sure SLAPI_RESULT_CODE and SLAPI_PLUGIN_OPRETURN are set */
+ slapi_pblock_get(pb, SLAPI_RESULT_CODE, &val);
+ if (!val) {
+ if (!ldap_result_code) {
+ ldap_result_code = LDAP_OPERATIONS_ERROR;
+ }
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code);
+ }
+ slapi_pblock_get( pb, SLAPI_PLUGIN_OPRETURN, &val );
+ if (!val) {
+ val = -1;
+ slapi_pblock_set( pb, SLAPI_PLUGIN_OPRETURN, &val );
+ }
+
diskfull_return:
if (disk_full) {
rc= return_on_disk_full(li);
} else {
/* It is safer not to abort when the transaction is not started. */
if (txn.back_txn_txn && (txn.back_txn_txn != parent_txn)) {
- /* make sure SLAPI_RESULT_CODE and SLAPI_PLUGIN_OPRETURN are set */
- int val = 0;
- slapi_pblock_get(pb, SLAPI_RESULT_CODE, &val);
- if (!val) {
- if (!ldap_result_code) {
- ldap_result_code = LDAP_OPERATIONS_ERROR;
- }
- slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code);
- }
- slapi_pblock_get( pb, SLAPI_PLUGIN_OPRETURN, &val );
- if (!val) {
- val = -1;
- slapi_pblock_set( pb, SLAPI_PLUGIN_OPRETURN, &val );
- }
/* call the transaction post add plugins just before the abort */
if ((retval = plugin_call_plugins(pb, SLAPI_PLUGIN_BE_TXN_POST_ADD_FN))) {
int opreturn = 0;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
index b3d8111..2e180f2 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
@@ -120,6 +120,7 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
const char *newdn = NULL;
char *newrdn = NULL;
int opreturn = 0;
+ int val = 0;
/* sdn & parentsdn need to be initialized before "goto *_return" */
slapi_sdn_init(&dn_newdn);
@@ -1198,6 +1199,20 @@ error_return:
disk_full = 1;
}
+ /* make sure SLAPI_RESULT_CODE and SLAPI_PLUGIN_OPRETURN are set */
+ slapi_pblock_get(pb, SLAPI_RESULT_CODE, &val);
+ if (!val) {
+ if (!ldap_result_code) {
+ ldap_result_code = LDAP_OPERATIONS_ERROR;
+ }
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code);
+ }
+ slapi_pblock_get( pb, SLAPI_PLUGIN_OPRETURN, &val );
+ if (!val) {
+ opreturn = -1;
+ slapi_pblock_set( pb, SLAPI_PLUGIN_OPRETURN, &opreturn );
+ }
+
if (disk_full)
{
retval = return_on_disk_full(li);
@@ -1207,20 +1222,6 @@ error_return:
/* It is safer not to abort when the transaction is not started. */
if (txn.back_txn_txn && (txn.back_txn_txn != parent_txn))
{
- /* make sure SLAPI_RESULT_CODE and SLAPI_PLUGIN_OPRETURN are set */
- int val = 0;
- slapi_pblock_get(pb, SLAPI_RESULT_CODE, &val);
- if (!val) {
- if (!ldap_result_code) {
- ldap_result_code = LDAP_OPERATIONS_ERROR;
- }
- slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code);
- }
- slapi_pblock_get( pb, SLAPI_PLUGIN_OPRETURN, &val );
- if (!val) {
- opreturn = -1;
- slapi_pblock_set( pb, SLAPI_PLUGIN_OPRETURN, &opreturn );
- }
/* call the transaction post modrdn plugins just before the commit */
if ((retval = plugin_call_plugins(pb, SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN))) {
LDAPDebug1Arg( LDAP_DEBUG_TRACE, "SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN plugin "
diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c
index 1585779..8aa95ac 100644
--- a/ldap/servers/slapd/plugin.c
+++ b/ldap/servers/slapd/plugin.c
@@ -1466,8 +1466,14 @@ plugin_call_func (struct slapdplugin *list, int operation, Slapi_PBlock *pb, int
} else if (SLAPI_PLUGIN_BEPREOPERATION == list->plg_type ||
SLAPI_PLUGIN_BEPOSTOPERATION == list->plg_type)
{
- /* OR the result into the return value for be pre/postops */
- return_value |= rc;
+ /* respect fatal error (-1); should not OR it */
+ if (-1 == rc) {
+ return_value = rc;
+ } else if (-1 != return_value) {
+ /* OR the result into the return value
+ * for be pre/postops */
+ return_value |= rc;
+ }
}
}
/* counters_to_errors_log("after plugin call"); */
commit da3f9226ca20ab6b9c71ea75080e6f0be9220de6
Author: Mark Reynolds <mareynol(a)redhat.com>
Date: Wed May 9 15:29:51 2012 -0400
Ticket #337 - Improve CLEANRUV task
Bug Description: After restarting a replica, regardless if it was cleaned, would trigger
ruv_compare_ruv errors at startup.
Fix Description: There were simple typos in the fix when checking if the rid was already cleaned.
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index 2819511..eac76a8 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -3899,7 +3899,7 @@ static int _cl5UpdateRUV (Object *obj, CSN *csn, PRBool newReplica, PRBool purge
{
if (ruv_contains_replica (file->purgeRUV, rid))
return CL5_SUCCESS;
- else if(is_cleaned_rid(rid))
+ else if(!is_cleaned_rid(rid))
{
/* if the replica is not part of the purgeRUV yet, add it unless it's from a cleaned rid */
ruv_add_replica (file->purgeRUV, rid, multimaster_get_local_purl());
@@ -3909,8 +3909,8 @@ static int _cl5UpdateRUV (Object *obj, CSN *csn, PRBool newReplica, PRBool purge
{
if (purge)
rc = ruv_set_csns(file->purgeRUV, csn, NULL);
- else if(is_cleaned_rid(rid)){
- /* don't update maxRuv is if rid is cleaned */
+ else if(!is_cleaned_rid(rid)){
+ /* don't update maxRuv if rid is cleaned */
rc = ruv_set_csns(file->maxRUV, csn, NULL);
}
}
diff --git a/ldap/servers/plugins/replication/repl_extop.c b/ldap/servers/plugins/replication/repl_extop.c
index 31a9ad0..e4abde0 100644
--- a/ldap/servers/plugins/replication/repl_extop.c
+++ b/ldap/servers/plugins/replication/repl_extop.c
@@ -1546,7 +1546,7 @@ multimaster_extop_releaseruv(Slapi_PBlock *pb){
char *iter;
int send_msgid = 0;
int rid = 0;
- int rc = -1;
+ int rc = 0;
slapi_pblock_get(pb, SLAPI_EXT_OP_REQ_OID, &extop_oid);
slapi_pblock_get(pb, SLAPI_EXT_OP_REQ_VALUE, &extop_value);
11 years, 11 months
Branch '389-ds-base-1.2.10' - ldap/servers
by Noriko Hosoi
ldap/servers/plugins/replication/csnpl.c | 23 +++++++++++++----------
ldap/servers/plugins/replication/llist.c | 8 ++++++--
ldap/servers/plugins/usn/usn.c | 4 +++-
ldap/servers/slapd/back-ldbm/ldbm_add.c | 15 +++++++++++++++
ldap/servers/slapd/back-ldbm/ldbm_modrdn.c | 15 +++++++++++++++
ldap/servers/slapd/plugin.c | 10 ++++++++--
6 files changed, 60 insertions(+), 15 deletions(-)
New commits:
commit ed1ebf66451a16144563d2d3d636fee6451009a4
Author: Noriko Hosoi <nhosoi(a)totoro.usersys.redhat.com>
Date: Wed May 9 15:39:17 2012 -0700
Trac Ticket #359 - Database RUV could mismatch the one
in changelog under the stress
https://fedorahosted.org/389/ticket/359
Fix description:
. csnplRollUp (csnpl.c) - To get the first committed csndata, if
there are preceded uncommitted csn's in the csnpl list, this
patch skips them and returns the first committed csn.
. llistRemoveCurrentAndGetNext (llist.c) - when the last item
in the list is removed, tail pointer is initialized, too.
. ldbm_back_add, ldbm_back_modrdn (ldbm_add.c, ldbm_modrdn.c) -
make sure SLAPI_RESULT_CODE and SLAPI_PLUGIN_OPRETURN are set
not just when the transaction is started, but in general.
If an error occurs the RESULT_CODE triggers to remove the CSN
from the RUV element.
. plugin_call_func (plugin.c) - when the plugin type is be pre/
post op, respect the fatal error code (-1) instead of OR the
results from all the plugins. The error code -1 is checked
in ldap_back_add and ldbm_back_modrdn to distinguish from the
URP operation bits.
Ported commit f0f74b57f81998a325dc7472b9ea9b44c5ff6439.
diff --git a/ldap/servers/plugins/replication/csnpl.c b/ldap/servers/plugins/replication/csnpl.c
index 62f4fc4..16cebf1 100644
--- a/ldap/servers/plugins/replication/csnpl.c
+++ b/ldap/servers/plugins/replication/csnpl.c
@@ -298,28 +298,31 @@ csnplRollUp(CSNPL *csnpl, CSN **first_commited)
CSN *largest_committed_csn = NULL;
csnpldata *data;
PRBool freeit = PR_TRUE;
+ void *iterator;
slapi_rwlock_wrlock (csnpl->csnLock);
if (first_commited) {
/* Avoid non-initialization issues due to careless callers */
*first_commited = NULL;
}
- data = (csnpldata *)llistGetHead(csnpl->csnList);
- while (NULL != data && data->committed)
+ data = (csnpldata *)llistGetFirst(csnpl->csnList, &iterator);
+ while (NULL != data)
{
if (NULL != largest_committed_csn && freeit)
{
csn_free(&largest_committed_csn);
}
- freeit = PR_TRUE;
- largest_committed_csn = data->csn; /* Save it */
- if (first_commited && (*first_commited == NULL)) {
- *first_commited = data->csn;
- freeit = PR_FALSE;
+ if (data->committed) {
+ freeit = PR_TRUE;
+ largest_committed_csn = data->csn; /* Save it */
+ if (first_commited && (*first_commited == NULL)) {
+ *first_commited = data->csn;
+ freeit = PR_FALSE;
+ }
+ data = (csnpldata *)llistRemoveCurrentAndGetNext(csnpl->csnList, &iterator);
+ } else {
+ data = (csnpldata *)llistGetNext (csnpl->csnList, &iterator);
}
- data = (csnpldata*)llistRemoveHead (csnpl->csnList);
- slapi_ch_free((void **)&data);
- data = (csnpldata *)llistGetHead(csnpl->csnList);
}
#ifdef DEBUG
diff --git a/ldap/servers/plugins/replication/llist.c b/ldap/servers/plugins/replication/llist.c
index bd0bc1d..e80f532 100644
--- a/ldap/servers/plugins/replication/llist.c
+++ b/ldap/servers/plugins/replication/llist.c
@@ -167,10 +167,14 @@ void* llistRemoveCurrentAndGetNext (LList *list, void **iterator)
prevNode->next = node->next;
_llistDestroyNode (&node, NULL);
node = prevNode->next;
- if (node)
+ if (node) {
return node->data;
- else
+ } else {
+ if (list->head->next == NULL) {
+ list->tail = NULL;
+ }
return NULL;
+ }
}
else
return NULL;
diff --git a/ldap/servers/plugins/usn/usn.c b/ldap/servers/plugins/usn/usn.c
index faa737c..c8672d5 100644
--- a/ldap/servers/plugins/usn/usn.c
+++ b/ldap/servers/plugins/usn/usn.c
@@ -455,6 +455,7 @@ bail:
/*
* usn_bepreop_modify - add/replace next USN to the mods;
* shared by modify and modrdn
+ * Note: bepreop should not return other than LDAP_SUCCESS.
*/
static int
usn_bepreop_modify (Slapi_PBlock *pb)
@@ -470,7 +471,8 @@ usn_bepreop_modify (Slapi_PBlock *pb)
slapi_pblock_get(pb, SLAPI_MODIFY_MODS, &mods);
slapi_pblock_get(pb, SLAPI_BACKEND, &be);
if (NULL == be) {
- rc = LDAP_PARAM_ERROR;
+ slapi_log_error(SLAPI_LOG_FATAL, USN_PLUGIN_SUBSYSTEM,
+ "usn_bepreop_modify: no backend.\n");
goto bail;
}
if (LDAP_SUCCESS == _usn_mod_next_usn(&mods, be)) {
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c b/ldap/servers/slapd/back-ldbm/ldbm_add.c
index df09c64..132b125 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_add.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c
@@ -116,6 +116,7 @@ ldbm_back_add( Slapi_PBlock *pb )
int is_ruv = 0; /* True if the current entry is RUV */
CSN *opcsn = NULL;
entry_address addr = {0};
+ int val = 0;
slapi_pblock_get( pb, SLAPI_PLUGIN_PRIVATE, &li );
slapi_pblock_get( pb, SLAPI_ADD_ENTRY, &e );
@@ -964,6 +965,20 @@ error_return:
disk_full = 1;
}
+ /* make sure SLAPI_RESULT_CODE and SLAPI_PLUGIN_OPRETURN are set */
+ slapi_pblock_get(pb, SLAPI_RESULT_CODE, &val);
+ if (!val) {
+ if (!ldap_result_code) {
+ ldap_result_code = LDAP_OPERATIONS_ERROR;
+ }
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code);
+ }
+ slapi_pblock_get( pb, SLAPI_PLUGIN_OPRETURN, &val );
+ if (!val) {
+ val = -1;
+ slapi_pblock_set( pb, SLAPI_PLUGIN_OPRETURN, &val );
+ }
+
diskfull_return:
if (disk_full) {
rc= return_on_disk_full(li);
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
index 6b0fa34..0b56219 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
@@ -111,6 +111,7 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
entry_address *newsuperior_addr;
char ebuf[BUFSIZ];
CSN *opcsn = NULL;
+ int val = 0;
/* sdn & parentsdn need to be initialized before "goto *_return" */
slapi_sdn_init(&dn_newdn);
@@ -1065,6 +1066,20 @@ error_return:
disk_full = 1;
}
+ /* make sure SLAPI_RESULT_CODE and SLAPI_PLUGIN_OPRETURN are set */
+ slapi_pblock_get(pb, SLAPI_RESULT_CODE, &val);
+ if (!val) {
+ if (!ldap_result_code) {
+ ldap_result_code = LDAP_OPERATIONS_ERROR;
+ }
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code);
+ }
+ slapi_pblock_get(pb, SLAPI_PLUGIN_OPRETURN, &val);
+ if (!val) {
+ val = -1;
+ slapi_pblock_set(pb, SLAPI_PLUGIN_OPRETURN, &val);
+ }
+
if (disk_full)
{
retval = return_on_disk_full(li);
diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c
index 4c8e8bd..070ce54 100644
--- a/ldap/servers/slapd/plugin.c
+++ b/ldap/servers/slapd/plugin.c
@@ -1465,8 +1465,14 @@ plugin_call_func (struct slapdplugin *list, int operation, Slapi_PBlock *pb, int
} else if (SLAPI_PLUGIN_BEPREOPERATION == list->plg_type ||
SLAPI_PLUGIN_BEPOSTOPERATION == list->plg_type)
{
- /* OR the result into the return value for be pre/postops */
- return_value |= rc;
+ /* respect fatal error (-1); should not OR it */
+ if (-1 == rc) {
+ return_value = rc;
+ } else if (-1 != return_value) {
+ /* OR the result into the return value
+ * for be pre/postops */
+ return_value |= rc;
+ }
}
}
/* counters_to_errors_log("after plugin call"); */
11 years, 11 months