ldap/servers/plugins/chainingdb/cb_instance.c | 192 ++++++++++++--------------
ldap/servers/slapd/add.c | 2
ldap/servers/slapd/attr.c | 95 ++++--------
ldap/servers/slapd/entrywsi.c | 2
ldap/servers/slapd/opshared.c | 1
ldap/servers/slapd/slap.h | 1
6 files changed, 128 insertions(+), 165 deletions(-)
New commits:
commit c73fc8354153106bb5ab3470a45d58a26aec0f59
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:
(cherry picked from commit dc379838f8e4cfd2c736e8c2fb8366fb3b4f73d4)
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 5c0193233288c30522b63cae0fd86c9299751588
Author: Noriko Hosoi <nhosoi(a)totoro.usersys.redhat.com>
Date: Tue Feb 5 14:56:12 2013 -0800
Ticket 570 - DS returns error 20 when replacing values of a multi-valued attribute
(only when replication is enabled)
Bug Description: When replacing an attr value "SOME_VALUE" with
"some_value", and replication
is enabled, an error 20(type or value exists) is incorrectly
returned.
Fix Description: For replace operations we were doing a bit-by-bit comparison.
Ignoring the syntax
of the attribute. The fix was to remove this bit-by-bit check that
is no longer
necessary with the current code base.
https://fedorahosted.org/389/ticket/570
Reviewed by: ?
(cherry picked and fixed conflicts from commit
1c3bf98303c04323542251f1c564c8bdc4e8cc67)
diff --git a/ldap/servers/slapd/attr.c b/ldap/servers/slapd/attr.c
index 2dc2a80..87dfe1e 100644
--- a/ldap/servers/slapd/attr.c
+++ b/ldap/servers/slapd/attr.c
@@ -534,76 +534,45 @@ slapi_attr_flag_is_set( const Slapi_Attr *a, unsigned long flag )
int
slapi_attr_value_cmp( const Slapi_Attr *a, const struct berval *v1, const struct berval
*v2 )
{
- int retVal;
+ Slapi_Attr a2 = *a;
+ struct ava ava;
+ Slapi_Value *cvals[2];
+ Slapi_Value tmpcval;
- if ( a->a_flags & SLAPI_ATTR_FLAG_CMP_BITBYBIT )
- {
- int cmplen = ( v1->bv_len <= v2->bv_len ? v1->bv_len : v2->bv_len );
- retVal = memcmp(v1->bv_val, v2->bv_val, cmplen);
- if ( retVal == 0 && v1->bv_len < v2->bv_len )
- {
- retVal = -1;
- }
- else if ( retVal == 0 && v1->bv_len > v2->bv_len )
- {
- retVal = 1;
- }
- }
- else
- {
- Slapi_Attr a2;
- struct ava ava;
- Slapi_Value *cvals[2];
- Slapi_Value tmpcval;
-
- a2 = *a;
- cvals[0] = &tmpcval;
- cvals[0]->v_csnset = NULL;
- cvals[0]->bv = *v1;
- cvals[0]->v_flags = 0;
- cvals[1] = NULL;
- a2.a_present_values.va = cvals; /* JCM - PUKE */
- ava.ava_type = a->a_type;
- ava.ava_value = *v2;
- ava.ava_private = NULL;
- retVal = plugin_call_syntax_filter_ava(&a2, LDAP_FILTER_EQUALITY, &ava);
- }
- return retVal;
+ cvals[0] = &tmpcval;
+ cvals[0]->v_csnset = NULL;
+ cvals[0]->bv = *v1;
+ cvals[0]->v_flags = 0;
+ cvals[1] = NULL;
+ a2.a_present_values.va = cvals; /* JCM - PUKE */
+ ava.ava_type = a->a_type;
+ ava.ava_value = *v2;
+ ava.ava_private = NULL;
+
+ return( plugin_call_syntax_filter_ava(&a2, LDAP_FILTER_EQUALITY, &ava));
}
int
slapi_attr_value_cmp_ext(const Slapi_Attr *a, Slapi_Value *v1, Slapi_Value *v2)
{
- int retVal;
- const struct berval *bv2 = slapi_value_get_berval(v2);
+ struct ava ava;
+ Slapi_Attr a2 = *a;
+ Slapi_Value *cvals[2];
+ unsigned long v2_flags = v2->v_flags;
+ const struct berval *bv2 = slapi_value_get_berval(v2);
+
+ cvals[0] = v1;
+ cvals[1] = NULL;
+ a2.a_present_values.va = cvals;
+ ava.ava_type = a->a_type;
+ ava.ava_value = *bv2;
+ if (v2_flags) {
+ ava.ava_private = &v2_flags;
+ } else {
+ ava.ava_private = NULL;
+ }
- if ( a->a_flags & SLAPI_ATTR_FLAG_CMP_BITBYBIT )
- {
- const struct berval *bv1 = slapi_value_get_berval(v1);
- return slapi_attr_value_cmp(a, bv1, bv2);
- }
- else
- {
- Slapi_Attr a2;
- struct ava ava;
- Slapi_Value *cvals[2];
- unsigned long v2_flags = v2->v_flags;
-
- a2 = *a;
- cvals[0] = v1;
- cvals[1] = NULL;
- a2.a_present_values.va = cvals; /* JCM - PUKE */
-
- ava.ava_type = a->a_type;
- ava.ava_value = *bv2;
- if (v2_flags) {
- ava.ava_private = &v2_flags;
- } else {
- ava.ava_private = NULL;
- }
- retVal = plugin_call_syntax_filter_ava(&a2, LDAP_FILTER_EQUALITY, &ava);
- }
- return retVal;
+ return (plugin_call_syntax_filter_ava(&a2, LDAP_FILTER_EQUALITY, &ava));
}
/*
diff --git a/ldap/servers/slapd/entrywsi.c b/ldap/servers/slapd/entrywsi.c
index 0419864..971e9e3 100644
--- a/ldap/servers/slapd/entrywsi.c
+++ b/ldap/servers/slapd/entrywsi.c
@@ -709,7 +709,7 @@ entry_replace_present_values_wsi(Slapi_Entry *e, const char *type,
struct berval
* slapi_entry_add_values() returns LDAP_SUCCESS and so the
* attribute remains deleted (which is the correct outcome).
*/
- return( entry_add_present_values_wsi( e, type, vals, csn, urp,
SLAPI_ATTR_FLAG_CMP_BITBYBIT ));
+ return( entry_add_present_values_wsi( e, type, vals, csn, urp, 0));
}
/*
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index e3cbc72..eea025a 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -510,7 +510,6 @@ typedef struct asyntaxinfo {
if any */
#define SLAPI_ATTR_FLAG_NOLOCKING 0x0020 /* the init code doesn't lock the
tables */
-#define SLAPI_ATTR_FLAG_CMP_BITBYBIT 0x4000 /* do memcmp, not syntax cmp */
#define SLAPI_ATTR_FLAG_KEEP 0x8000 /* keep when replacing all */
/* This is the type of the function passed into attr_syntax_enumerate_attrs */
commit 39d4108d254d44e0d7b5ea9de5ce75cea7aa7f63
Author: Noriko Hosoi <nhosoi(a)totoro.usersys.redhat.com>
Date: Tue Feb 5 13:53:11 2013 -0800
Bug 906005 - Valgrind reports memleak in modify_update_last_modified_attr
Fix description: plugin_get_dn returns plugin_dn, which is supposed
to be freed by the caller. This patch adds the free function to
modify_update_last_modified_attr, add_created_attrs and
add_internal_modifiersname.
(cherry picked from commit d895373022b93282da6310a12b2c82ea56b28d7a)
diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c
index 3206d5b..44a9aa2 100644
--- a/ldap/servers/slapd/add.c
+++ b/ldap/servers/slapd/add.c
@@ -789,6 +789,7 @@ add_created_attrs(Slapi_PBlock *pb, Slapi_Entry *e)
}
slapi_entry_attr_replace(e, "internalCreatorsName", bvals);
slapi_entry_attr_replace(e, "internalModifiersName", bvals);
+ slapi_ch_free_string(&plugin_dn);
/* Grab the thread data(binddn) */
slapi_td_get_dn(&binddn);
@@ -1014,6 +1015,7 @@ add_internal_modifiersname(Slapi_PBlock *pb, Slapi_Entry *e)
plugin_dn = plugin_get_dn (plugin);
if(plugin_dn){
slapi_entry_attr_set_charptr(e, "internalModifiersname",
plugin_dn);
+ slapi_ch_free_string(&plugin_dn);
}
}
}
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
index 485763e..fabe8a4 100644
--- a/ldap/servers/slapd/opshared.c
+++ b/ldap/servers/slapd/opshared.c
@@ -178,6 +178,7 @@ modify_update_last_modified_attr(Slapi_PBlock *pb, Slapi_Mods *smods)
}
slapi_mods_add_modbvps(smods, LDAP_MOD_REPLACE | LDAP_MOD_BVALUES,
"internalModifiersName", bvals);
+ slapi_ch_free_string(&plugin_dn);
/* Grab the thread data(binddn) */
slapi_td_get_dn(&binddn);