|
|
dc8c34 |
From ecf7b877c158e79739845bcc6616821fc6e44535 Mon Sep 17 00:00:00 2001
|
|
|
dc8c34 |
From: Mark Reynolds <mareynol@redhat.com>
|
|
|
dc8c34 |
Date: Fri, 11 May 2012 13:00:50 -0400
|
|
|
dc8c34 |
Subject: [PATCH 31/33] Ticket 367 - Invalid chaining config triggers a disk
|
|
|
dc8c34 |
full error and shutdown
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Bug Description: If you use the root DN for the chaining bind DN a error -2 (LDAP_LOCAL_ERROR)
|
|
|
dc8c34 |
is returned from the callback. This is the same error code for SLAPI_FAIL_DISKFULL.
|
|
|
dc8c34 |
Once the error -2 is retuned, the server thinks we are out of disk space and the
|
|
|
dc8c34 |
instance is shutdown.
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Fix Description: Return -1, instead of -2(LDAP_LOCAL_ERROR)
|
|
|
dc8c34 |
|
|
|
dc8c34 |
https://fedorahosted.org/389/ticket/367
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Note: also did a little code cleanup with indentation
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Reviewed by:
|
|
|
dc8c34 |
(cherry picked from commit dc379838f8e4cfd2c736e8c2fb8366fb3b4f73d4)
|
|
|
dc8c34 |
---
|
|
|
dc8c34 |
ldap/servers/plugins/chainingdb/cb_instance.c | 192 ++++++++++++-------------
|
|
|
dc8c34 |
1 files changed, 92 insertions(+), 100 deletions(-)
|
|
|
dc8c34 |
|
|
|
dc8c34 |
diff --git a/ldap/servers/plugins/chainingdb/cb_instance.c b/ldap/servers/plugins/chainingdb/cb_instance.c
|
|
|
dc8c34 |
index 9a33916..8fb694a 100644
|
|
|
dc8c34 |
--- a/ldap/servers/plugins/chainingdb/cb_instance.c
|
|
|
dc8c34 |
+++ b/ldap/servers/plugins/chainingdb/cb_instance.c
|
|
|
dc8c34 |
@@ -511,15 +511,15 @@ int cb_instance_modify_config_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor
|
|
|
dc8c34 |
*/
|
|
|
dc8c34 |
|
|
|
dc8c34 |
int
|
|
|
dc8c34 |
-cb_parse_instance_config_entry(cb_backend * cb, Slapi_Entry * e) {
|
|
|
dc8c34 |
-
|
|
|
dc8c34 |
- int rc =LDAP_SUCCESS;
|
|
|
dc8c34 |
- Slapi_Attr *attr = NULL;
|
|
|
dc8c34 |
- Slapi_Value *sval;
|
|
|
dc8c34 |
- const struct berval *attrValue;
|
|
|
dc8c34 |
- cb_backend_instance *inst=NULL;
|
|
|
dc8c34 |
- char *instname;
|
|
|
dc8c34 |
- char retmsg[CB_BUFSIZE];
|
|
|
dc8c34 |
+cb_parse_instance_config_entry(cb_backend * cb, Slapi_Entry * e)
|
|
|
dc8c34 |
+{
|
|
|
dc8c34 |
+ cb_backend_instance *inst = NULL;
|
|
|
dc8c34 |
+ Slapi_Attr *attr = NULL;
|
|
|
dc8c34 |
+ Slapi_Value *sval;
|
|
|
dc8c34 |
+ const struct berval *attrValue;
|
|
|
dc8c34 |
+ char *instname;
|
|
|
dc8c34 |
+ char retmsg[CB_BUFSIZE];
|
|
|
dc8c34 |
+ int rc = LDAP_SUCCESS;
|
|
|
dc8c34 |
|
|
|
dc8c34 |
CB_ASSERT(e!=NULL);
|
|
|
dc8c34 |
|
|
|
dc8c34 |
@@ -529,17 +529,17 @@ cb_parse_instance_config_entry(cb_backend * cb, Slapi_Entry * e) {
|
|
|
dc8c34 |
*/
|
|
|
dc8c34 |
|
|
|
dc8c34 |
if ( 0 == slapi_entry_attr_find( e, CB_CONFIG_INSTNAME, &attr )) {
|
|
|
dc8c34 |
- slapi_attr_first_value(attr, &sval);
|
|
|
dc8c34 |
- attrValue = slapi_value_get_berval(sval);
|
|
|
dc8c34 |
- instname=attrValue->bv_val;
|
|
|
dc8c34 |
+ slapi_attr_first_value(attr, &sval);
|
|
|
dc8c34 |
+ attrValue = slapi_value_get_berval(sval);
|
|
|
dc8c34 |
+ instname = attrValue->bv_val;
|
|
|
dc8c34 |
} else {
|
|
|
dc8c34 |
slapi_log_error( SLAPI_LOG_PLUGIN, CB_PLUGIN_SUBSYSTEM,
|
|
|
dc8c34 |
"Malformed backend instance (<%s> missing)>\n", CB_CONFIG_INSTNAME);
|
|
|
dc8c34 |
- return LDAP_LOCAL_ERROR;
|
|
|
dc8c34 |
+ return -1;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
- /* Allocate a new backend internal data structure */
|
|
|
dc8c34 |
- inst = cb_instance_alloc(cb,instname,slapi_entry_get_dn(e));
|
|
|
dc8c34 |
+ /* Allocate a new backend internal data structure */
|
|
|
dc8c34 |
+ inst = cb_instance_alloc(cb,instname,slapi_entry_get_dn(e));
|
|
|
dc8c34 |
|
|
|
dc8c34 |
/* Emulate a add config entry to configure */
|
|
|
dc8c34 |
/* this backend instance. */
|
|
|
dc8c34 |
@@ -556,99 +556,96 @@ cb_parse_instance_config_entry(cb_backend * cb, Slapi_Entry * e) {
|
|
|
dc8c34 |
*/
|
|
|
dc8c34 |
|
|
|
dc8c34 |
static int
|
|
|
dc8c34 |
-cb_instance_config_initialize(cb_backend_instance * inst, Slapi_Entry * e , int phase, int apply) {
|
|
|
dc8c34 |
-
|
|
|
dc8c34 |
- int rc =LDAP_SUCCESS;
|
|
|
dc8c34 |
- Slapi_Attr *attr = NULL;
|
|
|
dc8c34 |
- Slapi_Value *sval;
|
|
|
dc8c34 |
- struct berval * bval;
|
|
|
dc8c34 |
- int using_def_connlifetime,i;
|
|
|
dc8c34 |
- char err_buf[SLAPI_DSE_RETURNTEXT_SIZE];
|
|
|
dc8c34 |
- int urlfound=0;
|
|
|
dc8c34 |
- char *rootdn;
|
|
|
dc8c34 |
+cb_instance_config_initialize(cb_backend_instance * inst, Slapi_Entry * e , int phase, int apply)
|
|
|
dc8c34 |
+{
|
|
|
dc8c34 |
+ Slapi_Attr *attr = NULL;
|
|
|
dc8c34 |
+ Slapi_Value *sval;
|
|
|
dc8c34 |
+ Slapi_DN *suffix;
|
|
|
dc8c34 |
+ struct berval *bval;
|
|
|
dc8c34 |
+ char err_buf[SLAPI_DSE_RETURNTEXT_SIZE];
|
|
|
dc8c34 |
+ char *attr_name = NULL;
|
|
|
dc8c34 |
+ char *rootdn;
|
|
|
dc8c34 |
+ int using_def_connlifetime, i;
|
|
|
dc8c34 |
+ int urlfound = 0;
|
|
|
dc8c34 |
+ int rc = LDAP_SUCCESS;
|
|
|
dc8c34 |
|
|
|
dc8c34 |
using_def_connlifetime=1;
|
|
|
dc8c34 |
|
|
|
dc8c34 |
- for (slapi_entry_first_attr(e, &attr); attr; slapi_entry_next_attr(e, attr, &attr)) {
|
|
|
dc8c34 |
- char * attr_name=NULL;
|
|
|
dc8c34 |
- slapi_attr_get_type(attr, &attr_name);
|
|
|
dc8c34 |
+ for (slapi_entry_first_attr(e, &attr); attr; slapi_entry_next_attr(e, attr, &attr)) {
|
|
|
dc8c34 |
+ attr_name = NULL;
|
|
|
dc8c34 |
+ slapi_attr_get_type(attr, &attr_name);
|
|
|
dc8c34 |
|
|
|
dc8c34 |
if ( !strcasecmp ( attr_name, CB_CONFIG_SUFFIX )) {
|
|
|
dc8c34 |
if (apply && ( inst->inst_be != NULL )) {
|
|
|
dc8c34 |
- Slapi_DN *suffix;
|
|
|
dc8c34 |
suffix = slapi_sdn_new();
|
|
|
dc8c34 |
- i = slapi_attr_first_value(attr, &sval);
|
|
|
dc8c34 |
- while (i != -1 ) {
|
|
|
dc8c34 |
- bval = (struct berval *) slapi_value_get_berval(sval);
|
|
|
dc8c34 |
- slapi_sdn_set_dn_byref(suffix, bval->bv_val);
|
|
|
dc8c34 |
-
|
|
|
dc8c34 |
- if (!slapi_be_issuffix(inst->inst_be, suffix)) {
|
|
|
dc8c34 |
- slapi_be_addsuffix(inst->inst_be, suffix);
|
|
|
dc8c34 |
- }
|
|
|
dc8c34 |
- i = slapi_attr_next_value(attr, i, &sval);
|
|
|
dc8c34 |
- }
|
|
|
dc8c34 |
+ i = slapi_attr_first_value(attr, &sval);
|
|
|
dc8c34 |
+ while (i != -1 ) {
|
|
|
dc8c34 |
+ bval = (struct berval *) slapi_value_get_berval(sval);
|
|
|
dc8c34 |
+ slapi_sdn_set_dn_byref(suffix, bval->bv_val);
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ if (!slapi_be_issuffix(inst->inst_be, suffix)) {
|
|
|
dc8c34 |
+ slapi_be_addsuffix(inst->inst_be, suffix);
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ i = slapi_attr_next_value(attr, i, &sval);
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
slapi_sdn_free(&suffix);
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
- continue;
|
|
|
dc8c34 |
- } else
|
|
|
dc8c34 |
- if ( !strcasecmp ( attr_name, CB_CONFIG_CHAINING_COMPONENTS )) {
|
|
|
dc8c34 |
-
|
|
|
dc8c34 |
- if (apply) {
|
|
|
dc8c34 |
- slapi_rwlock_wrlock(inst->rwl_config_lock);
|
|
|
dc8c34 |
- i = slapi_attr_first_value(attr, &sval);
|
|
|
dc8c34 |
+ continue;
|
|
|
dc8c34 |
+ } else if ( !strcasecmp ( attr_name, CB_CONFIG_CHAINING_COMPONENTS )) {
|
|
|
dc8c34 |
+ if (apply) {
|
|
|
dc8c34 |
+ slapi_rwlock_wrlock(inst->rwl_config_lock);
|
|
|
dc8c34 |
+ i = slapi_attr_first_value(attr, &sval);
|
|
|
dc8c34 |
charray_free(inst->chaining_components);
|
|
|
dc8c34 |
inst->chaining_components=NULL;
|
|
|
dc8c34 |
- while (i != -1 ) {
|
|
|
dc8c34 |
- bval = (struct berval *) slapi_value_get_berval(sval);
|
|
|
dc8c34 |
+ while (i != -1 ) {
|
|
|
dc8c34 |
+ bval = (struct berval *) slapi_value_get_berval(sval);
|
|
|
dc8c34 |
charray_add(&inst->chaining_components,
|
|
|
dc8c34 |
- slapi_dn_normalize(slapi_ch_strdup(bval->bv_val)));
|
|
|
dc8c34 |
- i = slapi_attr_next_value(attr, i, &sval);
|
|
|
dc8c34 |
- }
|
|
|
dc8c34 |
- slapi_rwlock_unlock(inst->rwl_config_lock);
|
|
|
dc8c34 |
- }
|
|
|
dc8c34 |
- continue;
|
|
|
dc8c34 |
- } else
|
|
|
dc8c34 |
- if ( !strcasecmp ( attr_name, CB_CONFIG_ILLEGAL_ATTRS )) {
|
|
|
dc8c34 |
-
|
|
|
dc8c34 |
- if (apply) {
|
|
|
dc8c34 |
- slapi_rwlock_wrlock(inst->rwl_config_lock);
|
|
|
dc8c34 |
- i = slapi_attr_first_value(attr, &sval);
|
|
|
dc8c34 |
+ slapi_dn_normalize(slapi_ch_strdup(bval->bv_val)));
|
|
|
dc8c34 |
+ i = slapi_attr_next_value(attr, i, &sval);
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ slapi_rwlock_unlock(inst->rwl_config_lock);
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ continue;
|
|
|
dc8c34 |
+ } else if ( !strcasecmp ( attr_name, CB_CONFIG_ILLEGAL_ATTRS )) {
|
|
|
dc8c34 |
+ if (apply) {
|
|
|
dc8c34 |
+ slapi_rwlock_wrlock(inst->rwl_config_lock);
|
|
|
dc8c34 |
+ i = slapi_attr_first_value(attr, &sval);
|
|
|
dc8c34 |
charray_free(inst->illegal_attributes);
|
|
|
dc8c34 |
inst->illegal_attributes=NULL;
|
|
|
dc8c34 |
- while (i != -1 ) {
|
|
|
dc8c34 |
- bval = (struct berval *) slapi_value_get_berval(sval);
|
|
|
dc8c34 |
+ while (i != -1 ) {
|
|
|
dc8c34 |
+ bval = (struct berval *) slapi_value_get_berval(sval);
|
|
|
dc8c34 |
charray_add(&inst->illegal_attributes,
|
|
|
dc8c34 |
- slapi_ch_strdup(bval->bv_val));
|
|
|
dc8c34 |
- i = slapi_attr_next_value(attr, i, &sval);
|
|
|
dc8c34 |
- }
|
|
|
dc8c34 |
- slapi_rwlock_unlock(inst->rwl_config_lock);
|
|
|
dc8c34 |
- }
|
|
|
dc8c34 |
- continue;
|
|
|
dc8c34 |
+ slapi_ch_strdup(bval->bv_val));
|
|
|
dc8c34 |
+ i = slapi_attr_next_value(attr, i, &sval);
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ slapi_rwlock_unlock(inst->rwl_config_lock);
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ continue;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
|
|
|
dc8c34 |
if ( !strcasecmp ( attr_name, CB_CONFIG_HOSTURL )) {
|
|
|
dc8c34 |
urlfound=1;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
-
|
|
|
dc8c34 |
|
|
|
dc8c34 |
- /* We are assuming that each of these attributes are to have
|
|
|
dc8c34 |
- * only one value. If they have more than one value, like
|
|
|
dc8c34 |
- * the nsslapd-suffix attribute, then they need to be
|
|
|
dc8c34 |
- * handled differently. */
|
|
|
dc8c34 |
+ /*
|
|
|
dc8c34 |
+ * We are assuming that each of these attributes are to have
|
|
|
dc8c34 |
+ * only one value. If they have more than one value, like
|
|
|
dc8c34 |
+ * the nsslapd-suffix attribute, then they need to be
|
|
|
dc8c34 |
+ * handled differently.
|
|
|
dc8c34 |
+ */
|
|
|
dc8c34 |
|
|
|
dc8c34 |
- slapi_attr_first_value(attr, &sval);
|
|
|
dc8c34 |
- bval = (struct berval *) slapi_value_get_berval(sval);
|
|
|
dc8c34 |
-
|
|
|
dc8c34 |
- if (cb_instance_config_set((void *) inst, attr_name,
|
|
|
dc8c34 |
+ slapi_attr_first_value(attr, &sval);
|
|
|
dc8c34 |
+ bval = (struct berval *) slapi_value_get_berval(sval);
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ if (cb_instance_config_set((void *) inst, attr_name,
|
|
|
dc8c34 |
cb_the_instance_config, bval, err_buf, phase, apply ) != LDAP_SUCCESS) {
|
|
|
dc8c34 |
- slapi_log_error( SLAPI_LOG_FATAL,
|
|
|
dc8c34 |
- CB_PLUGIN_SUBSYSTEM,"Error with config attribute %s : %s\n",
|
|
|
dc8c34 |
+ slapi_log_error( SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,"Error with config attribute %s : %s\n",
|
|
|
dc8c34 |
attr_name, err_buf);
|
|
|
dc8c34 |
- rc=LDAP_LOCAL_ERROR;
|
|
|
dc8c34 |
- break;
|
|
|
dc8c34 |
- }
|
|
|
dc8c34 |
- if ( !strcasecmp ( attr_name, CB_CONFIG_CONNLIFETIME )) {
|
|
|
dc8c34 |
+ rc = -1;
|
|
|
dc8c34 |
+ break;
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ if ( !strcasecmp ( attr_name, CB_CONFIG_CONNLIFETIME )) {
|
|
|
dc8c34 |
using_def_connlifetime=0;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
@@ -661,20 +658,17 @@ cb_instance_config_initialize(cb_backend_instance * inst, Slapi_Entry * e , int
|
|
|
dc8c34 |
|
|
|
dc8c34 |
if (LDAP_SUCCESS == rc) {
|
|
|
dc8c34 |
if (!urlfound) {
|
|
|
dc8c34 |
- slapi_log_error( SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,
|
|
|
dc8c34 |
- "Malformed backend instance entry. Mandatory attr <%s> missing\n",
|
|
|
dc8c34 |
- CB_CONFIG_HOSTURL);
|
|
|
dc8c34 |
- rc= LDAP_LOCAL_ERROR;
|
|
|
dc8c34 |
+ slapi_log_error( SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,
|
|
|
dc8c34 |
+ "Malformed backend instance entry. Mandatory attr <%s> missing\n",CB_CONFIG_HOSTURL);
|
|
|
dc8c34 |
+ rc = -1;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
if (apply ) {
|
|
|
dc8c34 |
- if ( using_def_connlifetime &&
|
|
|
dc8c34 |
- strchr( inst->pool->hostname, ' ' ) != NULL ) {
|
|
|
dc8c34 |
-
|
|
|
dc8c34 |
- cb_instance_config_set((void *)inst, CB_CONFIG_CONNLIFETIME,
|
|
|
dc8c34 |
- cb_the_instance_config, NULL /* use default */, err_buf,
|
|
|
dc8c34 |
+ if ( using_def_connlifetime && strchr( inst->pool->hostname, ' ' ) != NULL ) {
|
|
|
dc8c34 |
+ cb_instance_config_set((void *)inst, CB_CONFIG_CONNLIFETIME,
|
|
|
dc8c34 |
+ cb_the_instance_config, NULL /* use default */, err_buf,
|
|
|
dc8c34 |
CB_CONFIG_PHASE_INITIALIZATION, 1 );
|
|
|
dc8c34 |
- }
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
@@ -683,15 +677,13 @@ cb_instance_config_initialize(cb_backend_instance * inst, Slapi_Entry * e , int
|
|
|
dc8c34 |
** It is forbidden to use directory manager as proxy user
|
|
|
dc8c34 |
** due to a bug in the acl check
|
|
|
dc8c34 |
*/
|
|
|
dc8c34 |
-
|
|
|
dc8c34 |
- rootdn=cb_get_rootdn();
|
|
|
dc8c34 |
+ rootdn = cb_get_rootdn();
|
|
|
dc8c34 |
|
|
|
dc8c34 |
if (inst->impersonate && inst->pool && inst->pool->binddn &&
|
|
|
dc8c34 |
!strcmp(inst->pool->binddn,rootdn)) { /* UTF8 aware */
|
|
|
dc8c34 |
- slapi_log_error( SLAPI_LOG_FATAL,
|
|
|
dc8c34 |
- CB_PLUGIN_SUBSYSTEM,"Error with config attribute %s (%s: forbidden value)\n",
|
|
|
dc8c34 |
- CB_CONFIG_BINDUSER, rootdn);
|
|
|
dc8c34 |
- rc=LDAP_LOCAL_ERROR;
|
|
|
dc8c34 |
+ slapi_log_error( SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,
|
|
|
dc8c34 |
+ "Error with config attribute %s (%s: forbidden value)\n", CB_CONFIG_BINDUSER, rootdn);
|
|
|
dc8c34 |
+ rc= -1;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
slapi_ch_free((void **)&rootdn);
|
|
|
dc8c34 |
|
|
|
dc8c34 |
@@ -1494,7 +1486,7 @@ struct berval *bval, char *err_buf, int phase, int apply_mod)
|
|
|
dc8c34 |
int use_default;
|
|
|
dc8c34 |
int int_val;
|
|
|
dc8c34 |
long long_val;
|
|
|
dc8c34 |
- int retval=LDAP_LOCAL_ERROR;
|
|
|
dc8c34 |
+ int retval = -1;
|
|
|
dc8c34 |
|
|
|
dc8c34 |
config = cb_get_config_info(config_array, attr_name);
|
|
|
dc8c34 |
if (NULL == config) {
|
|
|
dc8c34 |
--
|
|
|
dc8c34 |
1.7.7.6
|
|
|
dc8c34 |
|