summaryrefslogtreecommitdiffstats
path: root/ldap/servers
diff options
context:
space:
mode:
authorNoriko Hosoi <nhosoi@redhat.com>2006-10-13 01:06:29 +0000
committerNoriko Hosoi <nhosoi@redhat.com>2006-10-13 01:06:29 +0000
commit57e9577e0e96da39c62cc0b2c3ae3c053ff9232f (patch)
tree9c276cb9c3f35cec42e4c63c24fcba21f25b929e /ldap/servers
parent65dd96fe4a1effd42dfecaebd58c384ba7624518 (diff)
downloadds-57e9577e0e96da39c62cc0b2c3ae3c053ff9232f.tar.gz
ds-57e9577e0e96da39c62cc0b2c3ae3c053ff9232f.tar.xz
ds-57e9577e0e96da39c62cc0b2c3ae3c053ff9232f.zip
[208672] parameterizing the hardcoded paths (phase 2. db, log, lock, pid, cert, and instance dir)
1) introduced these 3 new config attributes: nsslapd-lockdir, nsslapd-tmpdir, nsslapd-certdir, and eliminated: nsslapd-instancedir. 2) replaced the hardcoded paths with the corresponding attribute value in the server as well as in the create/remove instance codes. 3) moved snmp stats file to the nsslapd-tmpdir 4) moved the server instance dir to <prefix>/lib/<brand>-ds/slapd-<id>
Diffstat (limited to 'ldap/servers')
-rw-r--r--ldap/servers/plugins/http/http_impl.c4
-rw-r--r--ldap/servers/plugins/rever/des.c14
-rw-r--r--ldap/servers/slapd/auth.c1
-rw-r--r--ldap/servers/slapd/back-ldbm/archive.c22
-rw-r--r--ldap/servers/slapd/back-ldbm/ldbm_config.c313
-rw-r--r--ldap/servers/slapd/back-ldbm/ldbm_config.h2
-rw-r--r--ldap/servers/slapd/ch_malloc.c3
-rw-r--r--ldap/servers/slapd/config.c51
-rw-r--r--ldap/servers/slapd/libglobs.c197
-rw-r--r--ldap/servers/slapd/libslapd.def6
-rw-r--r--ldap/servers/slapd/log.c9
-rw-r--r--ldap/servers/slapd/main.c11
-rw-r--r--ldap/servers/slapd/protect_db.c652
-rw-r--r--ldap/servers/slapd/proto-slap.h10
-rw-r--r--ldap/servers/slapd/slap.h21
-rw-r--r--ldap/servers/slapd/snmp_collator.c64
-rw-r--r--ldap/servers/slapd/ssl.c90
17 files changed, 720 insertions, 750 deletions
diff --git a/ldap/servers/plugins/http/http_impl.c b/ldap/servers/plugins/http/http_impl.c
index 2dac90a9..ee4f7ab3 100644
--- a/ldap/servers/plugins/http/http_impl.c
+++ b/ldap/servers/plugins/http/http_impl.c
@@ -326,7 +326,7 @@ static int doRequest(const char *url, httpheader **httpheaderArray, char *body,
NSS_Shutdown();
nssFlags &= (~NSS_INIT_READONLY);
- val = config_get_instancedir();
+ val = config_get_certdir();
PL_strncpyz(certDir, val, sizeof(certDir));
defaultprefix = strrchr(certDir, '/');
if (!defaultprefix)
@@ -336,8 +336,6 @@ static int doRequest(const char *url, httpheader **httpheaderArray, char *body,
defaultprefix++;
PR_snprintf(certPref, 1024, "%s-",defaultprefix);
PL_strncpyz(keyPref, certPref, sizeof(keyPref));
- *defaultprefix= '\0';
- PR_snprintf(certDir, 1024, "%salias", certDir);
nssStatus = NSS_Initialize(certDir, certPref, keyPref, "secmod.db", nssFlags);
slapi_ch_free((void **)&val);
diff --git a/ldap/servers/plugins/rever/des.c b/ldap/servers/plugins/rever/des.c
index 3207789b..049f2a01 100644
--- a/ldap/servers/plugins/rever/des.c
+++ b/ldap/servers/plugins/rever/des.c
@@ -214,7 +214,7 @@ static SVRCOREError genKey(struct pk11ContextStore **out, const char *token, cha
CK_MECHANISM pbeMech;
CK_MECHANISM cryptoMech;
- char *instancedir = NULL;
+ char *configdir = NULL;
char *iv = NULL;
store = (struct pk11ContextStore*)slapi_ch_malloc(sizeof(*store));
@@ -243,22 +243,22 @@ static SVRCOREError genKey(struct pk11ContextStore **out, const char *token, cha
/* Generate a unique id, used as salt for the key generation */
if ( path == NULL )
{
- instancedir = config_get_instancedir();
- if ( instancedir == NULL )
+ configdir = config_get_configdir();
+ if ( configdir == NULL )
{
return (err = SVRCORE_System_Error);
}
}
else
{
- instancedir = slapi_ch_strdup(path);
+ configdir = slapi_ch_strdup(path);
}
- if ( slapi_uniqueIDGenerateFromNameString (&iv, NULL, instancedir, strlen(instancedir)) != UID_SUCCESS )
+ if ( slapi_uniqueIDGenerateFromNameString (&iv, NULL, configdir, strlen(configdir)) != UID_SUCCESS )
{
- slapi_ch_free((void**)&instancedir);
+ slapi_ch_free((void**)&configdir);
return (err = SVRCORE_System_Error);
}
- slapi_ch_free((void**)&instancedir);
+ slapi_ch_free((void**)&configdir);
pwitem = (SECItem *) PORT_Alloc(sizeof(SECItem));
if (pwitem == NULL)
diff --git a/ldap/servers/slapd/auth.c b/ldap/servers/slapd/auth.c
index f7bf89db..9f0a614a 100644
--- a/ldap/servers/slapd/auth.c
+++ b/ldap/servers/slapd/auth.c
@@ -271,7 +271,6 @@ slapu_value_free_len( LDAP* ld, struct berval **values )
void
client_auth_init ()
{
- char *instancedir;
int err;
if (client_auth_config_file == NULL) {
char *confdir = config_get_configdir();
diff --git a/ldap/servers/slapd/back-ldbm/archive.c b/ldap/servers/slapd/back-ldbm/archive.c
index cb317b52..46b7a5b4 100644
--- a/ldap/servers/slapd/back-ldbm/archive.c
+++ b/ldap/servers/slapd/back-ldbm/archive.c
@@ -42,9 +42,7 @@
int ldbm_back_archive2ldbm( Slapi_PBlock *pb )
{
struct ldbminfo *li;
- char *instancedir = NULL;
- char *orig_dir = NULL;
- char *directory = NULL;
+ char *directory = NULL; /* -a <directory> */
char *backendname = NULL;
int return_value = -1;
int task_flags = 0;
@@ -53,19 +51,17 @@ int ldbm_back_archive2ldbm( Slapi_PBlock *pb )
int is_old_to_new = 0;
slapi_pblock_get( pb, SLAPI_PLUGIN_PRIVATE, &li );
- slapi_pblock_get( pb, SLAPI_SEQ_VAL, &orig_dir );
+ slapi_pblock_get( pb, SLAPI_SEQ_VAL, &directory );
slapi_pblock_get( pb, SLAPI_BACKEND_INSTANCE_NAME, &backendname);
slapi_pblock_get( pb, SLAPI_BACKEND_TASK, &task );
slapi_pblock_get( pb, SLAPI_TASK_FLAGS, &task_flags );
li->li_flags = run_from_cmdline = (task_flags & TASK_RUNNING_FROM_COMMANDLINE);
- if ( !orig_dir || !*orig_dir ) {
+ if ( !directory || !*directory ) {
LDAPDebug( LDAP_DEBUG_ANY, "archive2db: no archive name\n",
0, 0, 0 );
return( -1 );
}
- instancedir = config_get_instancedir();
- directory = rel2abspath_ext(orig_dir, instancedir);
/* check the current idl format vs backup DB version */
if (idl_get_idl_new())
@@ -248,17 +244,14 @@ int ldbm_back_archive2ldbm( Slapi_PBlock *pb )
}
}
out:
- slapi_ch_free_string(&directory);
return return_value;
}
int ldbm_back_ldbm2archive( Slapi_PBlock *pb )
{
struct ldbminfo *li;
- char *orig_dir = NULL;
- char *directory = NULL;
+ char *directory = NULL; /* -a <directory> */
char *dir_bak = NULL;
- char *instancedir = NULL;
int return_value = -1;
int task_flags = 0;
int run_from_cmdline = 0;
@@ -266,19 +259,17 @@ int ldbm_back_ldbm2archive( Slapi_PBlock *pb )
struct stat sbuf;
slapi_pblock_get( pb, SLAPI_PLUGIN_PRIVATE, &li );
- slapi_pblock_get( pb, SLAPI_SEQ_VAL, &orig_dir );
+ slapi_pblock_get( pb, SLAPI_SEQ_VAL, &directory );
slapi_pblock_get( pb, SLAPI_TASK_FLAGS, &task_flags );
li->li_flags = run_from_cmdline = (task_flags & TASK_RUNNING_FROM_COMMANDLINE);
slapi_pblock_get( pb, SLAPI_BACKEND_TASK, &task );
- if ( !orig_dir || !*orig_dir ) {
+ if ( !directory || !*directory ) {
LDAPDebug( LDAP_DEBUG_ANY, "db2archive: no archive name\n",
0, 0, 0 );
return( -1 );
}
- instancedir = config_get_instancedir();
- directory = rel2abspath_ext(orig_dir, instancedir);
if (stat(directory, &sbuf) == 0) {
int baklen = strlen(directory) + 5; /* ".bak\0" */
dir_bak = slapi_ch_malloc(baklen);
@@ -446,6 +437,5 @@ err:
}
out:
slapi_ch_free_string(&dir_bak);
- slapi_ch_free_string(&directory);
return return_value;
}
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c b/ldap/servers/slapd/back-ldbm/ldbm_config.c
index 9021dd7f..08fb22ef 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c
@@ -226,13 +226,10 @@ static int ldbm_config_directory_set(void *arg, void *value, char *errorbuf, int
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")) {
- /* Generate the default db directory name. The default db directory
- * should be the instance directory with a '/db' thrown on the end.
- * We need to read cn=config to get the instance dir. */
/* 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. */
-
+ * 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;
@@ -241,30 +238,33 @@ static int ldbm_config_directory_set(void *arg, void *value, char *errorbuf, int
int res;
search_pb = slapi_pblock_new();
- slapi_search_internal_set_pb(search_pb, "cn=config", LDAP_SCOPE_BASE,
- "objectclass=*", NULL, 0, NULL, NULL, li->li_identity, 0);
+ 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 cn=config\n",
- 0, 0, 0);
+ 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 cn=config\n",
- 0, 0, 0);
+ 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-instancedir", &attr);
+ 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-instancedir from cn=config\n",
- 0, 0, 0);
+ "ERROR: ldbm plugin unable to read attribute nsslapd-directory from %s\n",
+ CONFIG_LDBM_DN, 0, 0);
res = LDAP_OPERATIONS_ERROR;
goto done;
}
@@ -273,8 +273,8 @@ static int ldbm_config_directory_set(void *arg, void *value, char *errorbuf, int
|| ( NULL == v )
|| ( NULL == ( s = slapi_value_get_string( v )))) {
LDAPDebug(LDAP_DEBUG_ANY,
- "ERROR: ldbm plugin unable to read attribute nsslapd-instancedir from cn=config\n",
- 0, 0, 0);
+ "ERROR: ldbm plugin unable to read attribute nsslapd-directory from %s\n",
+ CONFIG_LDBM_DN, 0, 0);
res = LDAP_OPERATIONS_ERROR;
goto done;
}
@@ -284,7 +284,7 @@ done:
if (res != LDAP_SUCCESS) {
return res;
}
- PR_snprintf(tmpbuf, BUFSIZ, "%s/db", s );
+ PR_snprintf(tmpbuf, BUFSIZ, "%s", s);
val = tmpbuf;
}
slapi_ch_free((void **) &(li->li_new_directory));
@@ -350,7 +350,7 @@ static int ldbm_config_maxpassbeforemerge_set(void *arg, void *value, char *erro
val = 100;
}
- li->li_maxpassbeforemerge = val;
+ li->li_maxpassbeforemerge = val;
}
return retval;
@@ -661,7 +661,7 @@ static int ldbm_config_db_trickle_percentage_set(void *arg, void *value, char *e
if (val < 0 || val > 100) {
PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Error: Invalid value for %s (%d). Must be between 0 and 100\n", CONFIG_DB_TRICKLE_PERCENTAGE, val);
+ "Error: Invalid value for %s (%d). Must be between 0 and 100\n", CONFIG_DB_TRICKLE_PERCENTAGE, val);
LDAPDebug(LDAP_DEBUG_ANY, "%s", errorbuf, 0, 0);
return LDAP_UNWILLING_TO_PERFORM;
}
@@ -896,12 +896,12 @@ static void *ldbm_config_import_cache_autosize_get(void *arg)
}
static int ldbm_config_import_cache_autosize_set(void *arg, void *value, char *errorbuf,
- int phase, int apply)
+ int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *)arg;
if (apply)
- li->li_import_cache_autosize = (int)value;
+ li->li_import_cache_autosize = (int)value;
return LDAP_SUCCESS;
}
@@ -913,12 +913,12 @@ static void *ldbm_config_cache_autosize_get(void *arg)
}
static int ldbm_config_cache_autosize_set(void *arg, void *value, char *errorbuf,
- int phase, int apply)
+ int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *)arg;
if (apply)
- li->li_cache_autosize = (int)value;
+ li->li_cache_autosize = (int)value;
return LDAP_SUCCESS;
}
@@ -930,12 +930,12 @@ static void *ldbm_config_cache_autosize_split_get(void *arg)
}
static int ldbm_config_cache_autosize_split_set(void *arg, void *value, char *errorbuf,
- int phase, int apply)
+ int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *)arg;
if (apply)
- li->li_cache_autosize_split = (int)value;
+ li->li_cache_autosize_split = (int)value;
return LDAP_SUCCESS;
}
@@ -1090,7 +1090,7 @@ static void *ldbm_config_get_use_vlv_index(void *arg)
static int
ldbm_config_exclude_from_export_set( void *arg, void *value, char *errorbuf,
- int phase, int apply)
+ int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *)arg;
@@ -1114,12 +1114,12 @@ static void *
ldbm_config_exclude_from_export_get( void *arg )
{
struct ldbminfo *li = (struct ldbminfo *)arg;
- char *p, *retstr = NULL;
- size_t len = 0;
+ char *p, *retstr = NULL;
+ size_t len = 0;
if ( NULL != li->li_attrs_to_exclude_from_export &&
NULL != li->li_attrs_to_exclude_from_export[0] ) {
- int i;
+ int i;
for ( i = 0; li->li_attrs_to_exclude_from_export[i] != NULL; ++i ) {
len += strlen( li->li_attrs_to_exclude_from_export[i] ) + 1;
@@ -1171,59 +1171,59 @@ static int ldbm_config_db_tx_max_set(
* Configuration array for ldbm and dblayer variables
*----------------------------------------------------------------------*/
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_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},
-
- /* dblayer config attributes */
- {CONFIG_DB_LOGDIRECTORY, CONFIG_TYPE_STRING, "", &ldbm_config_db_logdirectory_get, &ldbm_config_db_logdirectory_set, CONFIG_FLAG_ALWAYS_SHOW},
- {CONFIG_DB_DURABLE_TRANSACTIONS, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_durable_transactions_get, &ldbm_config_db_durable_transactions_set, CONFIG_FLAG_ALWAYS_SHOW},
- {CONFIG_DB_CIRCULAR_LOGGING, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_circular_logging_get, &ldbm_config_db_circular_logging_set, 0},
- {CONFIG_DB_TRANSACTION_LOGGING, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_transaction_logging_get, &ldbm_config_db_transaction_logging_set, CONFIG_FLAG_ALWAYS_SHOW},
- {CONFIG_DB_CHECKPOINT_INTERVAL, CONFIG_TYPE_INT, "60", &ldbm_config_db_checkpoint_interval_get, &ldbm_config_db_checkpoint_interval_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_DB_TRANSACTION_BATCH, CONFIG_TYPE_INT, "0", &dblayer_get_batch_transactions, &dblayer_set_batch_transactions, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_DB_LOGBUF_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_logbuf_size_get, &ldbm_config_db_logbuf_size_set, CONFIG_FLAG_ALWAYS_SHOW},
- {CONFIG_DB_PAGE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_page_size_get, &ldbm_config_db_page_size_set, 0},
- {CONFIG_DB_INDEX_PAGE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_index_page_size_get, &ldbm_config_db_index_page_size_set, 0},
- {CONFIG_DB_IDL_DIVISOR, CONFIG_TYPE_INT, "0", &ldbm_config_db_idl_divisor_get, &ldbm_config_db_idl_divisor_set, 0},
- {CONFIG_DB_LOGFILE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_logfile_size_get, &ldbm_config_db_logfile_size_set, 0},
- {CONFIG_DB_TRICKLE_PERCENTAGE, CONFIG_TYPE_INT, "5", &ldbm_config_db_trickle_percentage_get, &ldbm_config_db_trickle_percentage_set, 0},
- {CONFIG_DB_SPIN_COUNT, CONFIG_TYPE_INT, "0", &ldbm_config_db_spin_count_get, &ldbm_config_db_spin_count_set, 0},
- {CONFIG_DB_VERBOSE, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_verbose_get, &ldbm_config_db_verbose_set, 0},
- {CONFIG_DB_DEBUG, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_debug_get, &ldbm_config_db_debug_set, 0},
- {CONFIG_DB_NAMED_REGIONS, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_named_regions_get, &ldbm_config_db_named_regions_set, 0},
- {CONFIG_DB_LOCK, CONFIG_TYPE_INT, "10000", &ldbm_config_db_lock_get, &ldbm_config_db_lock_set, 0},
- {CONFIG_DB_PRIVATE_MEM, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_private_mem_get, &ldbm_config_db_private_mem_set, 0},
- {CONFIG_DB_PRIVATE_IMPORT_MEM, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_private_import_mem_get, &ldbm_config_db_private_import_mem_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_DB_SHM_KEY, CONFIG_TYPE_LONG, "389389", &ldbm_config_db_shm_key_get, &ldbm_config_db_shm_key_set, 0},
- {CONFIG_DB_CACHE, CONFIG_TYPE_INT, "0", &ldbm_config_db_cache_get, &ldbm_config_db_cache_set, 0},
- {CONFIG_DB_DEBUG_CHECKPOINTING, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_debug_checkpointing_get, &ldbm_config_db_debug_checkpointing_set, 0},
- {CONFIG_DB_HOME_DIRECTORY, CONFIG_TYPE_STRING, "", &ldbm_config_db_home_directory_get, &ldbm_config_db_home_directory_set, 0},
- {CONFIG_IMPORT_CACHE_AUTOSIZE, CONFIG_TYPE_INT, "-1", &ldbm_config_import_cache_autosize_get, &ldbm_config_import_cache_autosize_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_CACHE_AUTOSIZE, CONFIG_TYPE_INT, "0", &ldbm_config_cache_autosize_get, &ldbm_config_cache_autosize_set, 0},
- {CONFIG_CACHE_AUTOSIZE_SPLIT, CONFIG_TYPE_INT, "50", &ldbm_config_cache_autosize_split_get, &ldbm_config_cache_autosize_split_set, 0},
- {CONFIG_IMPORT_CACHESIZE, CONFIG_TYPE_SIZE_T, "20000000", &ldbm_config_import_cachesize_get, &ldbm_config_import_cachesize_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
+ {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_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},
+
+ /* dblayer config attributes */
+ {CONFIG_DB_LOGDIRECTORY, CONFIG_TYPE_STRING, "", &ldbm_config_db_logdirectory_get, &ldbm_config_db_logdirectory_set, CONFIG_FLAG_ALWAYS_SHOW},
+ {CONFIG_DB_DURABLE_TRANSACTIONS, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_durable_transactions_get, &ldbm_config_db_durable_transactions_set, CONFIG_FLAG_ALWAYS_SHOW},
+ {CONFIG_DB_CIRCULAR_LOGGING, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_circular_logging_get, &ldbm_config_db_circular_logging_set, 0},
+ {CONFIG_DB_TRANSACTION_LOGGING, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_transaction_logging_get, &ldbm_config_db_transaction_logging_set, CONFIG_FLAG_ALWAYS_SHOW},
+ {CONFIG_DB_CHECKPOINT_INTERVAL, CONFIG_TYPE_INT, "60", &ldbm_config_db_checkpoint_interval_get, &ldbm_config_db_checkpoint_interval_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
+ {CONFIG_DB_TRANSACTION_BATCH, CONFIG_TYPE_INT, "0", &dblayer_get_batch_transactions, &dblayer_set_batch_transactions, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
+ {CONFIG_DB_LOGBUF_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_logbuf_size_get, &ldbm_config_db_logbuf_size_set, CONFIG_FLAG_ALWAYS_SHOW},
+ {CONFIG_DB_PAGE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_page_size_get, &ldbm_config_db_page_size_set, 0},
+ {CONFIG_DB_INDEX_PAGE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_index_page_size_get, &ldbm_config_db_index_page_size_set, 0},
+ {CONFIG_DB_IDL_DIVISOR, CONFIG_TYPE_INT, "0", &ldbm_config_db_idl_divisor_get, &ldbm_config_db_idl_divisor_set, 0},
+ {CONFIG_DB_LOGFILE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_logfile_size_get, &ldbm_config_db_logfile_size_set, 0},
+ {CONFIG_DB_TRICKLE_PERCENTAGE, CONFIG_TYPE_INT, "5", &ldbm_config_db_trickle_percentage_get, &ldbm_config_db_trickle_percentage_set, 0},
+ {CONFIG_DB_SPIN_COUNT, CONFIG_TYPE_INT, "0", &ldbm_config_db_spin_count_get, &ldbm_config_db_spin_count_set, 0},
+ {CONFIG_DB_VERBOSE, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_verbose_get, &ldbm_config_db_verbose_set, 0},
+ {CONFIG_DB_DEBUG, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_debug_get, &ldbm_config_db_debug_set, 0},
+ {CONFIG_DB_NAMED_REGIONS, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_named_regions_get, &ldbm_config_db_named_regions_set, 0},
+ {CONFIG_DB_LOCK, CONFIG_TYPE_INT, "10000", &ldbm_config_db_lock_get, &ldbm_config_db_lock_set, 0},
+ {CONFIG_DB_PRIVATE_MEM, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_private_mem_get, &ldbm_config_db_private_mem_set, 0},
+ {CONFIG_DB_PRIVATE_IMPORT_MEM, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_private_import_mem_get, &ldbm_config_db_private_import_mem_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
+ {CONFIG_DB_SHM_KEY, CONFIG_TYPE_LONG, "389389", &ldbm_config_db_shm_key_get, &ldbm_config_db_shm_key_set, 0},
+ {CONFIG_DB_CACHE, CONFIG_TYPE_INT, "0", &ldbm_config_db_cache_get, &ldbm_config_db_cache_set, 0},
+ {CONFIG_DB_DEBUG_CHECKPOINTING, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_debug_checkpointing_get, &ldbm_config_db_debug_checkpointing_set, 0},
+ {CONFIG_DB_HOME_DIRECTORY, CONFIG_TYPE_STRING, "", &ldbm_config_db_home_directory_get, &ldbm_config_db_home_directory_set, 0},
+ {CONFIG_IMPORT_CACHE_AUTOSIZE, CONFIG_TYPE_INT, "-1", &ldbm_config_import_cache_autosize_get, &ldbm_config_import_cache_autosize_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
+ {CONFIG_CACHE_AUTOSIZE, CONFIG_TYPE_INT, "0", &ldbm_config_cache_autosize_get, &ldbm_config_cache_autosize_set, 0},
+ {CONFIG_CACHE_AUTOSIZE_SPLIT, CONFIG_TYPE_INT, "50", &ldbm_config_cache_autosize_split_get, &ldbm_config_cache_autosize_split_set, 0},
+ {CONFIG_IMPORT_CACHESIZE, CONFIG_TYPE_SIZE_T, "20000000", &ldbm_config_import_cachesize_get, &ldbm_config_import_cachesize_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
#if defined(USE_NEW_IDL)
- {CONFIG_IDL_SWITCH, CONFIG_TYPE_STRING, "new", &ldbm_config_idl_get_idl_new, &ldbm_config_idl_set_tune, CONFIG_FLAG_ALWAYS_SHOW},
+ {CONFIG_IDL_SWITCH, CONFIG_TYPE_STRING, "new", &ldbm_config_idl_get_idl_new, &ldbm_config_idl_set_tune, CONFIG_FLAG_ALWAYS_SHOW},
#else
- {CONFIG_IDL_SWITCH, CONFIG_TYPE_STRING, "old", &ldbm_config_idl_get_idl_new, &ldbm_config_idl_set_tune, CONFIG_FLAG_ALWAYS_SHOW},
+ {CONFIG_IDL_SWITCH, CONFIG_TYPE_STRING, "old", &ldbm_config_idl_get_idl_new, &ldbm_config_idl_set_tune, CONFIG_FLAG_ALWAYS_SHOW},
#endif
- {CONFIG_BYPASS_FILTER_TEST, CONFIG_TYPE_STRING, "on", &ldbm_config_get_bypass_filter_test, &ldbm_config_set_bypass_filter_test, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_USE_VLV_INDEX, CONFIG_TYPE_ONOFF, "on", &ldbm_config_get_use_vlv_index, &ldbm_config_set_use_vlv_index, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_DB_LOCKDOWN, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_lockdown_get, &ldbm_config_db_lockdown_set, 0},
- {CONFIG_INDEX_BUFFER_SIZE, CONFIG_TYPE_INT, "0", &ldbm_config_index_buffer_size_get, &ldbm_config_index_buffer_size_set, 0},
- {CONFIG_EXCLUDE_FROM_EXPORT, CONFIG_TYPE_STRING,
- CONFIG_EXCLUDE_FROM_EXPORT_DEFAULT_VALUE,
- &ldbm_config_exclude_from_export_get,
- &ldbm_config_exclude_from_export_set, CONFIG_FLAG_ALWAYS_SHOW},
- {CONFIG_DB_TX_MAX, CONFIG_TYPE_INT, "200", &ldbm_config_db_tx_max_get, &ldbm_config_db_tx_max_set, 0},
- {CONFIG_SERIAL_LOCK, CONFIG_TYPE_ONOFF, "on", &ldbm_config_serial_lock_get, &ldbm_config_serial_lock_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_USE_LEGACY_ERRORCODE, CONFIG_TYPE_ONOFF, "off", &ldbm_config_legacy_errcode_get, &ldbm_config_legacy_errcode_set, 0},
- {NULL, 0, NULL, NULL, NULL, 0}
+ {CONFIG_BYPASS_FILTER_TEST, CONFIG_TYPE_STRING, "on", &ldbm_config_get_bypass_filter_test, &ldbm_config_set_bypass_filter_test, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
+ {CONFIG_USE_VLV_INDEX, CONFIG_TYPE_ONOFF, "on", &ldbm_config_get_use_vlv_index, &ldbm_config_set_use_vlv_index, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
+ {CONFIG_DB_LOCKDOWN, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_lockdown_get, &ldbm_config_db_lockdown_set, 0},
+ {CONFIG_INDEX_BUFFER_SIZE, CONFIG_TYPE_INT, "0", &ldbm_config_index_buffer_size_get, &ldbm_config_index_buffer_size_set, 0},
+ {CONFIG_EXCLUDE_FROM_EXPORT, CONFIG_TYPE_STRING,
+ CONFIG_EXCLUDE_FROM_EXPORT_DEFAULT_VALUE,
+ &ldbm_config_exclude_from_export_get,
+ &ldbm_config_exclude_from_export_set, CONFIG_FLAG_ALWAYS_SHOW},
+ {CONFIG_DB_TX_MAX, CONFIG_TYPE_INT, "200", &ldbm_config_db_tx_max_get, &ldbm_config_db_tx_max_set, 0},
+ {CONFIG_SERIAL_LOCK, CONFIG_TYPE_ONOFF, "on", &ldbm_config_serial_lock_get, &ldbm_config_serial_lock_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
+ {CONFIG_USE_LEGACY_ERRORCODE, CONFIG_TYPE_ONOFF, "off", &ldbm_config_legacy_errcode_get, &ldbm_config_legacy_errcode_set, 0},
+ {NULL, 0, NULL, NULL, NULL, 0}
};
void ldbm_config_setup_default(struct ldbminfo *li)
@@ -1279,7 +1279,7 @@ int ldbm_config_load_dse_info(struct ldbminfo *li)
* there, then we process the config information it stores.
*/
PR_snprintf(dn, BUFSIZ, "cn=config, cn=%s, cn=plugins, cn=config",
- li->li_plugin->plg_name);
+ li->li_plugin->plg_name);
search_pb = slapi_pblock_new();
slapi_search_internal_set_pb(search_pb, dn, LDAP_SCOPE_BASE,
"objectclass=*", NULL, 0, NULL, NULL, li->li_identity, 0);
@@ -1304,14 +1304,14 @@ int ldbm_config_load_dse_info(struct ldbminfo *li)
0, 0, 0);
return 1;
}
- parse_ldbm_config_entry(li, entries[0], ldbm_config);
+ parse_ldbm_config_entry(li, entries[0], ldbm_config);
}
if (search_pb) {
slapi_free_search_results_internal(search_pb);
slapi_pblock_destroy(search_pb);
}
-
+
/* Find all the instance entries and create a Slapi_Backend and an
* ldbm_instance for each */
ldbm_config_read_instance_entries(li, li->li_plugin->plg_name);
@@ -1371,14 +1371,14 @@ int ldbm_config_load_dse_info(struct ldbminfo *li)
void ldbm_config_get(void *arg, config_info *config, char *buf)
{
char *tmp_string;
- size_t val = 0;
+ size_t val = 0;
if (config == NULL) {
buf[0] = '\0';
}
switch(config->config_type) {
- case CONFIG_TYPE_INT:
+ case CONFIG_TYPE_INT:
sprintf(buf, "%d", (int) config->config_get_fn(arg));
break;
case CONFIG_TYPE_INT_OCTAL:
@@ -1388,7 +1388,7 @@ void ldbm_config_get(void *arg, config_info *config, char *buf)
sprintf(buf, "%ld", (long) config->config_get_fn(arg));
break;
case CONFIG_TYPE_SIZE_T:
- val = (size_t) config->config_get_fn(arg);
+ val = (size_t) config->config_get_fn(arg);
sprintf(buf, "%lu", val);
break;
case CONFIG_TYPE_STRING:
@@ -1475,17 +1475,17 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc
int int_val;
long long_val;
size_t sz_val;
- PRInt64 llval;
- int maxint = (int)(((unsigned int)~0)>>1);
- int minint = ~maxint;
- PRInt64 llmaxint;
- PRInt64 llminint;
- int err = 0;
- char *str_val;
+ PRInt64 llval;
+ int maxint = (int)(((unsigned int)~0)>>1);
+ int minint = ~maxint;
+ PRInt64 llmaxint;
+ PRInt64 llminint;
+ int err = 0;
+ char *str_val;
int retval = 0;
- LL_I2L(llmaxint, maxint);
- LL_I2L(llminint, minint);
+ LL_I2L(llmaxint, maxint);
+ LL_I2L(llminint, minint);
config = get_config_info(config_array, attr_name);
if (NULL == config) {
@@ -1505,7 +1505,7 @@ 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) {
- use_default = 1;
+ use_default = 1;
} else {
use_default = 0;
@@ -1518,33 +1518,33 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc
switch(config->config_type) {
case CONFIG_TYPE_INT:
if (use_default) {
- str_val = config->config_default_value;
+ str_val = config->config_default_value;
} else {
- str_val = bval->bv_val;
+ str_val = bval->bv_val;
+ }
+ /* get the value as a 64 bit value */
+ llval = db_atoi(str_val, &err);
+ /* check for parsing error (e.g. not a number) */
+ if (err) {
+ PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is not a number\n",
+ str_val, attr_name);
+ LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
+ return LDAP_UNWILLING_TO_PERFORM;
+ /* check for overflow */
+ } else if (LL_CMP(llval, >, llmaxint)) {
+ PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is greater than the maximum %d\n",
+ str_val, attr_name, maxint);
+ LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
+ return LDAP_UNWILLING_TO_PERFORM;
+ /* check for underflow */
+ } else if (LL_CMP(llval, <, llminint)) {
+ PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is less than the minimum %d\n",
+ str_val, attr_name, minint);
+ LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
+ return LDAP_UNWILLING_TO_PERFORM;
}
- /* get the value as a 64 bit value */
- llval = db_atoi(str_val, &err);
- /* check for parsing error (e.g. not a number) */
- if (err) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is not a number\n",
- str_val, attr_name);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
- /* check for overflow */
- } else if (LL_CMP(llval, >, llmaxint)) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is greater than the maximum %d\n",
- str_val, attr_name, maxint);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
- /* check for underflow */
- } else if (LL_CMP(llval, <, llminint)) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is less than the minimum %d\n",
- str_val, attr_name, minint);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
- }
- /* convert 64 bit value to 32 bit value */
- LL_L2I(int_val, llval);
+ /* convert 64 bit value to 32 bit value */
+ LL_L2I(int_val, llval);
retval = config->config_set_fn(arg, (void *) int_val, err_buf, phase, apply_mod);
break;
case CONFIG_TYPE_INT_OCTAL:
@@ -1553,37 +1553,37 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc
} else {
int_val = (int) strtol((char *)bval->bv_val, NULL, 8);
}
- retval = config->config_set_fn(arg, (void *) int_val, err_buf, phase, apply_mod);
- break;
+ retval = config->config_set_fn(arg, (void *) int_val, err_buf, phase, apply_mod);
+ break;
case CONFIG_TYPE_LONG:
if (use_default) {
- str_val = config->config_default_value;
+ str_val = config->config_default_value;
} else {
- str_val = bval->bv_val;
+ str_val = bval->bv_val;
}
- /* get the value as a 64 bit value */
- llval = db_atoi(str_val, &err);
- /* check for parsing error (e.g. not a number) */
- if (err) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is not a number\n",
- str_val, attr_name);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
- /* check for overflow */
- } else if (LL_CMP(llval, >, llmaxint)) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is greater than the maximum %d\n",
- str_val, attr_name, maxint);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
- /* check for underflow */
- } else if (LL_CMP(llval, <, llminint)) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is less than the minimum %d\n",
- str_val, attr_name, minint);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
- }
- /* convert 64 bit value to 32 bit value */
- LL_L2I(long_val, llval);
+ /* get the value as a 64 bit value */
+ llval = db_atoi(str_val, &err);
+ /* check for parsing error (e.g. not a number) */
+ if (err) {
+ PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is not a number\n",
+ str_val, attr_name);
+ LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
+ return LDAP_UNWILLING_TO_PERFORM;
+ /* check for overflow */
+ } else if (LL_CMP(llval, >, llmaxint)) {
+ PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is greater than the maximum %d\n",
+ str_val, attr_name, maxint);
+ LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
+ return LDAP_UNWILLING_TO_PERFORM;
+ /* check for underflow */
+ } else if (LL_CMP(llval, <, llminint)) {
+ PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is less than the minimum %d\n",
+ str_val, attr_name, minint);
+ LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
+ return LDAP_UNWILLING_TO_PERFORM;
+ }
+ /* convert 64 bit value to 32 bit value */
+ LL_L2I(long_val, llval);
retval = config->config_set_fn(arg, (void *) long_val, err_buf, phase, apply_mod);
break;
case CONFIG_TYPE_SIZE_T:
@@ -1615,7 +1615,7 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc
if (use_default) {
retval = config->config_set_fn(arg, config->config_default_value, err_buf, phase, apply_mod);
} else {
- retval = config->config_set_fn(arg, bval->bv_val, err_buf, phase, apply_mod);
+ retval = config->config_set_fn(arg, bval->bv_val, err_buf, phase, apply_mod);
}
break;
case CONFIG_TYPE_ONOFF:
@@ -1663,7 +1663,7 @@ static int parse_ldbm_config_entry(struct ldbminfo *li, Slapi_Entry *e, config_i
* Returns:
* SLAPI_DSE_CALLBACK_ERROR on failure
* SLAPI_DSE_CALLBACK_OK on success
- */
+ */
int ldbm_config_modify_entry_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *returncode, char *returntext, void *arg)
{
int i;
@@ -1678,7 +1678,7 @@ int ldbm_config_modify_entry_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefore
PR_Lock(li->li_config_mutex);
slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
-
+
returntext[0] = '\0';
/*
@@ -1750,15 +1750,14 @@ void ldbm_config_internal_set(struct ldbminfo *li, char *attrname, char *value)
void replace_ldbm_config_value(char *conftype, char *val, struct ldbminfo *li)
{
Slapi_PBlock pb;
- Slapi_Mods smods;
+ Slapi_Mods smods;
pblock_init(&pb);
- slapi_mods_init(&smods, 1);
- slapi_mods_add(&smods, LDAP_MOD_REPLACE, conftype, strlen(val), val);
- slapi_modify_internal_set_pb(&pb,
- "cn=config,cn=ldbm database,cn=plugins,cn=config",
- slapi_mods_get_ldapmods_byref(&smods),
- NULL, NULL, li->li_identity, 0);
+ slapi_mods_init(&smods, 1);
+ slapi_mods_add(&smods, LDAP_MOD_REPLACE, conftype, strlen(val), val);
+ slapi_modify_internal_set_pb(&pb, CONFIG_LDBM_DN,
+ slapi_mods_get_ldapmods_byref(&smods),
+ NULL, NULL, li->li_identity, 0);
slapi_modify_internal_pb(&pb);
slapi_mods_done(&smods);
pblock_done(&pb);
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.h b/ldap/servers/slapd/back-ldbm/ldbm_config.h
index 1eb56a49..6dd11e7d 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.h
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.h
@@ -144,6 +144,8 @@ struct config_info {
#define CONFIG_USE_LEGACY_ERRORCODE "nsslapd-do-not-use-vlv-error"
+#define CONFIG_LDBM_DN "cn=config,cn=ldbm database,cn=plugins,cn=config"
+
#define LDBM_INSTANCE_CONFIG_DONT_WRITE 1
/* Some fuctions in ldbm_config.c used by ldbm_instance_config.c */
diff --git a/ldap/servers/slapd/ch_malloc.c b/ldap/servers/slapd/ch_malloc.c
index ab204539..4f3a90de 100644
--- a/ldap/servers/slapd/ch_malloc.c
+++ b/ldap/servers/slapd/ch_malloc.c
@@ -624,11 +624,12 @@ BOOL InitialiseImageHelp()
{
if (!SymInitialized)
{
+ /* OBSOLETE: we don't have this directory structure any longer */
/*
* searchpath= <instancedir>\bin\slapd\server;<instancedir>\lib
*/
char *searchpath= NULL;
- char *id= config_get_instancedir();
+ /* char *id= config_get_instancedir(); eliminated */
if(id!=NULL)
{
char *p= id;
diff --git a/ldap/servers/slapd/config.c b/ldap/servers/slapd/config.c
index 9cfdd8d4..fa6961f9 100644
--- a/ldap/servers/slapd/config.c
+++ b/ldap/servers/slapd/config.c
@@ -160,7 +160,6 @@ slapd_bootstrap_config(const char *configdir)
char *buf = 0;
char *lastp = 0;
char *entrystr = 0;
- char *instancedir = NULL;
if (NULL == configdir) {
slapi_log_error(SLAPI_LOG_FATAL,
@@ -261,29 +260,6 @@ slapd_bootstrap_config(const char *configdir)
entrystr, configfile, 0);
continue;
}
-
- /* if instancedir is not set, set it first */
- {
- instancedir = config_get_instancedir();
- if (NULL == instancedir) {
- workpath[0] = '\0';
- if (entry_has_attr_and_value(e,
- CONFIG_INSTANCEDIR_ATTRIBUTE,
- workpath, sizeof(workpath))) {
- if (config_set_instancedir(
- CONFIG_INSTANCEDIR_ATTRIBUTE,
- workpath, errorbuf, CONFIG_APPLY)
- != LDAP_SUCCESS) {
- LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s\n",
- configfile, CONFIG_INSTANCEDIR_ATTRIBUTE,
- errorbuf);
- }
- }
- } else {
- slapi_ch_free((void **)&instancedir);
- }
- }
-
/* increase file descriptors */
#if !defined(_WIN32) && !defined(AIX)
if (!maxdescriptors[0] &&
@@ -369,6 +345,19 @@ slapd_bootstrap_config(const char *configdir)
}
}
+ /* set the cert dir; needed in slapd_nss_init */
+ workpath[0] = '\0';
+ if (entry_has_attr_and_value(e, CONFIG_CERTDIR_ATTRIBUTE,
+ workpath, sizeof(workpath)))
+ {
+ if (config_set_certdir(CONFIG_CERTDIR_ATTRIBUTE,
+ workpath, errorbuf, CONFIG_APPLY) != LDAP_SUCCESS)
+ {
+ LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s. \n", configfile,
+ CONFIG_CERTDIR_ATTRIBUTE, errorbuf);
+ }
+ }
+
/* see if the entry is a child of the plugin base dn */
if (slapi_sdn_isparent(&plug_dn,
slapi_entry_get_sdn_const(e)))
@@ -390,6 +379,7 @@ slapd_bootstrap_config(const char *configdir)
}
}
}
+
/* see if the entry is a grand child of the plugin base dn */
if (slapi_sdn_isgrandparent(&plug_dn,
slapi_entry_get_sdn_const(e)))
@@ -517,19 +507,6 @@ slapd_bootstrap_config(const char *configdir)
if (e)
slapi_entry_free(e);
}
-
- /*
- * check if the instance dir is set.
- */
- if ( NULL == ( instancedir = config_get_instancedir() )) {
- slapi_log_error(SLAPI_LOG_FATAL, "startup",
- "Instance directory is not specifiled in the file %s. It is mandatory.\n",
- configfile);
- exit (1);
- } else {
- slapi_ch_free((void **)&instancedir);
- }
-
/* kexcoff: initialize rootpwstoragescheme and pw_storagescheme
* if not explicilty set in the config file
*/
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 7cb039b4..4d1495c5 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -513,16 +513,22 @@ static struct config_get_and_set {
CONFIG_CONSTANT_STRING, NULL},
{CONFIG_HASH_FILTERS_ATTRIBUTE, config_set_hash_filters,
NULL, 0, NULL, CONFIG_ON_OFF, (ConfigGetFunc)config_get_hash_filters},
- {CONFIG_INSTANCEDIR_ATTRIBUTE, config_set_instancedir,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.instancedir, CONFIG_STRING, NULL},
/* parameterizing schema dir */
{CONFIG_SCHEMADIR_ATTRIBUTE, config_set_schemadir,
NULL, 0,
(void**)&global_slapdFrontendConfig.schemadir, CONFIG_STRING, NULL},
- /* parameterizing ldif dir */
- {CONFIG_LDIFDIR_ATTRIBUTE, config_set_ldifdir,
- NULL, 0, NULL, CONFIG_STRING, NULL},
+ /* parameterizing lock dir */
+ {CONFIG_LOCKDIR_ATTRIBUTE, config_set_lockdir,
+ NULL, 0,
+ (void**)&global_slapdFrontendConfig.lockdir, CONFIG_STRING, config_get_lockdir},
+ /* parameterizing tmp dir */
+ {CONFIG_TMPDIR_ATTRIBUTE, config_set_tmpdir,
+ NULL, 0,
+ (void**)&global_slapdFrontendConfig.tmpdir, CONFIG_STRING, config_get_tmpdir},
+ /* parameterizing cert dir */
+ {CONFIG_CERTDIR_ATTRIBUTE, config_set_certdir,
+ NULL, 0,
+ (void**)&global_slapdFrontendConfig.certdir, CONFIG_STRING, config_get_certdir},
{CONFIG_REWRITE_RFC1274_ATTRIBUTE, config_set_rewrite_rfc1274,
NULL, 0,
(void**)&global_slapdFrontendConfig.rewrite_rfc1274, CONFIG_ON_OFF, NULL},
@@ -2325,44 +2331,6 @@ config_set_workingdir( const char *attrname, char *value, char *errorbuf, int ap
return retVal;
}
-int
-config_set_instancedir( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- if ( PR_Access ( value, PR_ACCESS_READ_OK ) != 0 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Directory \"%s\" is not accessible.", value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
-
- if ( apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->instancedir = slapi_ch_strdup ( value );
-#ifdef _WIN32
- dostounixpath(slapdFrontendConfig->instancedir);
-#endif /* _WIN32 */
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
-
- /* Set the slapd type also */
- config_set_slapd_type ();
-
- /* Set the configdir if not set (it must be set since 7.2) */
- if (!slapdFrontendConfig->configdir)
- {
- char newdir[MAXPATHLEN+1];
- PR_snprintf ( newdir, sizeof(newdir), "%s/%s",
- slapdFrontendConfig->instancedir, CONFIG_SUBDIR_NAME);
- retVal = config_set_configdir(attrname, newdir, errorbuf, apply);
- }
- }
- return retVal;
-}
-
/* alias of encryption key and certificate files is now retrieved through */
/* calls to psetFullCreate() and psetGetAttrSingleValue(). See ssl.c, */
/* where this function is still used to set the global variable */
@@ -3715,19 +3683,6 @@ config_get_localuser() {
}
#endif /* _WIN32 */
-
-char *
-config_get_instancedir() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval( slapdFrontendConfig->instancedir );
- CFG_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
-}
-
/* alias of encryption key and certificate files is now retrieved through */
/* calls to psetFullCreate() and psetGetAttrSingleValue(). See ssl.c, */
/* where this function is still used to set the global variable */
@@ -4067,27 +4022,6 @@ config_is_slapd_lite ()
return ( SLAPD_FULL );
}
-/* This function is called once at the startup time and no more */
-void
-config_set_slapd_type( )
-{
- char *root = NULL;
- char *s_root = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- CFG_LOCK_WRITE(slapdFrontendConfig);
- if ( slapdFrontendConfig->instancedir )
- s_root = root = slapi_ch_strdup ( slapdFrontendConfig->instancedir );
-
- if ( (root = strrchr( root, '/' )) != NULL ) {
- *root = '\0';
- }
- slapdFrontendConfig->slapd_type = 0;
- slapdFrontendConfig->versionstring = SLAPD_VERSION_STR;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free ( (void **) &s_root );
-}
-
int
config_set_maxbersize( const char *attrname, char *value, char *errorbuf, int apply )
{
@@ -4263,11 +4197,112 @@ config_set_schemadir(const char *attrname, char *value, char *errorbuf, int appl
return retVal;
}
+char *
+config_get_lockdir()
+{
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ char *retVal;
+
+ CFG_LOCK_READ(slapdFrontendConfig);
+ retVal = config_copy_strval(slapdFrontendConfig->lockdir);
+ CFG_UNLOCK_READ(slapdFrontendConfig);
+
+ return retVal;
+}
+
int
-config_set_ldifdir(const char *attrname, char *value, char *errorbuf, int apply)
+config_set_lockdir(const char *attrname, char *value, char *errorbuf, int apply)
{
- /* noop */
- return LDAP_SUCCESS;
+ int retVal = LDAP_SUCCESS;
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+
+ if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
+ return LDAP_OPERATIONS_ERROR;
+ }
+
+ if (!apply) {
+ return retVal;
+ }
+
+ CFG_LOCK_WRITE(slapdFrontendConfig);
+ slapi_ch_free((void **)&slapdFrontendConfig->lockdir);
+
+ slapdFrontendConfig->lockdir = slapi_ch_strdup(value);
+
+ CFG_UNLOCK_WRITE(slapdFrontendConfig);
+ return retVal;
+}
+
+char *
+config_get_tmpdir()
+{
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ char *retVal;
+
+ CFG_LOCK_READ(slapdFrontendConfig);
+ retVal = config_copy_strval(slapdFrontendConfig->tmpdir);
+ CFG_UNLOCK_READ(slapdFrontendConfig);
+
+ return retVal;
+}
+
+int
+config_set_tmpdir(const char *attrname, char *value, char *errorbuf, int apply)
+{
+ int retVal = LDAP_SUCCESS;
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+
+ if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
+ return LDAP_OPERATIONS_ERROR;
+ }
+
+ if (!apply) {
+ return retVal;
+ }
+
+ CFG_LOCK_WRITE(slapdFrontendConfig);
+ slapi_ch_free((void **)&slapdFrontendConfig->tmpdir);
+
+ slapdFrontendConfig->tmpdir = slapi_ch_strdup(value);
+
+ CFG_UNLOCK_WRITE(slapdFrontendConfig);
+ return retVal;
+}
+
+char *
+config_get_certdir()
+{
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ char *retVal;
+
+ CFG_LOCK_READ(slapdFrontendConfig);
+ retVal = config_copy_strval(slapdFrontendConfig->certdir);
+ CFG_UNLOCK_READ(slapdFrontendConfig);
+
+ return retVal;
+}
+
+int
+config_set_certdir(const char *attrname, char *value, char *errorbuf, int apply)
+{
+ int retVal = LDAP_SUCCESS;
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+
+ if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
+ return LDAP_OPERATIONS_ERROR;
+ }
+
+ if (!apply) {
+ return retVal;
+ }
+
+ CFG_LOCK_WRITE(slapdFrontendConfig);
+ slapi_ch_free((void **)&slapdFrontendConfig->certdir);
+
+ slapdFrontendConfig->certdir = slapi_ch_strdup(value);
+
+ CFG_UNLOCK_WRITE(slapdFrontendConfig);
+ return retVal;
}
char **
diff --git a/ldap/servers/slapd/libslapd.def b/ldap/servers/slapd/libslapd.def
index 3b55a27b..df116647 100644
--- a/ldap/servers/slapd/libslapd.def
+++ b/ldap/servers/slapd/libslapd.def
@@ -473,7 +473,7 @@ EXPORTS
slapi_build_control @437
slapi_entry_get_ndn @438
dse_unset_dont_ever_write_dse_files @439
- config_set_instancedir @440
+; config_set_instancedir @440
config_set_encryptionalias @441
config_set_threadnumber @442
config_set_maxthreadsperconn @443
@@ -537,7 +537,7 @@ EXPORTS
slapi_entry_set_sdn @501
slapi_sdn_copy @502
config_set_basedn @503
- config_get_instancedir @504
+; config_get_instancedir @504
config_get_encryptionalias @505
config_get_threadnumber @506
config_get_maxthreadsperconn @507
@@ -570,7 +570,7 @@ EXPORTS
attr_set_deletion_csn @534
slapi_mod_dump @535
config_is_slapd_lite @536
- config_set_slapd_type @537
+; config_set_slapd_type @537
config_get_versionstring @538
slapi_is_rootdse @539
slapi_find_matching_paren @540
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index 664c6d83..2138d36b 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -225,7 +225,8 @@ void g_log_init(int log_enabled)
{
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
#if defined( XP_WIN32 )
- char * instancedir = NULL;
+ /* char * instancedir = NULL; obsolete. */
+ /* To port to Windows, need to support FHS. */
#endif
ts_time_lock = PR_NewLock();
@@ -234,7 +235,7 @@ void g_log_init(int log_enabled)
#if defined( XP_WIN32 )
pszServerName = slapi_ch_malloc( MAX_SERVICE_NAME );
- instancedir = config_get_instancedir();
+ /* instancedir = config_get_instancedir(); eliminated */
unixtodospath(instancedir);
if( !SlapdGetServerNameFromCmdline(pszServerName, instancedir, 1) )
{
@@ -1578,14 +1579,14 @@ log_write_title (LOGFD fp)
PR_snprintf(buff, bufflen, "\t%s:%d (%s)\n\n",
fe_cfg->localhost,
fe_cfg->security ? fe_cfg->secureport : fe_cfg->port,
- fe_cfg->instancedir ? fe_cfg->instancedir : "");
+ fe_cfg->configdir ? fe_cfg->configdir : "");
}
else {
/* If fe_cfg->localhost is not set, ignore fe_cfg->port since
* it is the default and might be misleading.
*/
PR_snprintf(buff, bufflen, "\t<host>:<port> (%s)\n\n",
- fe_cfg->instancedir ? fe_cfg->instancedir : "");
+ fe_cfg->configdir ? fe_cfg->configdir : "");
}
LOG_WRITE_NOW(fp, buff, strlen(buff), 0);
slapi_ch_free((void **)&buildnum);
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index 514ce88d..d74d6fd9 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -274,13 +274,7 @@ fix_ownership()
else {
return;
}
-
- /* The instance directory needs to be owned by the local user */
- if (slapdFrontendConfig->instancedir) {
- slapd_chown_if_not_owner(slapdFrontendConfig->instancedir,
- pw->pw_uid, -1);
- }
- /* config directory */
+ /* config directory needs to be owned by the local user */
if (slapdFrontendConfig->configdir) {
chown_dir_files(slapdFrontendConfig->configdir, pw, PR_FALSE);
}
@@ -698,8 +692,7 @@ main( int argc, char **argv)
process_command_line(argc,argv,myname,&extraname);
- if (!slapdFrontendConfig->instancedir &&
- !slapdFrontendConfig->configdir) {
+ if (NULL == slapdFrontendConfig->configdir) {
usage( myname, extraname );
exit( 1 );
}
diff --git a/ldap/servers/slapd/protect_db.c b/ldap/servers/slapd/protect_db.c
index db628419..33ef5626 100644
--- a/ldap/servers/slapd/protect_db.c
+++ b/ldap/servers/slapd/protect_db.c
@@ -44,7 +44,6 @@
#ifndef _WIN32
-#define LOCK_DIR "locks"
#define LOCK_FILE "lock"
#define IMPORT_DIR "imports"
#define EXPORT_DIR "exports"
@@ -87,8 +86,8 @@ grab_lockfile()
gets called by an atexit function, and NSPR is long gone by then. */
/* Get the name of the lockfile */
- snprintf(lockfile, sizeof(lockfile), "%s/%s", slapdFrontendConfig->instancedir, LOCK_FILE);
- lockfile[sizeof(lockfile)-1] = (char)0;
+ snprintf(lockfile, sizeof(lockfile), "%s/%s", slapdFrontendConfig->lockdir, LOCK_FILE);
+ lockfile[sizeof(lockfile)-1] = (char)0;
/* Get our pid */
pid = getpid();
@@ -96,7 +95,7 @@ grab_lockfile()
if ((fd = open(lockfile, O_RDWR | O_CREAT | O_EXCL, 0664)) != -1) {
/* We got the lock, write our pid to the file */
write(fd, (void *) &pid, sizeof(pid_t));
- close(fd);
+ close(fd);
return 0;
}
@@ -109,13 +108,13 @@ grab_lockfile()
while(1) {
/* Try to grab the lockfile NUM_TRIES times waiting WAIT_TIME milliseconds after each try */
- t.tv_sec = 0;
- t.tv_usec = WAIT_TIME * 1000;
+ t.tv_sec = 0;
+ t.tv_usec = WAIT_TIME * 1000;
for(x = 0; x < NUM_TRIES; x++) {
if ((fd = open(lockfile, O_RDWR | O_CREAT | O_EXCL)) != -1) {
/* Got the lock */
write(fd, (void *) &pid, sizeof(pid_t));
- close(fd);
+ close(fd);
return 0;
}
select(0, NULL, NULL, NULL, &t);
@@ -123,7 +122,7 @@ grab_lockfile()
/* We still haven't got the lockfile. Find out who owns it and see if they are still up */
if ((fd = open(lockfile, O_RDONLY)) != -1) {
- size_t nb_bytes=0;
+ size_t nb_bytes=0;
nb_bytes = read(fd, (void *) &owning_pid, sizeof(pid_t));
if ( (nb_bytes != (size_t)(sizeof(pid_t)) ) || (owning_pid == 0) || (kill(owning_pid, 0) != 0 && errno == ESRCH) ) {
@@ -158,8 +157,8 @@ release_lockfile()
/* This function assumes that the caller owns the lock, it doesn't check to make sure! */
- snprintf(lockfile, sizeof(lockfile), "%s/%s", slapdFrontendConfig->instancedir, LOCK_FILE);
- lockfile[sizeof(lockfile)-1] = (char)0;
+ snprintf(lockfile, sizeof(lockfile), "%s/%s", slapdFrontendConfig->lockdir, LOCK_FILE);
+ lockfile[sizeof(lockfile)-1] = (char)0;
unlink(lockfile);
}
@@ -171,9 +170,9 @@ static int
is_process_up(pid_t pid)
{
if (kill(pid, 0) == -1 && errno == ESRCH) {
- return 0;
+ return 0;
} else {
- return 1;
+ return 1;
}
}
@@ -189,24 +188,24 @@ make_sure_dir_exists(char *dir)
/* Make sure it exists */
if (PR_MkDir(dir, 0755) != PR_SUCCESS) {
- PRErrorCode prerr = PR_GetError();
- if (prerr != PR_FILE_EXISTS_ERROR) {
- LDAPDebug(LDAP_DEBUG_ANY, FILE_CREATE_ERROR, dir, prerr, slapd_pr_strerror(prerr));
- return 1;
- }
+ PRErrorCode prerr = PR_GetError();
+ if (prerr != PR_FILE_EXISTS_ERROR) {
+ LDAPDebug(LDAP_DEBUG_ANY, FILE_CREATE_ERROR, dir, prerr, slapd_pr_strerror(prerr));
+ return 1;
+ }
}
/* Make sure it's owned by the correct user */
if (slapdFrontendConfig->localuser != NULL) {
if ( (pw = getpwnam(slapdFrontendConfig->localuser)) == NULL ) {
- LDAPDebug(LDAP_DEBUG_ANY, GETPWNAM_WARNING, slapdFrontendConfig->localuser, errno, strerror(errno));
+ LDAPDebug(LDAP_DEBUG_ANY, GETPWNAM_WARNING, slapdFrontendConfig->localuser, errno, strerror(errno));
} else {
- if (chown(dir, pw->pw_uid, -1) == -1) {
- stat(dir, &stat_buffer);
- if (stat_buffer.st_uid != pw->pw_uid) {
- LDAPDebug(LDAP_DEBUG_ANY, CHOWN_WARNING, dir, 0, 0);
- }
- }
+ if (chown(dir, pw->pw_uid, -1) == -1) {
+ stat(dir, &stat_buffer);
+ if (stat_buffer.st_uid != pw->pw_uid) {
+ LDAPDebug(LDAP_DEBUG_ANY, CHOWN_WARNING, dir, 0, 0);
+ }
+ }
} /* else */
}
@@ -226,25 +225,25 @@ add_this_process_to(char *dir_name)
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
snprintf(file_name, sizeof(file_name), "%s/%d", dir_name, getpid());
- file_name[sizeof(file_name)-1] = (char)0;
+ file_name[sizeof(file_name)-1] = (char)0;
if ((prfd = PR_Open(file_name, PR_RDWR | PR_CREATE_FILE, 0666)) == NULL) {
- LDAPDebug(LDAP_DEBUG_ANY, FILE_CREATE_WARNING, file_name, 0, 0);
- return;
+ LDAPDebug(LDAP_DEBUG_ANY, FILE_CREATE_WARNING, file_name, 0, 0);
+ return;
}
/* Make sure the owner is of the file is the user the server
* runs as. */
if (slapdFrontendConfig->localuser != NULL) {
if ( (pw = getpwnam(slapdFrontendConfig->localuser)) == NULL ) {
- LDAPDebug(LDAP_DEBUG_ANY, GETPWNAM_WARNING, slapdFrontendConfig->localuser, errno, strerror(errno));
+ LDAPDebug(LDAP_DEBUG_ANY, GETPWNAM_WARNING, slapdFrontendConfig->localuser, errno, strerror(errno));
} else {
- if (chown(file_name, pw->pw_uid, -1) == -1) {
- stat(file_name, &stat_buffer);
- if (stat_buffer.st_uid != pw->pw_uid) {
- LDAPDebug(LDAP_DEBUG_ANY, CHOWN_WARNING, file_name, 0, 0);
- }
- }
+ if (chown(file_name, pw->pw_uid, -1) == -1) {
+ stat(file_name, &stat_buffer);
+ if (stat_buffer.st_uid != pw->pw_uid) {
+ LDAPDebug(LDAP_DEBUG_ANY, CHOWN_WARNING, file_name, 0, 0);
+ }
+ }
} /* else */
}
PR_Close(prfd);
@@ -269,22 +268,22 @@ sample_and_update(char *dir_name)
char file_name[MAXPATHLEN];
if ((dir = PR_OpenDir(dir_name)) == NULL) {
- return 0;
+ return 0;
}
while((entry = PR_ReadDir(dir, PR_SKIP_BOTH)) != NULL) {
- pid = (pid_t) strtol(entry->name, &endp, 0);
- if (*endp != '\0') {
- /* not quite sure what this file was, but we
- * didn't put it there */
- continue;
- }
- if (is_process_up(pid)) {
- result = (long) pid;
- } else {
- PR_snprintf(file_name, MAXPATHLEN, "%s/%s", dir_name, entry->name);
- PR_Delete(file_name);
- }
+ pid = (pid_t) strtol(entry->name, &endp, 0);
+ if (*endp != '\0') {
+ /* not quite sure what this file was, but we
+ * didn't put it there */
+ continue;
+ }
+ if (is_process_up(pid)) {
+ result = (long) pid;
+ } else {
+ PR_snprintf(file_name, MAXPATHLEN, "%s/%s", dir_name, entry->name);
+ PR_Delete(file_name);
+ }
}
PR_CloseDir(dir);
return result;
@@ -299,7 +298,6 @@ remove_and_update(char *dir_name)
{
/* since this is called from an atexit function, we can't use
* NSPR. */
-
DIR *dir;
struct dirent *entry;
pid_t pid;
@@ -311,30 +309,30 @@ remove_and_update(char *dir_name)
our_pid = getpid();
if ((dir = opendir(dir_name)) == NULL) {
- return;
+ return;
}
while((entry = readdir(dir)) != NULL) {
-
- /* skip dot and dot-dot */
- if (strcmp(entry->d_name, ".") == 0 ||
- strcmp(entry->d_name, "..") == 0)
- continue;
-
- pid = (pid_t) strtol(entry->d_name, &endp, 0);
- if (*endp != '\0') {
- /* not quite sure what this file was, but we
- * didn't put it there */
- continue;
- }
- if (!is_process_up(pid) || pid == our_pid) {
- PR_snprintf(file_name, MAXPATHLEN, "%s/%s", dir_name, entry->d_name);
- unlink(file_name);
- }
+
+ /* skip dot and dot-dot */
+ if (strcmp(entry->d_name, ".") == 0 ||
+ strcmp(entry->d_name, "..") == 0)
+ continue;
+
+ pid = (pid_t) strtol(entry->d_name, &endp, 0);
+ if (*endp != '\0') {
+ /* not quite sure what this file was, but we
+ * didn't put it there */
+ continue;
+ }
+ if (!is_process_up(pid) || pid == our_pid) {
+ PR_snprintf(file_name, sizeof(file_name), "%s/%s", dir_name, entry->d_name);
+ unlink(file_name);
+ }
}
closedir(dir);
}
-
+
/* Walks through all the pid directories and clears any stale
@@ -343,31 +341,26 @@ remove_and_update(char *dir_name)
void
remove_slapd_process()
{
- char lock_dir[MAXPATHLEN];
char import_dir[MAXPATHLEN];
char export_dir[MAXPATHLEN];
char server_dir[MAXPATHLEN];
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
/* Create the name of the directories that hold the pids of the currently running
* ns-slapd processes */
- snprintf(lock_dir, sizeof(lock_dir), "%s/%s", slapdFrontendConfig->instancedir, LOCK_DIR);
- lock_dir[sizeof(lock_dir)-1] = (char)0;
- snprintf(import_dir, sizeof(import_dir), "%s/%s/%s", slapdFrontendConfig->instancedir, LOCK_DIR, IMPORT_DIR);
- import_dir[sizeof(import_dir)-1] = (char)0;
- snprintf(export_dir, sizeof(export_dir), "%s/%s/%s", slapdFrontendConfig->instancedir, LOCK_DIR, EXPORT_DIR);
- export_dir[sizeof(export_dir)-1] = (char)0;
- snprintf(server_dir, sizeof(server_dir), "%s/%s/%s", slapdFrontendConfig->instancedir, LOCK_DIR, SERVER_DIR);
- server_dir[sizeof(server_dir)-1] = (char)0;
+ snprintf(import_dir, sizeof(import_dir), "%s/%s", slapdFrontendConfig->lockdir, IMPORT_DIR);
+ import_dir[sizeof(import_dir)-1] = (char)0;
+ snprintf(export_dir, sizeof(export_dir), "%s/%s", slapdFrontendConfig->lockdir, EXPORT_DIR);
+ export_dir[sizeof(export_dir)-1] = (char)0;
+ snprintf(server_dir, sizeof(server_dir), "%s/%s", slapdFrontendConfig->lockdir, SERVER_DIR);
+ server_dir[sizeof(server_dir)-1] = (char)0;
/* Grab the lockfile */
if (grab_lockfile() != 0) {
- /* Unable to grab the lockfile */
- return;
+ /* Unable to grab the lockfile */
+ return;
}
-
remove_and_update(import_dir);
remove_and_update(export_dir);
remove_and_update(server_dir);
@@ -378,7 +371,6 @@ remove_slapd_process()
int
add_new_slapd_process(int exec_mode, int r_flag, int skip_flag)
{
- char lock_dir[MAXPATHLEN];
char import_dir[MAXPATHLEN];
char export_dir[MAXPATHLEN];
char server_dir[MAXPATHLEN];
@@ -387,33 +379,31 @@ add_new_slapd_process(int exec_mode, int r_flag, int skip_flag)
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
if (skip_flag) {
- return 0;
+ return 0;
}
/* Create the name of the directories that hold the pids of the currently running
* ns-slapd processes */
- snprintf(lock_dir, sizeof(lock_dir), "%s/%s", slapdFrontendConfig->instancedir, LOCK_DIR);
- lock_dir[sizeof(lock_dir)-1] = (char)0;
- snprintf(import_dir, sizeof(import_dir), "%s/%s/%s", slapdFrontendConfig->instancedir, LOCK_DIR, IMPORT_DIR);
- import_dir[sizeof(import_dir)-1] = (char)0;
- snprintf(export_dir, sizeof(export_dir), "%s/%s/%s", slapdFrontendConfig->instancedir, LOCK_DIR, EXPORT_DIR);
- export_dir[sizeof(export_dir)-1] = (char)0;
- snprintf(server_dir, sizeof(server_dir), "%s/%s/%s", slapdFrontendConfig->instancedir, LOCK_DIR, SERVER_DIR);
- server_dir[sizeof(server_dir)-1] = (char)0;
+ snprintf(import_dir, sizeof(import_dir), "%s/%s", slapdFrontendConfig->lockdir, IMPORT_DIR);
+ import_dir[sizeof(import_dir)-1] = (char)0;
+ snprintf(export_dir, sizeof(export_dir), "%s/%s", slapdFrontendConfig->lockdir, EXPORT_DIR);
+ export_dir[sizeof(export_dir)-1] = (char)0;
+ snprintf(server_dir, sizeof(server_dir), "%s/%s", slapdFrontendConfig->lockdir, SERVER_DIR);
+ server_dir[sizeof(server_dir)-1] = (char)0;
/* Grab the lockfile */
if (grab_lockfile() != 0) {
- /* Unable to grab the lockfile */
- return -1;
+ /* Unable to grab the lockfile */
+ return -1;
}
/* Make sure the directories exist */
- if (make_sure_dir_exists(lock_dir) != 0 ||
- make_sure_dir_exists(import_dir) != 0 ||
- make_sure_dir_exists(export_dir) != 0 ||
- make_sure_dir_exists(server_dir) != 0) {
- release_lockfile();
- return -1;
+ if (make_sure_dir_exists(slapdFrontendConfig->lockdir) != 0 ||
+ make_sure_dir_exists(import_dir) != 0 ||
+ make_sure_dir_exists(export_dir) != 0 ||
+ make_sure_dir_exists(server_dir) != 0) {
+ release_lockfile();
+ return -1;
}
/* Go through the directories and find out what's going on.
@@ -424,62 +414,62 @@ add_new_slapd_process(int exec_mode, int r_flag, int skip_flag)
switch (exec_mode) {
case SLAPD_EXEMODE_SLAPD:
- if (running) {
- result = -1;
- LDAPDebug(LDAP_DEBUG_ANY, NO_SERVER_DUE_TO_SERVER, running, 0, 0);
- } else if (importing) {
- result = -1;
- LDAPDebug(LDAP_DEBUG_ANY, NO_SERVER_DUE_TO_IMPORT, importing, 0, 0);
- } else {
- add_this_process_to(server_dir);
- result = 0;
- }
- break;
+ if (running) {
+ result = -1;
+ LDAPDebug(LDAP_DEBUG_ANY, NO_SERVER_DUE_TO_SERVER, running, 0, 0);
+ } else if (importing) {
+ result = -1;
+ LDAPDebug(LDAP_DEBUG_ANY, NO_SERVER_DUE_TO_IMPORT, importing, 0, 0);
+ } else {
+ add_this_process_to(server_dir);
+ result = 0;
+ }
+ break;
case SLAPD_EXEMODE_DB2LDIF:
- if (r_flag) {
- /* When the -r flag is used in db2ldif we need to make sure
- * we get a consistent snapshot of the server. As a result
- * it needs to run by itself, so no other slapd process can
- * change the database while it is running. */
- if (running || importing) {
- LDAPDebug(LDAP_DEBUG_ANY, NO_DB2LDIFR_DUE_TO_USE, 0, 0, 0);
- result = -1;
- } else {
- /* Even though this is really going to export code, we will
- * but it in the importing dir so no other process can change
- * things while we are doing ldif2db with the -r flag. */
- add_this_process_to(import_dir);
- result = 0;
- }
- } else {
- if (importing) {
- LDAPDebug(LDAP_DEBUG_ANY, NO_DB2LDIF_DUE_TO_IMPORT, importing, 0, 0);
- result = -1;
- } else {
- add_this_process_to(export_dir);
- result = 0;
- }
- }
- break;
+ if (r_flag) {
+ /* When the -r flag is used in db2ldif we need to make sure
+ * we get a consistent snapshot of the server. As a result
+ * it needs to run by itself, so no other slapd process can
+ * change the database while it is running. */
+ if (running || importing) {
+ LDAPDebug(LDAP_DEBUG_ANY, NO_DB2LDIFR_DUE_TO_USE, 0, 0, 0);
+ result = -1;
+ } else {
+ /* Even though this is really going to export code, we will
+ * but it in the importing dir so no other process can change
+ * things while we are doing ldif2db with the -r flag. */
+ add_this_process_to(import_dir);
+ result = 0;
+ }
+ } else {
+ if (importing) {
+ LDAPDebug(LDAP_DEBUG_ANY, NO_DB2LDIF_DUE_TO_IMPORT, importing, 0, 0);
+ result = -1;
+ } else {
+ add_this_process_to(export_dir);
+ result = 0;
+ }
+ }
+ break;
case SLAPD_EXEMODE_DB2ARCHIVE:
- if (importing) {
- LDAPDebug(LDAP_DEBUG_ANY, NO_DB2BAK_DUE_TO_IMPORT, importing, 0, 0);
- result = -1;
- } else {
- add_this_process_to(export_dir);
- result = 0;
- }
- break;
+ if (importing) {
+ LDAPDebug(LDAP_DEBUG_ANY, NO_DB2BAK_DUE_TO_IMPORT, importing, 0, 0);
+ result = -1;
+ } else {
+ add_this_process_to(export_dir);
+ result = 0;
+ }
+ break;
case SLAPD_EXEMODE_ARCHIVE2DB:
case SLAPD_EXEMODE_LDIF2DB:
- if (running || importing || exporting) {
- LDAPDebug(LDAP_DEBUG_ANY, NO_IMPORT_DUE_TO_USE, 0, 0, 0);
- result = -1;
- } else {
- add_this_process_to(import_dir);
- result = 0;
- }
- break;
+ if (running || importing || exporting) {
+ LDAPDebug(LDAP_DEBUG_ANY, NO_IMPORT_DUE_TO_USE, 0, 0, 0);
+ result = -1;
+ } else {
+ add_this_process_to(import_dir);
+ result = 0;
+ }
+ break;
case SLAPD_EXEMODE_DB2INDEX:
if (running || importing || exporting) {
LDAPDebug(LDAP_DEBUG_ANY, NO_DB2INDEX_DUE_TO_USE, 0, 0, 0);
@@ -514,7 +504,7 @@ add_new_slapd_process(int exec_mode, int r_flag, int skip_flag)
release_lockfile();
if (result == 0) {
- atexit(remove_slapd_process);
+ atexit(remove_slapd_process);
}
return result;
@@ -525,31 +515,26 @@ add_new_slapd_process(int exec_mode, int r_flag, int skip_flag)
/* is_slapd_running()
* returns 1 if slapd is running, 0 if not, -1 on error
*/
-
-
int
is_slapd_running() {
char server_dir[MAXPATHLEN];
- char lock_dir[MAXPATHLEN];
slapdFrontendConfig_t *cfg = getFrontendConfig();
int running = 0;
- snprintf(lock_dir, sizeof(lock_dir), "%s/%s", cfg->instancedir, LOCK_DIR);
- lock_dir[sizeof(lock_dir)-1] = (char)0;
- snprintf( server_dir, sizeof(server_dir), "%s/%s/%s", cfg->instancedir, LOCK_DIR, SERVER_DIR);
+ snprintf(server_dir, sizeof(server_dir), "%s/%s", cfg->lockdir, SERVER_DIR);
server_dir[sizeof(server_dir)-1] = (char)0;
/* Grab the lockfile */
if (grab_lockfile() != 0) {
- /* Unable to grab the lockfile */
- return -1;
+ /* Unable to grab the lockfile */
+ return -1;
}
/* Make sure the directories exist */
- if (make_sure_dir_exists(lock_dir) != 0 ||
- make_sure_dir_exists(server_dir) != 0) {
- release_lockfile();
- return -1;
+ if (make_sure_dir_exists(cfg->lockdir) != 0 ||
+ make_sure_dir_exists(server_dir) != 0) {
+ release_lockfile();
+ return -1;
}
running = sample_and_update(server_dir);
@@ -557,7 +542,6 @@ is_slapd_running() {
return running;
}
-
#else /* _WIN32 */
/* The NT version of this code */
@@ -568,11 +552,11 @@ is_slapd_running() {
int
mutex_exists( char *mutexName )
{
- if ( OpenMutex( SYNCHRONIZE, FALSE, mutexName ) == NULL ) {
- return( 0 );
- } else {
- return( 1 );
- }
+ if ( OpenMutex( SYNCHRONIZE, FALSE, mutexName ) == NULL ) {
+ return( 0 );
+ } else {
+ return( 1 );
+ }
}
/* is_slapd_running():
@@ -586,28 +570,28 @@ is_slapd_running() {
int result = 0;
slapdFrontendConfig_t *cfg = getFrontendConfig();
- strncpy( mutexName, cfg->instancedir, MAXPATHLEN );
- strncpy( serverMutexName, cfg->instancedir, MAXPATHLEN );
+ strncpy( mutexName, cfg->lockdir, MAXPATHLEN );
+ strncpy( serverMutexName, cfg->lockdir, MAXPATHLEN );
mutexName[ MAXPATHLEN ] = '\0';
serverMutexName[ MAXPATHLEN ] = '\0';
strcat( serverMutexName, "/server" );
-
+
return mutex_exists ( serverMutexName );
}
static void fix_mutex_name(char *name)
{
- /* On NT mutex names cannot contain the '\' character.
- * This functions replaces '\' with '/' in the supplied
- * name. */
- int x;
-
- for (x = 0; name[x] != '\0'; x++) {
- if ('\\' == name[x]) {
- name[x] = '/';
- }
- }
+ /* On NT mutex names cannot contain the '\' character.
+ * This functions replaces '\' with '/' in the supplied
+ * name. */
+ int x;
+
+ for (x = 0; name[x] != '\0'; x++) {
+ if ('\\' == name[x]) {
+ name[x] = '/';
+ }
+ }
}
/*
@@ -624,9 +608,9 @@ static HANDLE open_mutex = NULL;
void
remove_slapd_process()
{
- if (open_mutex) {
- CloseHandle(open_mutex);
- }
+ if (open_mutex) {
+ CloseHandle(open_mutex);
+ }
}
/* This function makes sure different instances of slapd don't
@@ -646,158 +630,158 @@ remove_slapd_process()
int
add_new_slapd_process(int exec_mode, int r_flag, int skip_flag)
{
- char mutexName[ MAXPATHLEN + 1 ];
- char serverMutexName[ MAXPATHLEN + 1 ];
- char importMutexName[ MAXPATHLEN + 1 ];
- char exportMutexName[ MAXPATHLEN + 1 ];
-
- HANDLE mutex;
- SECURITY_ATTRIBUTES mutexAttributes;
- PSECURITY_DESCRIPTOR pSD;
- LPVOID lpMsgBuf;
-
- int result = 0;
-
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if (skip_flag) {
- return 0;
- }
-
- /* Create the names for the mutexes */
- PL_strncpyz(mutexName, slapdFrontendConfig->instancedir, sizeof(mutexName));
-
- /* Make sure the name of the mutex is legal. */
- fix_mutex_name(mutexName);
-
- PR_snprintf(serverMutexName, sizeof(serverMutexName), "%s/server", mutexName);
- PR_snprintf(importMutexName, sizeof(importMutexName), "%s/import", mutexName);
- PR_snprintf(exportMutexName, sizeof(exportMutexName), "%s/export", mutexName);
-
- /* Fill in the security crap for the mutex */
- pSD = (PSECURITY_DESCRIPTOR)slapi_ch_malloc( sizeof( SECURITY_DESCRIPTOR ) );
- InitializeSecurityDescriptor( pSD, SECURITY_DESCRIPTOR_REVISION );
- SetSecurityDescriptorDacl( pSD, TRUE, NULL, FALSE );
- mutexAttributes.nLength = sizeof( mutexAttributes );
- mutexAttributes.lpSecurityDescriptor = pSD;
- mutexAttributes.bInheritHandle = FALSE;
-
- /* Get a handle to the main mutex */
- if ( ( mutex = CreateMutex( &mutexAttributes, FALSE, mutexName ) ) == NULL ) {
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
- (LPTSTR) &lpMsgBuf,
- 0,
- NULL
- );
-
- LDAPDebug( LDAP_DEBUG_ANY, CREATE_MUTEX_ERROR, lpMsgBuf, 0, 0 );
- LocalFree( lpMsgBuf );
- exit( 1 );
- }
-
- /* Lock the main mutex */
- if ( WaitForSingleObject( mutex, INFINITE ) == WAIT_FAILED ) {
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
- (LPTSTR) &lpMsgBuf,
- 0,
- NULL
- );
-
- LDAPDebug( LDAP_DEBUG_ANY, WAIT_ERROR, lpMsgBuf, 0, 0 );
- LocalFree( lpMsgBuf );
- exit( 1 );
- }
-
-
- switch (exec_mode) {
- case SLAPD_EXEMODE_SLAPD:
- if ( mutex_exists( serverMutexName ) ||
- mutex_exists( importMutexName ) ) {
- LDAPDebug( LDAP_DEBUG_ANY, NO_SERVER_DUE_TO_USE, 0, 0, 0);
- result = -1;
- } else {
- open_mutex = CreateMutex( &mutexAttributes, FALSE, serverMutexName );
- result = 0;
- }
- break;
- case SLAPD_EXEMODE_DB2LDIF:
- if (r_flag) {
- /* When the -r flag is used in db2ldif we need to make sure
- * we get a consistent snapshot of the server. As a result
- * it needs to run by itself, so no other slapd process can
- * change the database while it is running. */
- if ( mutex_exists( serverMutexName ) ||
- mutex_exists( importMutexName ) ||
- mutex_exists( exportMutexName ) ) {
- LDAPDebug(LDAP_DEBUG_ANY, NO_DB2LDIFR_DUE_TO_USE, 0, 0, 0);
- result = -1;
- } else {
- CreateMutex( &mutexAttributes, FALSE, exportMutexName );
- result = 0;
- }
- break;
- }
- case SLAPD_EXEMODE_DB2ARCHIVE:
- if ( mutex_exists( importMutexName ) ) {
- LDAPDebug(LDAP_DEBUG_ANY, NO_EXPORT_DUE_TO_IMPORT, 0, 0, 0);
- result = -1;
- } else {
- CreateMutex( &mutexAttributes, FALSE, exportMutexName );
- result = 0;
- }
- break;
- case SLAPD_EXEMODE_ARCHIVE2DB:
- case SLAPD_EXEMODE_LDIF2DB:
- if ( mutex_exists( serverMutexName ) ||
- mutex_exists( importMutexName ) ||
- mutex_exists( exportMutexName ) ) {
- LDAPDebug(LDAP_DEBUG_ANY, NO_IMPORT_DUE_TO_USE, 0, 0, 0);
- result = -1;
- } else {
- CreateMutex( &mutexAttributes, FALSE, importMutexName );
- result = 0;
- }
- break;
+ char mutexName[ MAXPATHLEN + 1 ];
+ char serverMutexName[ MAXPATHLEN + 1 ];
+ char importMutexName[ MAXPATHLEN + 1 ];
+ char exportMutexName[ MAXPATHLEN + 1 ];
+
+ HANDLE mutex;
+ SECURITY_ATTRIBUTES mutexAttributes;
+ PSECURITY_DESCRIPTOR pSD;
+ LPVOID lpMsgBuf;
+
+ int result = 0;
+
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+
+ if (skip_flag) {
+ return 0;
+ }
+
+ /* Create the names for the mutexes */
+ PL_strncpyz(mutexName, slapdFrontendConfig->lockdir, sizeof(mutexName));
+
+ /* Make sure the name of the mutex is legal. */
+ fix_mutex_name(mutexName);
+
+ PR_snprintf(serverMutexName, sizeof(serverMutexName), "%s/server", mutexName);
+ PR_snprintf(importMutexName, sizeof(importMutexName), "%s/import", mutexName);
+ PR_snprintf(exportMutexName, sizeof(exportMutexName), "%s/export", mutexName);
+
+ /* Fill in the security crap for the mutex */
+ pSD = (PSECURITY_DESCRIPTOR)slapi_ch_malloc( sizeof( SECURITY_DESCRIPTOR ) );
+ InitializeSecurityDescriptor( pSD, SECURITY_DESCRIPTOR_REVISION );
+ SetSecurityDescriptorDacl( pSD, TRUE, NULL, FALSE );
+ mutexAttributes.nLength = sizeof( mutexAttributes );
+ mutexAttributes.lpSecurityDescriptor = pSD;
+ mutexAttributes.bInheritHandle = FALSE;
+
+ /* Get a handle to the main mutex */
+ if ( ( mutex = CreateMutex( &mutexAttributes, FALSE, mutexName ) ) == NULL ) {
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
+ (LPTSTR) &lpMsgBuf,
+ 0,
+ NULL
+ );
+
+ LDAPDebug( LDAP_DEBUG_ANY, CREATE_MUTEX_ERROR, lpMsgBuf, 0, 0 );
+ LocalFree( lpMsgBuf );
+ exit( 1 );
+ }
+
+ /* Lock the main mutex */
+ if ( WaitForSingleObject( mutex, INFINITE ) == WAIT_FAILED ) {
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
+ (LPTSTR) &lpMsgBuf,
+ 0,
+ NULL
+ );
+
+ LDAPDebug( LDAP_DEBUG_ANY, WAIT_ERROR, lpMsgBuf, 0, 0 );
+ LocalFree( lpMsgBuf );
+ exit( 1 );
+ }
+
+
+ switch (exec_mode) {
+ case SLAPD_EXEMODE_SLAPD:
+ if ( mutex_exists( serverMutexName ) ||
+ mutex_exists( importMutexName ) ) {
+ LDAPDebug( LDAP_DEBUG_ANY, NO_SERVER_DUE_TO_USE, 0, 0, 0);
+ result = -1;
+ } else {
+ open_mutex = CreateMutex( &mutexAttributes, FALSE, serverMutexName );
+ result = 0;
+ }
+ break;
+ case SLAPD_EXEMODE_DB2LDIF:
+ if (r_flag) {
+ /* When the -r flag is used in db2ldif we need to make sure
+ * we get a consistent snapshot of the server. As a result
+ * it needs to run by itself, so no other slapd process can
+ * change the database while it is running. */
+ if ( mutex_exists( serverMutexName ) ||
+ mutex_exists( importMutexName ) ||
+ mutex_exists( exportMutexName ) ) {
+ LDAPDebug(LDAP_DEBUG_ANY, NO_DB2LDIFR_DUE_TO_USE, 0, 0, 0);
+ result = -1;
+ } else {
+ CreateMutex( &mutexAttributes, FALSE, exportMutexName );
+ result = 0;
+ }
+ break;
+ }
+ case SLAPD_EXEMODE_DB2ARCHIVE:
+ if ( mutex_exists( importMutexName ) ) {
+ LDAPDebug(LDAP_DEBUG_ANY, NO_EXPORT_DUE_TO_IMPORT, 0, 0, 0);
+ result = -1;
+ } else {
+ CreateMutex( &mutexAttributes, FALSE, exportMutexName );
+ result = 0;
+ }
+ break;
+ case SLAPD_EXEMODE_ARCHIVE2DB:
+ case SLAPD_EXEMODE_LDIF2DB:
+ if ( mutex_exists( serverMutexName ) ||
+ mutex_exists( importMutexName ) ||
+ mutex_exists( exportMutexName ) ) {
+ LDAPDebug(LDAP_DEBUG_ANY, NO_IMPORT_DUE_TO_USE, 0, 0, 0);
+ result = -1;
+ } else {
+ CreateMutex( &mutexAttributes, FALSE, importMutexName );
+ result = 0;
+ }
+ break;
#if defined(UPGRADEDB)
- case SLAPD_EXEMODE_UPGRADEDB:
- if ( mutex_exists( serverMutexName ) ||
- mutex_exists( importMutexName ) ||
- mutex_exists( exportMutexName ) ) {
- LDAPDebug(LDAP_DEBUG_ANY, NO_UPGRADEDB_DUE_TO_USE, 0, 0, 0);
- result = -1;
- } else {
- CreateMutex( &mutexAttributes, FALSE, importMutexName );
- result = 0;
- }
- break;
+ case SLAPD_EXEMODE_UPGRADEDB:
+ if ( mutex_exists( serverMutexName ) ||
+ mutex_exists( importMutexName ) ||
+ mutex_exists( exportMutexName ) ) {
+ LDAPDebug(LDAP_DEBUG_ANY, NO_UPGRADEDB_DUE_TO_USE, 0, 0, 0);
+ result = -1;
+ } else {
+ CreateMutex( &mutexAttributes, FALSE, importMutexName );
+ result = 0;
+ }
+ break;
#endif
- case SLAPD_EXEMODE_DBTEST:
- if ( mutex_exists( serverMutexName ) ||
- mutex_exists( importMutexName ) ||
- mutex_exists( exportMutexName ) ) {
- LDAPDebug(LDAP_DEBUG_ANY, NO_DBTEST_DUE_TO_USE, 0, 0, 0);
- result = -1;
- } else {
- CreateMutex( &mutexAttributes, FALSE, importMutexName );
- result = 0;
- }
- break;
- }
-
- /* release the main mutex */
- ReleaseMutex( mutex );
-
- slapi_ch_free((void**)&pSD );
-
- return( result );
+ case SLAPD_EXEMODE_DBTEST:
+ if ( mutex_exists( serverMutexName ) ||
+ mutex_exists( importMutexName ) ||
+ mutex_exists( exportMutexName ) ) {
+ LDAPDebug(LDAP_DEBUG_ANY, NO_DBTEST_DUE_TO_USE, 0, 0, 0);
+ result = -1;
+ } else {
+ CreateMutex( &mutexAttributes, FALSE, importMutexName );
+ result = 0;
+ }
+ break;
+ }
+
+ /* release the main mutex */
+ ReleaseMutex( mutex );
+
+ slapi_ch_free((void**)&pSD );
+
+ return( result );
}
#endif /* _WIN32 */
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 54044a71..2b6f7d76 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -246,7 +246,6 @@ int config_set_rootdn( const char *attrname, char *value, char *errorbuf, int ap
int config_set_rootpw( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_rootpwstoragescheme( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_workingdir( const char *attrname, char *value, char *errorbuf, int apply );
-int config_set_instancedir( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_encryptionalias( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_threadnumber( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_maxthreadsperconn( const char *attrname, char *value, char *errorbuf, int apply );
@@ -302,7 +301,9 @@ int config_set_enquote_sup_oc(const char *attrname, char *value, char *errorbuf
int config_set_basedn( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_configdir( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_schemadir( const char *attrname, char *value, char *errorbuf, int apply );
-int config_set_ldifdir( const char *attrname, char *value, char *errorbuf, int apply );
+int config_set_lockdir( const char *attrname, char *value, char *errorbuf, int apply );
+int config_set_tmpdir( const char *attrname, char *value, char *errorbuf, int apply );
+int config_set_certdir( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_attrname_exceptions( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_hash_filters( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_rewrite_rfc1274( const char *attrname, char *value, char *errorbuf, int apply );
@@ -366,7 +367,6 @@ char *config_get_rootpwstoragescheme();
char *config_get_localuser();
#endif /* _WIN32 */
char *config_get_workingdir();
-char *config_get_instancedir();
char *config_get_encryptionalias();
int config_get_threadnumber();
int config_get_maxthreadsperconn();
@@ -401,6 +401,9 @@ int config_get_enquote_sup_oc();
char *config_get_basedn();
char *config_get_configdir();
char *config_get_schemadir();
+char *config_get_lockdir();
+char *config_get_tmpdir();
+char *config_get_certdir();
char **config_get_errorlog_list();
char **config_get_accesslog_list();
char **config_get_auditlog_list();
@@ -966,7 +969,6 @@ int g_get_global_lastmod();
struct snmp_vars_t * g_get_global_snmp_vars();
void FrontendConfig_init();
int g_get_slapd_security_on();
-void config_set_slapd_type ();
char *config_get_versionstring();
void libldap_init_debug_level(int *);
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index c6fb41f9..863d19fb 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -1648,7 +1648,6 @@ typedef struct _slapdEntryPoints {
#define CONFIG_SSL3CIPHERS_ATTRIBUTE "nsslapd-SSL3ciphers"
#define CONFIG_ACCESSLOG_ATTRIBUTE "nsslapd-accesslog"
#define CONFIG_ERRORLOG_ATTRIBUTE "nsslapd-errorlog"
-#define CONFIG_INSTANCEDIR_ATTRIBUTE "nsslapd-instancedir"
#define CONFIG_SECUREPORT_ATTRIBUTE "nsslapd-securePort"
#define CONFIG_SECURELISTENHOST_ATTRIBUTE "nsslapd-securelistenhost"
#define CONFIG_THREADNUMBER_ATTRIBUTE "nsslapd-threadnumber"
@@ -1709,7 +1708,9 @@ typedef struct _slapdEntryPoints {
#define CONFIG_CONFIG_ATTRIBUTE "nsslapd-config"
#define CONFIG_SCHEMADIR_ATTRIBUTE "nsslapd-schemadir"
-#define CONFIG_LDIFDIR_ATTRIBUTE "nsslapd-ldifdir"
+#define CONFIG_LOCKDIR_ATTRIBUTE "nsslapd-lockdir"
+#define CONFIG_TMPDIR_ATTRIBUTE "nsslapd-tmpdir"
+#define CONFIG_CERTDIR_ATTRIBUTE "nsslapd-certdir"
#define CONFIG_SSLCLIENTAUTH_ATTRIBUTE "nsslapd-SSLclientAuth"
#define CONFIG_SSL_CHECK_HOSTNAME_ATTRIBUTE "nsslapd-ssl-check-hostname"
#define CONFIG_HASH_FILTERS_ATTRIBUTE "nsslapd-hash-filters"
@@ -1794,7 +1795,6 @@ typedef struct _slapdFrontendConfig {
char *encryptionalias;
char *errorlog;
char *listenhost;
- char *instancedir;
#ifndef _WIN32
char *localuser;
#endif /* _WIN32 */
@@ -1877,15 +1877,18 @@ typedef struct _slapdFrontendConfig {
ber_len_t maxbersize; /* Maximum BER element size we'll accept */
int max_filter_nest_level;/* deepest nested filter we will accept */
- int enquote_sup_oc; /* put single quotes around an oc's
- superior oc in cn=schema */
+ int enquote_sup_oc; /* put single quotes around an oc's
+ superior oc in cn=schema */
- char *certmap_basedn; /* Default Base DN for certmap */
+ char *certmap_basedn; /* Default Base DN for certmap */
char *workingdir; /* full path of directory before detach */
- char *configdir; /* full path name of directory containing configuration files */
- char *schemadir; /* full path name of directory containing schema files */
- int attrname_exceptions; /* if true, allow questionable attribute names */
+ char *configdir; /* full path name of directory containing configuration files */
+ char *schemadir; /* full path name of directory containing schema files */
+ char *lockdir; /* full path name of directory containing lock files */
+ char *tmpdir; /* full path name of directory containing tmp files */
+ char *certdir; /* full path name of directory containing cert files */
+ int attrname_exceptions; /* if true, allow questionable attribute names */
int rewrite_rfc1274; /* return attrs for both v2 and v3 names */
char *schemareplace; /* see CONFIG_SCHEMAREPLACE_* #defines below */
} slapdFrontendConfig_t;
diff --git a/ldap/servers/slapd/snmp_collator.c b/ldap/servers/slapd/snmp_collator.c
index 79838247..043e3765 100644
--- a/ldap/servers/slapd/snmp_collator.c
+++ b/ldap/servers/slapd/snmp_collator.c
@@ -392,54 +392,50 @@ int snmp_collator_start()
{
int err;
- char *instancedir = config_get_instancedir();
+ char *statspath = config_get_tmpdir();
+ char *lp = NULL;
- /*
- * Get directory for our stats file
- */
+ /*
+ * Get directory for our stats file
+ */
+ if (NULL == statspath) {
+ statspath = slapi_ch_strdup("/tmp");
+ }
- PR_snprintf(szStatsFile, sizeof(szStatsFile), "%s/logs/%s", instancedir,
- AGT_STATS_FILE);
+ PR_snprintf(szStatsFile, sizeof(szStatsFile), "%s/%s",
+ statspath, AGT_STATS_FILE);
tmpstatsfile = szStatsFile;
+ slapi_ch_free((void **) &statspath);
- slapi_ch_free((void **) &instancedir);
-
-
- /* open the memory map */
-
- if ((err = agt_mopen_stats(tmpstatsfile, O_RDWR, &hdl) != 0))
- {
- if (err != EEXIST) /* Ignore if file already exists */
- {
- printf("Failed to open stats file (%s) (error %d).\n",
- AGT_STATS_FILE, err);
-
- exit(1);
- }
- }
+ /* open the memory map */
+ if ((err = agt_mopen_stats(tmpstatsfile, O_RDWR, &hdl) != 0))
+ {
+ if (err != EEXIST) /* Ignore if file already exists */
+ {
+ printf("Failed to open stats file (%s) (error %d).\n",
+ szStatsFile, err);
+ exit(1);
+ }
+ }
/* read config entry for entity table data */
-
/* point stats struct at mmap data */
- stats = (struct agt_stats_t *) mmap_tbl [hdl].fp;
+ stats = (struct agt_stats_t *) mmap_tbl [hdl].fp;
/* initialize stats data */
- snmp_collator_init();
+ snmp_collator_init();
/*
-* now that memmap is open and things point the right way
-* an atomic set or increment anywhere in slapd should set
-* the snmp memmap vars correctly and be able to be polled by snmp
+* now that memmap is open and things point the right way
+* an atomic set or increment anywhere in slapd should set
+* the snmp memmap vars correctly and be able to be polled by snmp
*/
- /* Arrange to be called back periodically */
- snmp_eq_ctx = slapi_eq_repeat(snmp_collator_update, NULL, (time_t)0,
- SLAPD_SNMP_UPDATE_INTERVAL);
-
-
-return 0;
-
+ /* Arrange to be called back periodically */
+ snmp_eq_ctx = slapi_eq_repeat(snmp_collator_update, NULL, (time_t)0,
+ SLAPD_SNMP_UPDATE_INTERVAL);
+ return 0;
}
diff --git a/ldap/servers/slapd/ssl.c b/ldap/servers/slapd/ssl.c
index e88c3446..d1552442 100644
--- a/ldap/servers/slapd/ssl.c
+++ b/ldap/servers/slapd/ssl.c
@@ -51,10 +51,7 @@
#include <io.h>
#endif
-#ifdef LINUX
#include <sys/param.h>
-#endif
-
#include <ssl.h>
#include <nss.h>
#include <key.h>
@@ -456,7 +453,7 @@ slapd_nss_init(int init_ssl, int config_available)
int len = 0;
PRUint32 nssFlags = 0;
Slapi_Entry *ec = NULL;
- char *instancedir;
+ char *certdir;
if (config_available) {
getConfigEntry( configDN, &ec );
@@ -469,9 +466,11 @@ slapd_nss_init(int init_ssl, int config_available)
ec = NULL;
}
- instancedir = config_get_instancedir();
- PL_strncpyz(path, instancedir, sizeof(path));
- slapi_ch_free_string(&instancedir);
+ /* set in slapd_bootstrap_config,
+ thus certdir is available even if config_available is false */
+ certdir = config_get_certdir();
+ PL_strncpyz(path, certdir, sizeof(path));
+ slapi_ch_free_string(&certdir);
/* make sure path does not end in the path separator character */
len = strlen(path);
@@ -479,14 +478,15 @@ slapd_nss_init(int init_ssl, int config_available)
path[len-1] = '\0';
}
- /* get the server root from the path */
+ /* get the server instance dir name from path:
+ <sysconfig>/BRAND_DS/slapd-<id> */
val = strrchr(path, '/');
if (!val) {
val = strrchr(path, '\\');
}
val++;
- if(keyfn && certfn) {
+ if (keyfn && certfn) {
if (is_abspath(certfn)) {
warn_if_no_cert_file(certfn);
/* first, initialize path from the certfn */
@@ -553,7 +553,6 @@ slapd_nss_init(int init_ssl, int config_available)
}
PR_snprintf(certPref, sizeof(certPref), "%s-", val);
PL_strncpyz(keyPref, certPref, sizeof(keyPref));
- PL_strncpyz(val, "alias/", sizeof(path)-(val-path));
}
slapi_ch_free((void **) &certfn);
@@ -581,10 +580,6 @@ slapd_nss_init(int init_ssl, int config_available)
return rv;
}
-
-
-
-
/*
* slapd_ssl_init() is called from main() if we plan to listen
* on a secure port.
@@ -1004,12 +999,11 @@ int slapd_ssl_init2(PRFileDesc **fd, int startTLS)
tmpDir = slapd_get_tmp_dir();
- slapi_log_error(
- SLAPI_LOG_TRACE,
- "slapd_ssl_init2",
- "tmp dir = %s\n", tmpDir);
+ slapi_log_error(SLAPI_LOG_TRACE,
+ "slapd_ssl_init2", "tmp dir = %s\n", tmpDir);
rv = SSL_ConfigServerSessionIDCache(0, stimeout, stimeout, tmpDir);
+ slapi_ch_free(&tmpDir);
if (rv) {
errorCode = PR_GetError();
if (errorCode == ENOSPC) {
@@ -1448,12 +1442,11 @@ slapd_ssl_listener_is_initialized()
return _ssl_listener_initialized;
}
-
+/* memory to store tmpdir is allocated and returned; caller should free it. */
char* slapd_get_tmp_dir()
{
- static char tmpdir[] = "/tmp";
- static char tmp[256];
- char* instanceDir;
+ static char tmp[MAXPATHLEN];
+ char* tmpdir = NULL;;
#if defined( XP_WIN32 )
unsigned ilen;
char pch;
@@ -1462,64 +1455,61 @@ char* slapd_get_tmp_dir()
tmp[0] = '\0';
- if((instanceDir = config_get_instancedir()) == NULL)
+ if((tmpdir = config_get_tmpdir()) == NULL)
{
slapi_log_error(
SLAPI_LOG_FATAL,
"slapd_get_tmp_dir",
- "config_get_instancedir returns NULL Setting tmp dir to default\n");
+ "config_get_tmpdir returns NULL Setting tmp dir to default\n");
#if defined( XP_WIN32 )
- ilen = sizeof(tmp);
- GetTempPath( ilen, tmp );
- tmp[ilen-1] = (char)0;
- ilen = strlen(tmp);
- /* Remove trailing slash. */
- pch = tmp[ilen-1];
- if( pch == '\\' || pch == '/' )
- tmp[ilen-1] = '\0';
- return tmp;
+ ilen = sizeof(tmp);
+ GetTempPath( ilen, tmp );
+ tmp[ilen-1] = (char)0;
+ ilen = strlen(tmp);
+ /* Remove trailing slash. */
+ pch = tmp[ilen-1];
+ if( pch == '\\' || pch == '/' )
+ tmp[ilen-1] = '\0';
#else
- return( tmpdir );
+ strcpy(tmp, "/tmp");
#endif
+ return slapi_ch_strdup(tmp);
}
- PR_snprintf(tmp,sizeof(tmp),"%s/tmp",instanceDir);
- slapi_ch_free_string(&instanceDir);
-
#if defined( XP_WIN32 )
- for(ilen=0;ilen < strlen(tmp); ilen++)
{
- if(tmp[ilen]=='/')
- tmp[ilen]='\\';
+ char *ptr = NULL;
+ char *endptr = tmpdir + strlen(tmpdir);
+ for(ptr = tmpdir; ptr < endptr; ptr++)
+ {
+ if('/' == *ptr)
+ *ptr = '\\';
+ }
}
#endif
- if(stat(tmp,&ffinfo) == -1)
+ if(stat(tmpdir, &ffinfo) == -1)
#if defined( XP_WIN32 )
- if(CreateDirectory(tmp, NULL) == 0)
+ if(CreateDirectory(tmpdir, NULL) == 0)
{
slapi_log_error(
SLAPI_LOG_FATAL,
"slapd_get_tmp_dir",
"CreateDirectory(%s, NULL) Error: %s\n",
- tmp, strerror(errno));
- return ( tmpdir );
+ tmpdir, strerror(errno));
}
#else
- if(mkdir(tmp, 00770) == -1)
+ if(mkdir(tmpdir, 00770) == -1)
{
slapi_log_error(
SLAPI_LOG_FATAL,
"slapd_get_tmp_dir",
"mkdir(%s, 00770) Error: %s\n",
- tmp, strerror(errno));
- return ( tmpdir );
+ tmpdir, strerror(errno));
}
#endif
-
- return ( tmp );
-
+ return ( tmpdir );
}
#endif /* NET_SSL */