summaryrefslogtreecommitdiffstats
path: root/ldap/servers/slapd
diff options
context:
space:
mode:
authorNoriko Hosoi <nhosoi@redhat.com>2007-12-04 00:50:19 +0000
committerNoriko Hosoi <nhosoi@redhat.com>2007-12-04 00:50:19 +0000
commit4b56e87e61399e6c7d5501e06ada3f22ffb4b728 (patch)
tree4d5d7ee18fe449fff9e6fd91e4cd5239585fcef2 /ldap/servers/slapd
parent7ff698e16687700f0dc0273cdbbfe5cfe88cbefd (diff)
downloadds-4b56e87e61399e6c7d5501e06ada3f22ffb4b728.tar.gz
ds-4b56e87e61399e6c7d5501e06ada3f22ffb4b728.tar.xz
ds-4b56e87e61399e6c7d5501e06ada3f22ffb4b728.zip
Resolves: #231093
Summary: db2bak: crash bug (comment #8, 11) Description: Set the strong requirement: nsslapd-directory must have some value. to guarantee it: 1) checking errors from ldbm_config_directory_set. If the check fails, don't start the server. 2) if nsslapd-directory does not exist or the value is empty in dse.ldif, issuing an error message and returning the error code. 3) since it was difficult to distinguish the nsslapd-directory empty value from the initial default value, introduced CONFIG_FLAG_SKIP_DEFAULT_SETTING flag to tell the backend config code to skip setting the default value
Diffstat (limited to 'ldap/servers/slapd')
-rw-r--r--ldap/servers/slapd/back-ldbm/dblayer.c5
-rw-r--r--ldap/servers/slapd/back-ldbm/ldbm_config.c154
-rw-r--r--ldap/servers/slapd/back-ldbm/ldbm_config.h1
-rw-r--r--ldap/servers/slapd/back-ldbm/ldbm_instance_config.c8
-rw-r--r--ldap/servers/slapd/back-ldbm/start.c8
5 files changed, 104 insertions, 72 deletions
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index 42111735..8f0bc07b 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -1409,6 +1409,11 @@ int dblayer_start(struct ldbminfo *li, int dbmode)
/* DBDB we should pick these up in our config routine, and do away with
* the li_ one */
+ if (NULL == li->li_directory || '\0' == *li->li_directory) {
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "Error: DB directory is not specified.\n", 0, 0, 0);
+ return -1;
+ }
PR_Lock(li->li_config_mutex);
priv->dblayer_home_directory = li->li_directory; /* nsslapd-directory */
priv->dblayer_cachesize = li->li_dbcachesize;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c b/ldap/servers/slapd/back-ldbm/ldbm_config.c
index 541ae6d3..1ddd1f21 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c
@@ -243,75 +243,86 @@ static int ldbm_config_directory_set(void *arg, void *value, char *errorbuf, int
strdup'ed in rel2abspath */
LDAPDebug(LDAP_DEBUG_ANY, "New db directory location will not take affect until the server is restarted\n", 0, 0, 0);
} else {
- if (!strcmp(val, "get default")) {
- /* We use this funky "get default" string for the caller to
- * tell us that it has no idea what the db directory should
- * be. This code figures it out be reading "cn=config,cn=ldbm
- * database,cn=plugins,cn=config" entry. */
- Slapi_PBlock *search_pb;
- Slapi_Entry **entries = NULL;
- Slapi_Attr *attr = NULL;
- Slapi_Value *v = NULL;
- const char *s = NULL;
- int res;
-
- search_pb = slapi_pblock_new();
- slapi_search_internal_set_pb(search_pb, CONFIG_LDBM_DN,
- LDAP_SCOPE_BASE, "objectclass=*", NULL, 0, NULL, NULL,
- li->li_identity, 0);
- slapi_search_internal_pb(search_pb);
- slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_RESULT, &res);
-
- if (res != LDAP_SUCCESS) {
- LDAPDebug(LDAP_DEBUG_ANY,
- "ERROR: ldbm plugin unable to read %s\n",
- CONFIG_LDBM_DN, 0, 0);
- goto done;
- }
-
- slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
- if (NULL == entries) {
- LDAPDebug(LDAP_DEBUG_ANY,
- "ERROR: ldbm plugin unable to read %s\n",
- CONFIG_LDBM_DN, 0, 0);
- res = LDAP_OPERATIONS_ERROR;
- goto done;
- }
-
- res = slapi_entry_attr_find(entries[0], "nsslapd-directory", &attr);
- if (res != 0 || attr == NULL) {
- LDAPDebug(LDAP_DEBUG_ANY,
- "ERROR: ldbm plugin unable to read attribute nsslapd-directory from %s\n",
- CONFIG_LDBM_DN, 0, 0);
- res = LDAP_OPERATIONS_ERROR;
- goto done;
- }
-
- if ( slapi_attr_first_value(attr,&v) != 0
- || ( NULL == v )
- || ( NULL == ( s = slapi_value_get_string( v )))) {
- LDAPDebug(LDAP_DEBUG_ANY,
- "ERROR: ldbm plugin unable to read attribute nsslapd-directory from %s\n",
- CONFIG_LDBM_DN, 0, 0);
- res = LDAP_OPERATIONS_ERROR;
- goto done;
- }
-
-done:
- slapi_pblock_destroy(search_pb);
- if (res != LDAP_SUCCESS) {
- return res;
- }
- PR_snprintf(tmpbuf, BUFSIZ, "%s", s);
- val = tmpbuf;
- }
slapi_ch_free((void **) &(li->li_new_directory));
slapi_ch_free((void **) &(li->li_directory));
- li->li_new_directory = rel2abspath(val); /* normalize the path;
- strdup'ed in rel2abspath */
- li->li_directory = rel2abspath(val); /* ditto */
+ if (NULL == val || '\0' == *val) {
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "ERROR: db directory is not set; check %s in the db config: %s\n",
+ CONFIG_DIRECTORY, CONFIG_LDBM_DN, 0);
+ retval = LDAP_PARAM_ERROR;
+ } else {
+ if (0 == strcmp(val, "get default")) {
+ /* We use this funky "get default" string for the caller to
+ * tell us that it has no idea what the db directory should
+ * be. This code figures it out be reading "cn=config,cn=ldbm
+ * database,cn=plugins,cn=config" entry. */
+ Slapi_PBlock *search_pb;
+ Slapi_Entry **entries = NULL;
+ Slapi_Attr *attr = NULL;
+ Slapi_Value *v = NULL;
+ const char *s = NULL;
+ int res;
+
+ search_pb = slapi_pblock_new();
+ slapi_search_internal_set_pb(search_pb, CONFIG_LDBM_DN,
+ LDAP_SCOPE_BASE, "objectclass=*", NULL, 0, NULL, NULL,
+ li->li_identity, 0);
+ slapi_search_internal_pb(search_pb);
+ slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_RESULT, &res);
+
+ if (res != LDAP_SUCCESS) {
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "ERROR: ldbm plugin unable to read %s\n",
+ CONFIG_LDBM_DN, 0, 0);
+ retval = res;
+ goto done;
+ }
+
+ slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
+ if (NULL == entries) {
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "ERROR: ldbm plugin unable to read %s\n",
+ CONFIG_LDBM_DN, 0, 0);
+ retval = LDAP_OPERATIONS_ERROR;
+ goto done;
+ }
+
+ res = slapi_entry_attr_find(entries[0], "nsslapd-directory", &attr);
+ if (res != 0 || attr == NULL) {
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "ERROR: ldbm plugin unable to read attribute nsslapd-directory from %s\n",
+ CONFIG_LDBM_DN, 0, 0);
+ retval = LDAP_OPERATIONS_ERROR;
+ goto done;
+ }
+
+ if ( slapi_attr_first_value(attr,&v) != 0
+ || ( NULL == v )
+ || ( NULL == ( s = slapi_value_get_string( v )))) {
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "ERROR: ldbm plugin unable to read attribute nsslapd-directory from %s\n",
+ CONFIG_LDBM_DN, 0, 0);
+ retval = LDAP_OPERATIONS_ERROR;
+ goto done;
+ }
+ slapi_pblock_destroy(search_pb);
+ if (NULL == s || '\0' == s || 0 == PL_strcmp(s, "(null)")) {
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "ERROR: db directory is not set; check %s in the db config: %s\n",
+ CONFIG_DIRECTORY, CONFIG_LDBM_DN, 0);
+ retval = LDAP_PARAM_ERROR;
+ goto done;
+ }
+ PR_snprintf(tmpbuf, BUFSIZ, "%s", s);
+ val = tmpbuf;
+ }
+ li->li_new_directory = rel2abspath(val); /* normalize the path;
+ strdup'ed in
+ rel2abspath */
+ li->li_directory = rel2abspath(val); /* ditto */
+ }
}
-
+done:
return retval;
}
@@ -1193,7 +1204,7 @@ static config_info ldbm_config[] = {
{CONFIG_LOOKTHROUGHLIMIT, CONFIG_TYPE_INT, "5000", &ldbm_config_lookthroughlimit_get, &ldbm_config_lookthroughlimit_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
{CONFIG_MODE, CONFIG_TYPE_INT_OCTAL, "0600", &ldbm_config_mode_get, &ldbm_config_mode_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
{CONFIG_IDLISTSCANLIMIT, CONFIG_TYPE_INT, "4000", &ldbm_config_allidsthreshold_get, &ldbm_config_allidsthreshold_set, CONFIG_FLAG_ALWAYS_SHOW},
- {CONFIG_DIRECTORY, CONFIG_TYPE_STRING, "", &ldbm_config_directory_get, &ldbm_config_directory_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
+ {CONFIG_DIRECTORY, CONFIG_TYPE_STRING, "", &ldbm_config_directory_get, &ldbm_config_directory_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE|CONFIG_FLAG_SKIP_DEFAULT_SETTING},
{CONFIG_DBCACHESIZE, CONFIG_TYPE_SIZE_T, "10000000", &ldbm_config_dbcachesize_get, &ldbm_config_dbcachesize_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
{CONFIG_DBNCACHE, CONFIG_TYPE_INT, "0", &ldbm_config_dbncache_get, &ldbm_config_dbncache_set, CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
{CONFIG_MAXPASSBEFOREMERGE, CONFIG_TYPE_INT, "100", &ldbm_config_maxpassbeforemerge_get, &ldbm_config_maxpassbeforemerge_set, 0},
@@ -1319,7 +1330,11 @@ int ldbm_config_load_dse_info(struct ldbminfo *li)
0, 0, 0);
return 1;
}
- parse_ldbm_config_entry(li, entries[0], ldbm_config);
+ if (0 != parse_ldbm_config_entry(li, entries[0], ldbm_config)) {
+ LDAPDebug(LDAP_DEBUG_ANY, "Error parsing the ldbm config DSE\n",
+ 0, 0, 0);
+ return 1;
+ }
}
if (search_pb) {
@@ -1520,6 +1535,9 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc
/* If the config phase is initialization or if bval is NULL, we will use
* the default value for the attribute. */
if (CONFIG_PHASE_INITIALIZATION == phase || NULL == bval) {
+ if (CONFIG_FLAG_SKIP_DEFAULT_SETTING & config->config_flags) {
+ return LDAP_SUCCESS; /* Skipping the default config setting */
+ }
use_default = 1;
} else {
use_default = 0;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.h b/ldap/servers/slapd/back-ldbm/ldbm_config.h
index 7a2ea5be..dbd38edf 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.h
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.h
@@ -72,6 +72,7 @@ typedef void *config_get_fn_t(void *arg);
#define CONFIG_FLAG_PREVIOUSLY_SET 1
#define CONFIG_FLAG_ALWAYS_SHOW 2
#define CONFIG_FLAG_ALLOW_RUNNING_CHANGE 4
+#define CONFIG_FLAG_SKIP_DEFAULT_SETTING 8
struct config_info {
char *config_name;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
index abe2299a..51d71a35 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
@@ -480,8 +480,12 @@ ldbm_instance_config_load_dse_info(ldbm_instance *inst)
0, 0, 0);
return 1;
}
- parse_ldbm_instance_config_entry(inst, entries[0],
- ldbm_instance_config);
+ if (0 != parse_ldbm_instance_config_entry(inst, entries[0],
+ ldbm_instance_config)) {
+ LDAPDebug(LDAP_DEBUG_ANY, "Error parsing the config DSE\n",
+ 0, 0, 0);
+ return 1;
+ }
}
if (search_pb)
diff --git a/ldap/servers/slapd/back-ldbm/start.c b/ldap/servers/slapd/back-ldbm/start.c
index e5c4299f..9b517eb1 100644
--- a/ldap/servers/slapd/back-ldbm/start.c
+++ b/ldap/servers/slapd/back-ldbm/start.c
@@ -63,7 +63,11 @@ ldbm_back_start( Slapi_PBlock *pb )
slapi_pblock_get( pb, SLAPI_PLUGIN_PRIVATE, &li );
/* parse the config file here */
- ldbm_config_load_dse_info(li);
+ if (0 != ldbm_config_load_dse_info(li)) {
+ LDAPDebug( LDAP_DEBUG_ANY, "start: Loading database configuration failed\n",
+ 0, 0, 0 );
+ return SLAPI_FAIL_GENERAL;
+ }
/* register with the binder-based resource limit subsystem so that */
/* lookthroughlimit can be supported on a per-connection basis. */
@@ -77,7 +81,7 @@ ldbm_back_start( Slapi_PBlock *pb )
/* If the db directory hasn't been set yet, we need to set it to
* the default. */
- if ('\0' == li->li_directory[0]) {
+ if (NULL == li->li_directory || '\0' == li->li_directory[0]) {
/* "get default" is a special string that tells the config
* routines to figure out the default db directory by
* reading cn=config. */