[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm ldbm_config.h, 1.6, 1.7 ldbm_instance_config.c, 1.9, 1.10 ldbm_config.c, 1.13, 1.14 dblayer.c, 1.25, 1.26 start.c, 1.7, 1.8
Noriko Hosoi (nhosoi)
fedora-directory-commits at redhat.com
Tue Dec 4 00:50:22 UTC 2007
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv29527
Modified Files:
ldbm_config.h ldbm_instance_config.c ldbm_config.c dblayer.c
start.c
Log Message:
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
Index: ldbm_config.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldbm_config.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ldbm_config.h 10 Nov 2006 23:45:39 -0000 1.6
+++ ldbm_config.h 4 Dec 2007 00:50:19 -0000 1.7
@@ -72,6 +72,7 @@
#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;
Index: ldbm_instance_config.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ldbm_instance_config.c 14 Nov 2007 15:04:51 -0000 1.9
+++ ldbm_instance_config.c 4 Dec 2007 00:50:19 -0000 1.10
@@ -480,8 +480,12 @@
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)
Index: ldbm_config.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldbm_config.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ldbm_config.c 28 Nov 2007 19:03:42 -0000 1.13
+++ ldbm_config.c 4 Dec 2007 00:50:19 -0000 1.14
@@ -243,75 +243,86 @@
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 @@
{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 @@
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 @@
/* 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;
Index: dblayer.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/dblayer.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- dblayer.c 18 Oct 2007 00:08:34 -0000 1.25
+++ dblayer.c 4 Dec 2007 00:50:19 -0000 1.26
@@ -1409,6 +1409,11 @@
/* 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;
Index: start.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/start.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- start.c 15 Mar 2007 21:34:32 -0000 1.7
+++ start.c 4 Dec 2007 00:50:19 -0000 1.8
@@ -63,7 +63,11 @@
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 @@
/* 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. */
More information about the Fedora-directory-commits
mailing list