summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--ldap/admin/include/dsalib.h42
-rw-r--r--ldap/admin/lib/dsalib_conf.c3
-rw-r--r--ldap/admin/lib/dsalib_db.c259
-rw-r--r--ldap/admin/lib/dsalib_location.c46
-rw-r--r--ldap/admin/lib/dsalib_util.c151
-rw-r--r--ldap/admin/src/create_instance.c589
-rw-r--r--ldap/admin/src/create_instance.h4
-rw-r--r--ldap/admin/src/ds_remove.c4
-rw-r--r--ldap/admin/src/scripts/template-bak2db.pl6
-rw-r--r--ldap/admin/src/scripts/template-db2bak.pl10
-rw-r--r--ldap/admin/src/scripts/template-db2index.pl11
-rw-r--r--ldap/admin/src/scripts/template-db2ldif.pl11
-rw-r--r--ldap/admin/src/scripts/template-ldif2db.pl6
-rw-r--r--ldap/admin/src/scripts/template-ns-accountstatus.pl4
-rw-r--r--ldap/admin/src/scripts/template-ns-activate.pl4
-rw-r--r--ldap/admin/src/scripts/template-ns-inactivate.pl4
-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
33 files changed, 1360 insertions, 1264 deletions
diff --git a/ldap/admin/include/dsalib.h b/ldap/admin/include/dsalib.h
index 6f137cf7..96ff5ee8 100644
--- a/ldap/admin/include/dsalib.h
+++ b/ldap/admin/include/dsalib.h
@@ -47,21 +47,21 @@
#endif
/* error types */
-#define DS_FILE_ERROR 0
-#define DS_MEMORY_ERROR 1
-#define DS_SYSTEM_ERROR 2
-#define DS_INCORRECT_USAGE 3
-#define DS_ELEM_MISSING 4
+#define DS_FILE_ERROR 0
+#define DS_MEMORY_ERROR 1
+#define DS_SYSTEM_ERROR 2
+#define DS_INCORRECT_USAGE 3
+#define DS_ELEM_MISSING 4
#define DS_REGISTRY_DATABASE_ERROR 5
-#define DS_NETWORK_ERROR 6
-#define DS_GENERAL_FAILURE 7
-#define DS_WARNING 8
+#define DS_NETWORK_ERROR 6
+#define DS_GENERAL_FAILURE 7
+#define DS_WARNING 8
/* The upper bound on error types */
-#define DS_MAX_ERROR 9
+#define DS_MAX_ERROR 9
/* The default error type (in case something goes wrong */
-#define DS_DEFAULT_ERROR 3
+#define DS_DEFAULT_ERROR 3
#ifndef BIG_LINE
#define BIG_LINE 1024
@@ -80,18 +80,27 @@
#define CONTENT_NAME "content"
#endif
+/* config file/path info */
+#define DS_CONFIG_DIR "DS_CONFIG_DIR"
+#define DS_CONFIG_FILE "dse.ldif"
+#define DS_ORIGCONFIG_FILE "dse_original.ldif"
+#define PIDFILE "PIDFILE"
+
+#define DS_CONFIG_LOCKDIR "nsslapd-lockdir:"
+#define DS_CONFIG_ERRLOG "nsslapd-errorlog:"
+
#ifdef XP_UNIX
-#define FILE_PATHSEP '/'
+#define FILE_PATHSEP '/'
#define FILE_PATHSEPP "/"
-#define FILE_PARENT "../"
+#define FILE_PARENT "../"
#define WSACleanup()
#elif defined(XP_WIN32)
-#define FILE_PATHSEP '/'
+#define FILE_PATHSEP '/'
#define FILE_PATHSEPP "\\\\"
-#define FILE_PARENT "..\\"
+#define FILE_PARENT "..\\"
#endif /* XP_WIN32 */
@@ -303,7 +312,6 @@ extern DS_EXPORT_SYMBOL void ds_print_server_status(int isrunning);
extern DS_EXPORT_SYMBOL int ds_get_file_size(char *fileName);
extern DS_EXPORT_SYMBOL void ds_display_tail(char *fileName, int timeOut,
int startSeek, char *doneMsg, char *lastLine);
-extern DS_EXPORT_SYMBOL char **ds_get_ldif_files();
extern DS_EXPORT_SYMBOL int ds_ldif2db_preserve(char *file);
extern DS_EXPORT_SYMBOL int ds_ldif2db(char *file);
extern DS_EXPORT_SYMBOL int ds_ldif2db_backend_subtree(char *file, char *backend, char *subtree);
@@ -322,6 +330,8 @@ extern DS_EXPORT_SYMBOL char *ds_get_config_dir();
extern DS_EXPORT_SYMBOL void ds_set_config_dir(char *config_dir);
extern DS_EXPORT_SYMBOL char *ds_get_run_dir();
extern DS_EXPORT_SYMBOL void ds_set_run_dir(char *run_dir);
+extern DS_EXPORT_SYMBOL char *ds_get_bak_dir();
+extern DS_EXPORT_SYMBOL void ds_set_bak_dir(char *bak_dir);
extern DS_EXPORT_SYMBOL char *ds_get_pwenc(char *passwd_hash, char *password);
extern DS_EXPORT_SYMBOL int ds_check_config(int type);
extern DS_EXPORT_SYMBOL int ds_check_pw(char *pwhash, char *pwclear);
@@ -415,7 +425,7 @@ extern DS_EXPORT_SYMBOL char* ds_become_original();
extern DS_EXPORT_SYMBOL char* ds_makeshort(char *filepath);
-extern DS_EXPORT_SYMBOL int ds_search_file(char *filename, char *searchstring);
+extern DS_EXPORT_SYMBOL int ds_search_file(char *filename, char *searchstring, char **returnstring);
/* Begin parsing a POST in a CGI context */
extern DS_EXPORT_SYMBOL int ds_post_begin(FILE *input);
diff --git a/ldap/admin/lib/dsalib_conf.c b/ldap/admin/lib/dsalib_conf.c
index 08961da1..86d9dc31 100644
--- a/ldap/admin/lib/dsalib_conf.c
+++ b/ldap/admin/lib/dsalib_conf.c
@@ -51,7 +51,6 @@
#include "nspr.h"
-#define CONF_FILE_NAME "dse.ldif"
#define CONF_SUFFIX "cn=config"
DS_EXPORT_SYMBOL char *
@@ -83,7 +82,7 @@ ds_get_config(int type)
return(NULL);
}
- PR_snprintf(conffile, PATH_MAX, "%s/%s", configdir, CONF_FILE_NAME);
+ PR_snprintf(conffile, PATH_MAX, "%s/%s", configdir, DS_CONFIG_FILE);
if ( !(sf = fopen(conffile, "r")) ) {
ds_send_error("could not read config file.", 1);
diff --git a/ldap/admin/lib/dsalib_db.c b/ldap/admin/lib/dsalib_db.c
index 9c7b1ca9..60916b14 100644
--- a/ldap/admin/lib/dsalib_db.c
+++ b/ldap/admin/lib/dsalib_db.c
@@ -64,35 +64,42 @@
DS_EXPORT_SYMBOL char **
ds_get_bak_dirs()
{
- char format_str[PATH_MAX];
+ char format_str[PATH_MAX];
char *root;
- int i = 0;
- char **bak_dirs = NULL;
+ int i = 0;
+ char **bak_dirs = NULL;
+ char *bakdir = NULL;
if ( (root = ds_get_install_root()) == NULL )
- {
+ {
ds_send_error("Cannot find server root directory.", 0);
return(bak_dirs);
}
- PR_snprintf( format_str, PATH_MAX, "%s%cbak", root, FILE_SEP );
- bak_dirs = ds_get_file_list( format_str );
- if( bak_dirs )
- {
- while( bak_dirs[i] != NULL )
- {
- /* Prepend the filename with the install root */
- char filename[PATH_MAX];
- PR_snprintf( filename, PATH_MAX, "%s%cbak%c%s", root, FILE_SEP,
- FILE_SEP, bak_dirs[i] );
- free( bak_dirs[i] );
- bak_dirs[i] = strdup( filename );
+ if ( (bakdir = ds_get_bak_dir()) == NULL )
+ {
+ ds_send_error("Cannot find backup directory.", 0);
+ return(bak_dirs);
+ }
+
+ PR_snprintf( format_str, PATH_MAX, "%s", bakdir );
+ bak_dirs = ds_get_file_list( format_str );
+ if( bak_dirs )
+ {
+ while( bak_dirs[i] != NULL )
+ {
+ /* Prepend the filename with the install root */
+ char filename[PATH_MAX];
+ PR_snprintf( filename, PATH_MAX, "%s%c%s",
+ bakdir, FILE_SEP, bak_dirs[i] );
+ free( bak_dirs[i] );
+ bak_dirs[i] = strdup( filename );
#if defined( XP_WIN32 )
- ds_dostounixpath( bak_dirs[i] );
+ ds_dostounixpath( bak_dirs[i] );
#endif
- i++;
- }
- }
+ i++;
+ }
+ }
return(bak_dirs);
}
@@ -113,7 +120,7 @@ ds_bak2db(char *file)
int error = -1;
int status;
FILE *sf = NULL;
- struct stat fstats;
+ struct stat fstats;
if ( file == NULL ) {
return DS_NULL_PARAMETER;
@@ -126,8 +133,8 @@ ds_bak2db(char *file)
return DS_NO_SERVER_ROOT;
}
- if ( file[strlen(file) - 1] == '\n' ) /* strip out returns */
- file[strlen(file) - 1] = '\0';
+ if ( file[strlen(file) - 1] == '\n' ) /* strip out returns */
+ file[strlen(file) - 1] = '\0';
if( stat( file, &fstats ) == -1 && errno == ENOENT ) {
return DS_CANNOT_OPEN_BACKUP_FILE;
@@ -138,12 +145,12 @@ ds_bak2db(char *file)
tmp_dir = ds_get_tmp_dir();
PR_snprintf(statfile, PATH_MAX, "%s%cbak2db.%d", tmp_dir, FILE_SEP, (int)getpid());
PR_snprintf(startup_line, BIG_LINE,
- "%s%cbak2db "
- "%s%s%s > "
- "%s%s%s 2>&1",
- root, FILE_SEP,
- ENQUOTE, file, ENQUOTE,
- ENQUOTE, statfile, ENQUOTE );
+ "%s%cbak2db "
+ "%s%s%s > "
+ "%s%s%s 2>&1",
+ root, FILE_SEP,
+ ENQUOTE, file, ENQUOTE,
+ ENQUOTE, statfile, ENQUOTE );
alter_startup_line(startup_line);
fflush(0);
error = system(startup_line);
@@ -151,19 +158,19 @@ ds_bak2db(char *file)
if ( error == -1 ) {
return DS_CANNOT_EXEC;
}
- fflush(0);
+ fflush(0);
if( !(sf = fopen(statfile, "r")) ) {
return DS_CANNOT_OPEN_STAT_FILE;
}
while ( fgets(startup_line, BIG_LINE, sf) ) {
- if ((strstr(startup_line, "- Restoring file")) ||
- (strstr(startup_line, "- Checkpointing"))) {
- ds_show_message(startup_line);
- } else {
- haderror = 1;
- ds_send_error(startup_line, 0);
- }
+ if ((strstr(startup_line, "- Restoring file")) ||
+ (strstr(startup_line, "- Checkpointing"))) {
+ ds_show_message(startup_line);
+ } else {
+ haderror = 1;
+ ds_send_error(startup_line, 0);
+ }
}
fclose(sf);
@@ -189,9 +196,9 @@ ds_db2bak(char *file)
int haderror = 0;
int error = -1;
FILE *sf = NULL;
- int lite = 0;
+ int lite = 0;
#ifdef XP_WIN32
- time_t ltime;
+ time_t ltime;
#endif
if ( (root = ds_get_install_root()) == NULL ) {
@@ -201,29 +208,29 @@ ds_db2bak(char *file)
if ( (file == NULL) || (strlen(file) == 0) )
file = NULL;
- tmp_dir = ds_get_tmp_dir();
+ tmp_dir = ds_get_tmp_dir();
PR_snprintf(statfile, PATH_MAX, "%s%cdb2bak.%d", tmp_dir, FILE_SEP, (int)getpid());
-
-
+
+
#if defined( XP_WIN32 )
- if( file == NULL )
- {
- file = malloc( BIG_LINE );
-
- time( &ltime );
- PR_snprintf( file, BIG_LINE, "%s", ctime( &ltime ) );
- ds_timetofname( file );
- }
-
- /* Check if the directory exists or can be created */
- if ( !ds_file_exists( file ) ) {
- char *errmsg = ds_mkdir_p( file, NEWDIR_MODE );
- if( errmsg != NULL ) {
-/* ds_send_error(errmsg, 10);
+ if( file == NULL )
+ {
+ file = malloc( BIG_LINE );
+
+ time( &ltime );
+ PR_snprintf( file, BIG_LINE, "%s", ctime( &ltime ) );
+ ds_timetofname( file );
+ }
+
+ /* Check if the directory exists or can be created */
+ if ( !ds_file_exists( file ) ) {
+ char *errmsg = ds_mkdir_p( file, NEWDIR_MODE );
+ if( errmsg != NULL ) {
+/* ds_send_error(errmsg, 10);
*/
- return DS_CANNOT_CREATE_DIRECTORY;
- }
- }
+ return DS_CANNOT_CREATE_DIRECTORY;
+ }
+ }
#endif
/* DBDB: note on the following line.
@@ -238,16 +245,16 @@ ds_db2bak(char *file)
PR_snprintf(startup_line, sizeof(startup_line),
- "%s%cdb2bak "
- "%s%s%s > "
- "%s%s%s 2>&1",
- root, FILE_SEP,
- ENQUOTE,
- (file == NULL) ? "" : file,
- ENQUOTE,
- ENQUOTE, statfile, ENQUOTE);
-
- PATH_FOR_PLATFORM( startup_line );
+ "%s%cdb2bak "
+ "%s%s%s > "
+ "%s%s%s 2>&1",
+ root, FILE_SEP,
+ ENQUOTE,
+ (file == NULL) ? "" : file,
+ ENQUOTE,
+ ENQUOTE, statfile, ENQUOTE);
+
+ PATH_FOR_PLATFORM( startup_line );
alter_startup_line(startup_line);
fflush(0);
error = system(startup_line);
@@ -274,7 +281,7 @@ ds_db2bak(char *file)
unlink(statfile);
if ( lite && haderror )
- return DS_HAS_TOBE_READONLY_MODE;
+ return DS_HAS_TOBE_READONLY_MODE;
if ( haderror )
return DS_UNKNOWN_ERROR;
@@ -284,52 +291,52 @@ ds_db2bak(char *file)
static void
process_and_report( char *line, int line_size, FILE *cmd )
{
- while(fgets(line, line_size, cmd)) {
- /* Strip off line feeds */
- int ind = strlen( line ) - 1;
- while ( (ind >= 0) &&
- ((line[ind] == '\n') ||
- (line[ind] == '\r')) ) {
- line[ind] = 0;
- ind--;
- }
- if ( ind < 1 ) {
- continue;
- }
- ds_send_status(line);
- }
+ while(fgets(line, line_size, cmd)) {
+ /* Strip off line feeds */
+ int ind = strlen( line ) - 1;
+ while ( (ind >= 0) &&
+ ((line[ind] == '\n') ||
+ (line[ind] == '\r')) ) {
+ line[ind] = 0;
+ ind--;
+ }
+ if ( ind < 1 ) {
+ continue;
+ }
+ ds_send_status(line);
+ }
}
static int exec_and_report( char *startup_line )
{
- FILE *cmd = NULL;
+ FILE *cmd = NULL;
char line[BIG_LINE];
int haderror = 0;
- PATH_FOR_PLATFORM( startup_line );
+ PATH_FOR_PLATFORM( startup_line );
alter_startup_line(startup_line);
- /*
- fprintf( stdout, "Launching <%s>\n", startup_line );
- */
+ /*
+ fprintf( stdout, "Launching <%s>\n", startup_line );
+ */
fflush(0);
- cmd = popen(startup_line, "r");
- if(!cmd) {
+ cmd = popen(startup_line, "r");
+ if(!cmd) {
return DS_CANNOT_EXEC;
}
- process_and_report( line, sizeof(line), cmd );
- pclose(cmd);
+ process_and_report( line, sizeof(line), cmd );
+ pclose(cmd);
/*
** The VLV indexing code prints OK,
** if the index was successfully created.
*/
- if (strcmp(line,"OK")==0) {
- haderror = 0;
- } else {
- haderror = DS_UNKNOWN_ERROR;
- }
+ if (strcmp(line,"OK")==0) {
+ haderror = 0;
+ } else {
+ haderror = DS_UNKNOWN_ERROR;
+ }
return haderror;
}
@@ -345,8 +352,8 @@ ds_vlvindex(char **backendList, char **vlvList)
char startup_line[BIG_LINE];
char *root;
char *instroot;
- char **vlvc = NULL;
-
+ char **vlvc = NULL;
+
root = ds_get_server_root();
instroot = ds_get_install_root();
@@ -355,21 +362,21 @@ ds_vlvindex(char **backendList, char **vlvList)
}
PR_snprintf(startup_line, sizeof(startup_line), "%s/bin/slapd/server/%s db2index "
- "-D %s%s/%s "
- "-n %s ",
- root, SLAPD_NAME,
- ENQUOTE, instroot, ENQUOTE,
- backendList[0]);
-
-
- /* Create vlv TAG */
- vlvc=vlvList;
- while( *vlvc != NULL ) {
- PR_snprintf( startup_line, sizeof(startup_line), "%s -T %s%s%s", startup_line,"\"",*vlvc,"\"" );
- vlvc++;
- }
+ "-D %s%s/%s "
+ "-n %s ",
+ root, SLAPD_NAME,
+ ENQUOTE, instroot, ENQUOTE,
+ backendList[0]);
+
+
+ /* Create vlv TAG */
+ vlvc=vlvList;
+ while( *vlvc != NULL ) {
+ PR_snprintf( startup_line, sizeof(startup_line), "%s -T %s%s%s", startup_line,"\"",*vlvc,"\"" );
+ vlvc++;
+ }
- return exec_and_report( startup_line );
+ return exec_and_report( startup_line );
}
/*
@@ -391,17 +398,17 @@ ds_addindex(char **attrList, char *backendName)
return DS_NO_SERVER_ROOT;
}
- PR_snprintf(startup_line, sizeof(startup_line), "%s/bin/slapd/server/%s db2index "
- "-D %s%s%s "
- "-n %s",
- root, SLAPD_NAME,
- ENQUOTE, instroot, ENQUOTE,
- backendName);
-
- while( *attrList != NULL ) {
- PR_snprintf( startup_line, sizeof(startup_line), "%s -t %s", startup_line, *attrList );
- attrList++;
- }
+ PR_snprintf(startup_line, sizeof(startup_line), "%s/bin/slapd/server/%s db2index "
+ "-D %s%s%s "
+ "-n %s",
+ root, SLAPD_NAME,
+ ENQUOTE, instroot, ENQUOTE,
+ backendName);
+
+ while( *attrList != NULL ) {
+ PR_snprintf( startup_line, sizeof(startup_line), "%s -t %s", startup_line, *attrList );
+ attrList++;
+ }
- return exec_and_report( startup_line );
+ return exec_and_report( startup_line );
}
diff --git a/ldap/admin/lib/dsalib_location.c b/ldap/admin/lib/dsalib_location.c
index 87081c2b..6aefb061 100644
--- a/ldap/admin/lib/dsalib_location.c
+++ b/ldap/admin/lib/dsalib_location.c
@@ -133,6 +133,52 @@ ds_set_run_dir(char *run_dir)
}
/*
+ * Returns the bakup dir of the server, where db backup files are put.
+ * Info is returned in a static area. The caller must copy it
+ * for reuse if needed.
+ */
+DS_EXPORT_SYMBOL char *
+ds_get_bak_dir()
+{
+ return getenv("DS_BAK_DIR");
+}
+
+/*
+ * set bak_dir to environment variable DS_BAK_DIR
+ * to retrieve the value using ds_get_bak_dir later.
+ */
+DS_EXPORT_SYMBOL void
+ds_set_bak_dir(char *bak_dir)
+{
+ static char env[PATH_MAX];
+ PR_snprintf(env, sizeof(env), "DS_BAK_DIR=%s", bak_dir);
+ putenv(env);
+}
+
+/*
+ * Returns the tmp dir of the server, where tmp files are put.
+ * Info is returned in a static area. The caller must copy it
+ * for reuse if needed.
+ */
+DS_EXPORT_SYMBOL char *
+ds_get_tmp_dir()
+{
+ return getenv("DS_TMP_DIR");
+}
+
+/*
+ * set bak_dir to environment variable DS_TMP_DIR
+ * to retrieve the value using ds_get_tmp_dir later.
+ */
+DS_EXPORT_SYMBOL void
+ds_set_tmp_dir(char *tmp_dir)
+{
+ static char env[PATH_MAX];
+ PR_snprintf(env, sizeof(env), "DS_TMP_DIR=%s", tmp_dir);
+ putenv(env);
+}
+
+/*
* Returns the install location of the server under the admserv
* directory.
*/
diff --git a/ldap/admin/lib/dsalib_util.c b/ldap/admin/lib/dsalib_util.c
index ead2a197..bebb38a9 100644
--- a/ldap/admin/lib/dsalib_util.c
+++ b/ldap/admin/lib/dsalib_util.c
@@ -307,51 +307,6 @@ ds_cp_file(char *sfile, char *dfile, int mode)
#endif
}
-/* Returns a directory path used for tmp files. */
-DS_EXPORT_SYMBOL char *
-ds_get_tmp_dir()
-{
-#if defined( XP_WIN32 )
- size_t ilen;
- char pch;
-#endif
- static char tmpdir[] = "/tmp";
- static char tmp[256] = {0};
- char* instanceDir = ds_get_install_root();
-
- if(instanceDir == NULL)
- {
- #if defined( XP_WIN32 )
- ilen = sizeof(tmp);
- GetTempPath( ilen, tmp );
- tmp[ilen-1] = (char)0;
- /* Remove trailing slash. */
- ilen = strlen(tmp);
- pch = tmp[ilen-1];
- if( pch == '\\' || pch == '/' )
- tmp[ilen-1] = '\0';
- return tmp;
- #else
- return( tmpdir );
- #endif
- }
-
- PR_snprintf(tmp, sizeof(tmp), "%s/tmp",instanceDir);
-
-#if defined( XP_WIN32 )
- for(ilen=0;ilen < strlen(tmp); ilen++)
- {
- if(tmp[ilen]=='/')
- tmp[ilen]='\\';
- }
-#endif
-
- if(!ds_file_exists(tmp))
- ds_mkdir_p(tmp,00770);
-
- return ( tmp );
-}
-
DS_EXPORT_SYMBOL void
ds_unixtodospath(char *szText)
{
@@ -630,8 +585,10 @@ ds_makeshort( char * filepath )
}
/* returns 1 if string "searchstring" found in file "filename" */
+/* if found, returnstring is allocated and filled with the line */
+/* caller should release the memory */
DS_EXPORT_SYMBOL int
-ds_search_file(char *filename, char *searchstring)
+ds_search_file(char *filename, char *searchstring, char **returnstring)
{
struct stat finfo;
FILE * sf;
@@ -648,6 +605,10 @@ ds_search_file(char *filename, char *searchstring)
while ( fgets(big_line, BIG_LINE, sf) ) {
if( strstr( big_line, searchstring ) != NULL ) {
+ *returnstring = (char *)malloc(strlen(big_line) + 1);
+ if (NULL != *returnstring) {
+ strcpy(*returnstring, big_line);
+ }
fclose(sf);
return 1;
}
@@ -864,8 +825,6 @@ ds_system_errmsg(void)
return static_error;
}
-/* get db path dir info from dse.ldif and remove it if it's not under path
-*/
#ifndef MAXPATHLEN
#define MAXPATHLEN 1024
#endif
@@ -907,7 +866,7 @@ rm_db_dirs(char *fullpath, DS_RM_RF_ERR_FUNC ds_rm_rf_err_func, void *arg)
if (fp == NULL)
{
- ds_rm_rf_err_func(fullpath, "opening dse.ldif", arg);
+ ds_rm_rf_err_func(fullpath, "opening the config file", arg);
return;
}
@@ -990,6 +949,43 @@ rm_db_dirs(char *fullpath, DS_RM_RF_ERR_FUNC ds_rm_rf_err_func, void *arg)
fclose(fp);
}
+static char *
+get_dir_from_startslapd(char *loc, char *keyword)
+{
+ char *returnstr = NULL;
+ char *ptr = NULL;
+ char *confdir = NULL;
+if (ds_search_file(loc, keyword, &returnstr) > 0 && returnstr) {
+ ptr = strchr(returnstr, '=');
+ if (NULL != ptr) {
+ confdir = strdup(++ptr);
+ }
+ free(returnstr);
+ }
+ return confdir;
+}
+
+static char *
+get_dir_from_config(char *config_dir, char *config_attr)
+{
+ char *configfile = NULL;
+ char *returnstr = NULL;
+ char *ptr = NULL;
+ char *dir = NULL;
+ configfile = PR_smprintf("%s%c%s", config_dir, FILE_PATHSEP, DS_CONFIG_FILE);
+ if (configfile && ds_search_file(configfile, config_attr, &returnstr) > 0
+ && returnstr) {
+ ptr = strchr(returnstr, ':');
+ if (NULL != ptr) {
+ while (' ' == *ptr || '\t' == *ptr) ptr++;
+ dir = strdup(ptr);
+ }
+ free(returnstr);
+ PR_smprintf_free(configfile);
+ }
+ return dir;
+}
+
/* this function will recursively remove a directory hierarchy from the file
system, like "rm -rf"
In order to handle errors, the user supplies a callback function. When an
@@ -1041,9 +1037,61 @@ internal_rm_rf(const char *path, DS_RM_RF_ERR_FUNC ds_rm_rf_err_func, void *arg)
break;
}
} else {
- /* if dse.ldif, check db dir is under the instance dir or not */
- if (0 == strcmp(dirent->name, "dse.ldif"))
+ /* FHS changes the directory structure.
+ * Config dir is no longer in the instance dir.
+ * The info should be found in start-slapd,
+ * therefore get the path from the file here.
+ */
+ if (0 == strcmp(dirent->name, "start-slapd")) {
+ char *config_dir = ds_get_config_dir();
+ char *run_dir = ds_get_run_dir();
+ if (NULL == config_dir || '\0' == *config_dir) {
+ config_dir = get_dir_from_startslapd(fullpath, DS_CONFIG_DIR);
+ }
+ if (NULL == run_dir || '\0' == *run_dir) {
+ char *ptr = NULL;
+ run_dir = get_dir_from_startslapd(fullpath, PIDFILE);
+ ptr = strrchr(run_dir, FILE_PATHSEP);
+ if (NULL != ptr) {
+ *ptr = '\0'; /* equiv to dirname */
+ }
+ }
+ if (NULL != run_dir) {
+ internal_rm_rf(run_dir, ds_rm_rf_err_func, NULL);
+ free(run_dir);
+ }
+ if (NULL != config_dir) {
+ char *lock_dir = get_dir_from_config(config_dir, DS_CONFIG_LOCKDIR);
+ char *err_log = get_dir_from_config(config_dir, DS_CONFIG_ERRLOG);
+
+ if (NULL != lock_dir) {
+ internal_rm_rf(lock_dir, ds_rm_rf_err_func, NULL);
+ free(lock_dir);
+ }
+ if (NULL != err_log) {
+ char *ptr = strrchr(err_log, FILE_PATHSEP);
+ if (NULL != ptr) {
+ *ptr = '\0'; /* equiv to 'dirname' */
+ internal_rm_rf(err_log, ds_rm_rf_err_func, NULL);
+ }
+ free(err_log);
+ }
+ /* removing db dirs */
+ rm_db_dirs(config_dir, ds_rm_rf_err_func, arg);
+
+ /* removing config dir */
+ internal_rm_rf(config_dir, ds_rm_rf_err_func, NULL);
+ }
+ }
+ /*
+ * When the file is the config file,
+ * check if db dir is in the instance dir or not.
+ * If db dir exists in the instance dir, it's an old structure.
+ * Let's clean the old db here, as well.
+ */
+ if (0 == strcmp(dirent->name, DS_CONFIG_FILE)) {
rm_db_dirs(fullpath, ds_rm_rf_err_func, arg);
+ }
if (PR_Delete(fullpath) != PR_SUCCESS) {
if (!ds_rm_rf_err_func(fullpath, "deleting file", arg)) {
@@ -1086,6 +1134,7 @@ default_err_func(const char *path, const char *op, void *arg)
return 1; /* just continue */
}
+/* dir: instance dir, e.g., "$NETSITE_ROOT/slapd-<id>" */
DS_EXPORT_SYMBOL int
ds_rm_rf(const char *dir, DS_RM_RF_ERR_FUNC ds_rm_rf_err_func, void *arg)
{
diff --git a/ldap/admin/src/create_instance.c b/ldap/admin/src/create_instance.c
index 62d89ddd..2c12bb5c 100644
--- a/ldap/admin/src/create_instance.c
+++ b/ldap/admin/src/create_instance.c
@@ -187,7 +187,7 @@ static int needToStartServer(server_config_s *cf)
static int getSuiteSpotUserGroup(server_config_s* cf)
{
#ifdef XP_UNIX
- static const char *ssUsersFile = "shared/config/ssusers.conf";
+ static const char *ssUsersFile = "ssusers.conf";
char realFile[PATH_SIZE];
char buf[1024];
FILE *fp = NULL;
@@ -196,7 +196,7 @@ static int getSuiteSpotUserGroup(server_config_s* cf)
if (cf->servuser)
return 0;
- PR_snprintf(realFile, sizeof(realFile), "%s/%s", cf->sroot, ssUsersFile);
+ PR_snprintf(realFile, sizeof(realFile), "%s/%s", cf->config_dir, ssUsersFile);
if (!(fp = fopen(realFile, "r")))
return 1;
@@ -320,6 +320,7 @@ void set_defaults(char *sroot, char *hn, server_config_s *conf)
conf->db_dir = NULL;
conf->bak_dir = NULL;
conf->ldif_dir = NULL;
+ conf->tmp_dir = NULL;
}
/* ----------------- Sanity check a server configuration ------------------ */
@@ -328,7 +329,7 @@ char *create_instance_checkport(char *, char *);
char *create_instance_checkuser(char *);
int create_instance_numbers(char *);
int create_instance_exists(char *fn, int type);
-char *create_instance_copy(char *, char *, int);
+char *create_instance_copy(char *, char *, int, int);
char *create_instance_concatenate(char *, char *, int);
int create_instance_mkdir(char *, int);
char *create_instance_mkdir_p(char *, char *, int, struct passwd *);
@@ -361,7 +362,7 @@ isAValidDN(const char *dn_to_test)
!*rdnNoTypes[0] || !PL_strcasecmp(rdnList[0], rdnNoTypes[0]))
{
t = make_error("The given value [%s] is not a valid DN.",
- dn_to_test);
+ dn_to_test);
}
if (rdnList)
ldap_value_free(rdnList);
@@ -425,9 +426,6 @@ static char *sanity_check(server_config_s *cf, char *param_name)
{
char *t;
register int x;
-#if 0
- char fn[PATH_SIZE];
-#endif
if (!param_name)
return "Parameter param_name is null";
@@ -468,22 +466,6 @@ static char *sanity_check(server_config_s *cf, char *param_name)
cf->servid[x]);
}
}
-#if 0
- /* has that identifier already been used? */
- PR_snprintf(fn, sizeof(fn), "%s%c%s-%s", cf->sroot, FILE_PATHSEP,
- PRODUCT_NAME, cf->servid);
-
-/* Not an error to upgrade! ???
- if ( !cf->upgradingServer ) {
- if(create_instance_exists(fn)) {
- PL_strncpyz(param_name, "servid", BIG_LINE);
- return make_error ("A server named '%s' already exists."
- "\nPlease choose another server identifier.",
- cf->servid);
- }
- }
- */
-#endif
#ifdef XP_UNIX
if( (t = create_instance_checkuser(cf->servuser)) )
@@ -716,73 +698,32 @@ char *gen_script(char *s_root, char *name, char *fmt, ...)
return NULL;
}
-char *gen_perl_script(char *s_root, char *cs_path, char *name, char *fmt, ...)
-#ifdef __GNUC__
- __attribute__ ((format (printf, 4, 5)));
-#else
- ;
-#endif
-char *gen_perl_script(char *s_root, char *cs_path, char *name, char *fmt, ...)
-{
- char myperl[PATH_SIZE];
- char fn[PATH_SIZE];
- FILE *f;
- va_list args;
-
- if (PR_FAILURE == PR_Access(cs_path, PR_ACCESS_EXISTS)) {
- printf("Notice: %s does not exist, skipping %s . . .\n", cs_path, name);
- return NULL;
- }
-
- PR_snprintf(fn, sizeof(fn), "%s%c%s", cs_path, FILE_PATHSEP, name);
- PR_snprintf(myperl, sizeof(myperl), "%s%cbin%cslapd%cadmin%cbin%cperl",
- s_root, FILE_PATHSEP, FILE_PATHSEP,
- FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP);
- if(!(f = fopen(fn, "w")))
- return make_error("Could not write to %s (%s).", fn, ds_system_errmsg());
- va_start(args, fmt);
-#if !defined( XP_WIN32 )
- fprintf(f, "#!%s\n\n", myperl);
-#endif
- vfprintf(f, fmt, args);
-
-#if defined( XP_UNIX )
- fchmod(fileno(f), NEWSCRIPT_MODE);
-#endif
- fclose(f);
-#if defined( XP_WIN32 )
- chmod( fn, NEWSCRIPT_MODE);
-#endif
-
- return NULL;
-}
-
char *gen_perl_script_auto(char *s_root, char *cs_path, char *name,
server_config_s *cf)
{
char myperl[PATH_SIZE];
char fn[PATH_SIZE], ofn[PATH_SIZE];
- const char *table[10][2];
+ const char *table[12][2];
if (PR_FAILURE == PR_Access(cs_path, PR_ACCESS_EXISTS)) {
printf("Notice: %s does not exist, skipping %s . . .\n", cs_path, name);
return NULL;
}
- PR_snprintf(ofn, sizeof(ofn), "%s%cbin%cslapd%cadmin%cscripts%ctemplate-%s", s_root,
- FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP,
+ PR_snprintf(ofn, sizeof(ofn), "%s%cbin%cslapd%cadmin%cscripts%ctemplate-%s",
+ cf->prefix, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP,
FILE_PATHSEP, name);
PR_snprintf(fn, sizeof(fn), "%s%c%s", cs_path, FILE_PATHSEP, name);
#ifdef USE_NSPERL
PR_snprintf(myperl, sizeof(myperl), "!%s%cbin%cslapd%cadmin%cbin%cperl",
- s_root, FILE_PATHSEP, FILE_PATHSEP,
+ cf->prefix, FILE_PATHSEP, FILE_PATHSEP,
FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP);
#else
strcpy(myperl, "!/usr/bin/env perl");
#endif
table[0][0] = "DS-ROOT";
- table[0][1] = s_root;
+ table[0][1] = cf->prefix;
table[1][0] = "MY-DS-ROOT";
table[1][1] = cs_path;
table[2][0] = "SEP";
@@ -802,7 +743,13 @@ char *gen_perl_script_auto(char *s_root, char *cs_path, char *name,
#endif
table[7][0] = "ROOT-DN";
table[7][1] = cf->rootdn;
- table[8][0] = table[8][1] = NULL;
+ table[8][0] = "LDIF-DIR";
+ table[8][1] = cf->ldif_dir;
+ table[9][0] = "SERV-ID";
+ table[9][1] = cf->servid;
+ table[10][0] = "BAK-DIR";
+ table[10][1] = cf->bak_dir;
+ table[11][0] = table[11][1] = NULL;
if (generate_script(ofn, fn, NEWSCRIPT_MODE, table) != 0) {
return make_error("Could not write %s to %s (%s).", ofn, fn,
@@ -817,23 +764,24 @@ char *gen_perl_script_auto_for_migration(char *s_root, char *cs_path, char *name
{
char myperl[PATH_SIZE];
char fn[PATH_SIZE], ofn[PATH_SIZE];
- const char *table[10][2];
-
- PR_snprintf(ofn, sizeof(ofn), "%s%cbin%cslapd%cadmin%cscripts%ctemplate-%s", s_root,
- FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP,
- FILE_PATHSEP, name);
- PR_snprintf(fn, sizeof(fn), "%s%cbin%cslapd%cadmin%cbin%c%s", s_root, FILE_PATHSEP,
- FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP, name);
+ const char *table[12][2];
+
+ PR_snprintf(ofn, sizeof(ofn), "%s%cbin%cslapd%cadmin%cscripts%ctemplate-%s",
+ cf->prefix, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP,
+ FILE_PATHSEP, FILE_PATHSEP, name);
+ PR_snprintf(fn, sizeof(fn), "%s%cbin%cslapd%cadmin%cbin%c%s",
+ cf->prefix, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP,
+ FILE_PATHSEP, FILE_PATHSEP, name);
#ifdef USE_NSPERL
PR_snprintf(myperl, sizeof(myperl), "!%s%cbin%cslapd%cadmin%cbin%cperl",
- s_root, FILE_PATHSEP, FILE_PATHSEP,
- FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP);
+ cf->prefix, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP,
+ FILE_PATHSEP, FILE_PATHSEP);
#else
strcpy(myperl, "!/usr/bin/env perl");
#endif
table[0][0] = "DS-ROOT";
- table[0][1] = s_root;
+ table[0][1] = cf->prefix;
table[1][0] = "MY-DS-ROOT";
table[1][1] = cs_path;
table[2][0] = "SEP";
@@ -853,7 +801,13 @@ char *gen_perl_script_auto_for_migration(char *s_root, char *cs_path, char *name
#endif
table[7][0] = "ROOT-DN";
table[7][1] = cf->rootdn;
- table[8][0] = table[8][1] = NULL;
+ table[8][0] = "LDIF-DIR";
+ table[8][1] = cf->ldif_dir;
+ table[9][0] = "SERV-ID";
+ table[9][1] = cf->servid;
+ table[10][0] = "BAK-DIR";
+ table[10][1] = cf->bak_dir;
+ table[11][0] = table[11][1] = NULL;
if (generate_script(ofn, fn, NEWSCRIPT_MODE, table) != 0) {
return make_error("Could not write %s to %s (%s).", ofn, fn,
@@ -914,11 +868,11 @@ char *add_ntservice(server_config_s *cf)
char szServiceExe[MAX_PATH], szServiceDisplayName[MAX_PATH], szServiceName[MAX_PATH];
DWORD dwLastError;
- PR_snprintf(szServiceExe, sizeof(szServiceExe), "%s/bin/%s/server/%s", cf->sroot,
- SVR_DIR_ROOT, SVR_EXE);
+ PR_snprintf(szServiceExe, sizeof(szServiceExe), "%s/bin/%s/server/%s",
+ cf->prefix, SVR_DIR_ROOT, SVR_EXE);
PR_snprintf(szServiceName, sizeof(szServiceName),"%s-%s", SVR_ID_SERVICE, cf->servid);
PR_snprintf(szServiceDisplayName, sizeof(szServiceDisplayName), "%s (%s)", SVR_NAME_FULL_VERSION,
- cf->servid);
+ cf->servid);
/* install new service - if already installed, try and remove and
then reinstall */
@@ -931,8 +885,8 @@ char *add_ntservice(server_config_s *cf)
}
// setup event logging registry keys, do this after service creation
- PR_snprintf(szMessageFile, sizeof(szMessageFile), "%s\\bin\\%s\\server\\%s", cf->sroot,
- SVR_DIR_ROOT, "slapdmessages30.dll");
+ PR_snprintf(szMessageFile, sizeof(szMessageFile), "%s\\bin\\%s\\server\\%s",
+ cf->prefix, SVR_DIR_ROOT, "slapdmessages30.dll");
setup_nteventlogging(szServiceName, szMessageFile);
// TODO: add perfmon setup code -ahakim 11/22/96
@@ -941,7 +895,7 @@ char *add_ntservice(server_config_s *cf)
char *setup_ntserver(server_config_s *cf)
{
- char line[MAX_PATH], *sroot = cf->sroot;
+ char line[MAX_PATH], *sroot = cf->prefix;
char subdir[MAX_PATH];
char NumValuesBuf[3];
DWORD Result;
@@ -1264,7 +1218,7 @@ create_scripts(server_config_s *cf, char *param_name)
"exit 1\n",
sroot, DS_CONFIG_DIR, cf->config_dir, DS_CONFIG_DIR, cf->run_dir,
cf->run_dir, PRODUCT_BIN, PRODUCT_BIN,
- sroot, PRODUCT_BIN, cf->config_dir, cf->run_dir
+ cf->prefix, PRODUCT_BIN, cf->config_dir, cf->run_dir
);
}
if(t) return t;
@@ -1497,6 +1451,16 @@ char *create_server(server_config_s *cf, char *param_name)
if( (create_instance_mkdir_p("run dir", cf->run_dir, NEWSECDIR_MODE, pw)) )
return make_error("make run dir %s failed (%s)",
cf->run_dir, ds_system_errmsg());
+
+ /* Create tmp directory */
+ if( (create_instance_mkdir_p("tmp dir", cf->tmp_dir, NEWSECDIR_MODE, pw)) )
+ return make_error("make tmp dir %s failed (%s)",
+ cf->tmp_dir, ds_system_errmsg());
+
+ /* Create cert directory */
+ if( (create_instance_mkdir_p("cert dir", cf->cert_dir, NEWSECDIR_MODE, pw)) )
+ return make_error("make cert dir %s failed (%s)",
+ cf->cert_dir, ds_system_errmsg());
# if 0
/* Create httpacl directory */
PR_snprintf(line, sizeof(line), "%s%chttpacl", cf->sroot, FILE_PATHSEP);
@@ -1788,7 +1752,7 @@ char *create_instance_checkuser(char *user)
#ifdef XP_UNIX
-char *create_instance_copy(char *sfile, char *dfile, int mode)
+char *create_instance_copy(char *sfile, char *dfile, int mode, int needbakup)
{
int sfd, dfd, len;
struct stat fi;
@@ -1799,16 +1763,31 @@ char *create_instance_copy(char *sfile, char *dfile, int mode)
/* Make sure we're in the right umask */
umask(022);
- if( (sfd = open(sfile, O_RDONLY)) == -1)
+ if( (sfd = open(sfile, O_RDONLY)) == -1) {
return make_error("Cannot open %s for reading (%s)", sfile,
ds_system_errmsg());
-
- fstat(sfd, &fi);
+ }
+ if (stat(sfile, &fi) < 0) {
+ return make_error("Cannot stat %s (%s)", sfile, ds_system_errmsg());
+ }
if(!(S_ISREG(fi.st_mode))) {
close(sfd);
return make_error("%s is not a regular file", sfile);
}
len = fi.st_size;
+
+ if (needbakup) {
+ if (0 == stat(dfile, &fi)) { /* file exists */
+ if (S_ISREG(fi.st_mode) || S_ISDIR(fi.st_mode)) {
+ char *bak_dfile = PR_smprintf("%s.bak", dfile);
+ if (NULL != bak_dfile) {
+ rename(dfile, bak_dfile); /* make a back up;
+ ignore any errors */
+ PR_smprintf_free(bak_dfile);
+ }
+ }
+ }
+ }
if( (dfd = open(dfile, O_RDWR | O_CREAT | O_TRUNC, mode)) == -1)
return make_error("Cannot open file %s for writing (%s)", dfile,
@@ -1817,13 +1796,15 @@ char *create_instance_copy(char *sfile, char *dfile, int mode)
while(len) {
read_len = len>COPY_BUFFER_SIZE?COPY_BUFFER_SIZE:len;
- if ( (read_len = read(sfd, copy_buffer, read_len)) == -1) {
- make_error("Cannot read from file %s (%s)",
+ if ( (read_len = read(sfd, copy_buffer, read_len) ) == -1 ) {
+ close(sfd); close(dfd);
+ return make_error("Cannot read from file %s (%s)",
sfile, ds_system_errmsg());
}
- if ( write(dfd, copy_buffer, read_len) != read_len) {
- make_error("Error writing to file %s from copy of %s (%s)",
+ if ( write(dfd, copy_buffer, read_len) != read_len ) {
+ close(sfd); close(dfd);
+ return make_error("Error writing to file %s from copy of %s (%s)",
dfile, sfile, ds_system_errmsg());
}
@@ -1836,7 +1817,7 @@ char *create_instance_copy(char *sfile, char *dfile, int mode)
}
#else /* XP_WIN32 */
-char *create_instance_copy(char *sfile, char *dfile, int mode)
+char *create_instance_copy(char *sfile, char *dfile, int mode, int bakup)
{
HANDLE sfd, dfd, MapHandle;
PCHAR fp;
@@ -1905,15 +1886,6 @@ is_a_dir(const char *dirname, const char *filename)
return file_is_type_x(dirname, filename, PR_FILE_DIRECTORY);
}
-#if 0 /* not being used */
-/* return true if the given path and file corresponds to a regular file */
-static int
-is_a_file(const char *dirname, const char *filename)
-{
- return file_is_type_x(dirname, filename, PR_FILE_FILE);
-}
-#endif
-
static char *
ds_copy_group_files_using_mode(char *src_dir, char *dest_dir,
char *filter, int use_mode)
@@ -1945,7 +1917,7 @@ ds_copy_group_files_using_mode(char *src_dir, char *dest_dir,
free(sub_dest_dir);
}
else {
- if( (t = create_instance_copy(src_file, dest_file, use_mode)) )
+ if( (t = create_instance_copy(src_file, dest_file, use_mode, 0 )) )
return t;
}
}
@@ -1962,16 +1934,6 @@ ds_copy_group_files(char *src_dir, char *dest_dir, char *filter)
NEWFILE_MODE);
}
-#if 0 /* not being used */
-static char *
-ds_copy_group_bins(char *src_dir, char *dest_dir, char *filter,
- int use_mode)
-{
- return ds_copy_group_files_using_mode(src_dir, dest_dir, filter,
- NEWSCRIPT_MODE);
-}
-#endif
-
/* this macro was copied from libldap/tmplout.c */
#define HREF_CHAR_ACCEPTABLE( c ) (( c >= '-' && c <= '9' ) || \
( c >= '@' && c <= 'Z' ) || \
@@ -2031,9 +1993,10 @@ ds_cre_subdirs(server_config_s *cf, struct passwd* pw)
return(t);
}
- /* create subdir <server_root>/bin/slapd/authck */
+ /* create subdir <prefix>/bin/slapd/authck */
/* dsgw cookie dir */
- PR_snprintf(subdir, sizeof(subdir), "%s%cbin%cslapd%cauthck", sroot, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP);
+ PR_snprintf(subdir, sizeof(subdir), "%s%cbin%cslapd%cauthck",
+ cf->prefix, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP);
if( (t = create_instance_mkdir_p("authck dir", subdir, NEWDIR_MODE, pw)) )
return(t);
#endif
@@ -2110,12 +2073,12 @@ char *ds_gen_scripts(char *sroot, server_config_s *cf, char *cs_path)
char *server = sroot;
char *admin = sroot;
char *tools = cf->bindir;
+ char cgics_path[PATH_SIZE];
#else
char server[PATH_SIZE];
char admin[PATH_SIZE];
char tools[PATH_SIZE];
#endif
- char cgics_path[PATH_SIZE];
char *cl_scripts[7] = {"dsstop", "dsstart", "dsrestart", "dsrestore", "dsbackup", "dsimport", "dsexport"};
char *cl_javafiles[7] = {"DSStop", "DSStart", "DSRestart", "DSRestore", "DSBackup", "DSImport", "DSExport"};
int cls = 0; /*Index into commandline script names and java names - RJP*/
@@ -2133,13 +2096,13 @@ char *ds_gen_scripts(char *sroot, server_config_s *cf, char *cs_path)
#if 0
/* nothing to do for server, admin, tools */
- PR_snprintf(cgics_path, sizeof(cgics_path), "%s%cbin%cadmin%cadmin%cbin", sroot,
- FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP);
+ PR_snprintf(cgics_path, sizeof(cgics_path), "%s%cbin%cadmin%cadmin%cbin",
+ cf->prefix, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP);
#else /* will go away */
- PR_snprintf(server, sizeof(server), "%s/bin/"PRODUCT_NAME"/server", sroot);
- PR_snprintf(admin, sizeof(admin), "%s/bin/"PRODUCT_NAME"/admin/bin", sroot);
- PR_snprintf(tools, sizeof(tools), "%s/shared/bin", sroot);
+ PR_snprintf(server, sizeof(server), "%s/bin/"PRODUCT_NAME"/server", cf->prefix);
+ PR_snprintf(admin, sizeof(admin), "%s/bin/"PRODUCT_NAME"/admin/bin", cf->prefix);
+ PR_snprintf(tools, sizeof(tools), "%s/shared/bin", cf->prefix);
#endif
t = gen_script(cs_path, "monitor",
"if [ \"x$1\" != \"x\" ];\nthen MDN=\"$1\";\nelse MDN=\"cn=monitor\";\n fi\n"
@@ -2152,7 +2115,7 @@ char *ds_gen_scripts(char *sroot, server_config_s *cf, char *cs_path)
t = gen_script(cs_path, "saveconfig",
"cd %s\n"
"echo saving configuration ...\n"
- "conf_ldif=%s/confbak/`date +%%Y_%%m_%%d_%%H%%M%%S`.ldif\n"
+ "conf_ldif=%s/confbak/%s-`date +%%Y_%%m_%%d_%%H%%M%%S`.ldif\n"
"./%s db2ldif -N -D %s "
"-s \"%s\" -a $conf_ldif -n NetscapeRoot 2>&1\n"
"if [ \"$?\" -ge 1 ] \nthen\n"
@@ -2160,12 +2123,15 @@ char *ds_gen_scripts(char *sroot, server_config_s *cf, char *cs_path)
" exit 1\n"
"fi\n"
"exit 0\n",
- server, cf->config_dir, PRODUCT_BIN, cf->config_dir, cf->netscaperoot);
+ server,
+ cf->config_dir, cf->servid,
+ PRODUCT_BIN, cf->config_dir,
+ cf->netscaperoot);
if(t) return t;
t = gen_script(cs_path, "restoreconfig",
"cd %s\n"
- "conf_ldif=`ls -1t %s/confbak/*.ldif | head -1`\n"
+ "conf_ldif=`ls -1t %s/confbak/%s-*.ldif | head -1`\n"
"if [ -z \"$conf_ldif\" ]\n"
"then\n"
" echo No configuration to restore in %s/confbak ; exit 1\n"
@@ -2174,7 +2140,10 @@ char *ds_gen_scripts(char *sroot, server_config_s *cf, char *cs_path)
"./%s ldif2db -D %s"
" -i $conf_ldif -n NetscapeRoot 2>&1\n"
"exit $?\n",
- server, cf->config_dir, cf->config_dir, PRODUCT_BIN, cf->config_dir);
+ server,
+ cf->config_dir, cf->servid,
+ cf->config_dir,
+ PRODUCT_BIN, cf->config_dir);
if(t) return t;
t = gen_script(cs_path, "ldif2db",
@@ -2327,11 +2296,12 @@ char *ds_gen_scripts(char *sroot, server_config_s *cf, char *cs_path)
"\tfi\n"
"done\n"
"if [ $ldif_file = \"mydummy\" ]\nthen\n"
- "\tldif_file=%s/ldif/`date +%%Y_%%m_%%d_%%H%%M%%S`.ldif\nfi\n"
+ "\tldif_file=%s/%s-`date +%%Y_%%m_%%d_%%H%%M%%S`.ldif\nfi\n"
"if [ $set_ldif -eq 2 ]\nthen\n"
"./%s db2ldif -D %s \"$@\"\nelse\n"
"./%s db2ldif -D %s -a $ldif_file \"$@\"\nfi\n",
- server, cf->ldif_dir,
+ server,
+ cf->ldif_dir, cf->servid,
PRODUCT_BIN, cf->config_dir,
PRODUCT_BIN, cf->config_dir);
if(t) return t;
@@ -2551,10 +2521,10 @@ char *ds_gen_scripts(char *sroot, server_config_s *cf, char *cs_path)
*q = '\0';
}
- PR_snprintf(server, sizeof(server), "%s/bin/"PRODUCT_NAME"/server", sroot);
- PR_snprintf(admin, sizeof(admin), "%s/bin/"PRODUCT_NAME"/admin/bin", sroot);
+ PR_snprintf(server, sizeof(server), "%s/bin/"PRODUCT_NAME"/server", cf->prefix);
+ PR_snprintf(admin, sizeof(admin), "%s/bin/"PRODUCT_NAME"/admin/bin", cf->prefix);
PR_snprintf(tools, sizeof(tools), "%s/shared/bin", sroot);
- PR_snprintf(cgics_path, sizeof(cgics_path), "%s/bin/admin/admin/bin", sroot);
+ PR_snprintf(cgics_path, sizeof(cgics_path), "%s/bin/admin/admin/bin", cf->prefix);
ds_unixtodospath( cs_path );
ds_unixtodospath( server );
@@ -3082,7 +3052,7 @@ char *ds_gen_scripts(char *sroot, server_config_s *cf, char *cs_path)
"set rc=%%errorlevel%%\n"
"if defined MKSARGS exit %%rc%%\n"
"exit /b %%rc%%\n",
- sroot, cs_path);
+ cf->prefix, cs_path);
if(t) return t;
@@ -3098,7 +3068,7 @@ char *ds_gen_scripts(char *sroot, server_config_s *cf, char *cs_path)
"set rc=%%errorlevel%%\n"
"if defined MKSARGS exit %%rc%%\n"
"exit /b %%rc%%\n",
- sroot, cs_path);
+ cf->prefix, cs_path);
if(t) return t;
free(mysroot);
@@ -3214,7 +3184,7 @@ suffix_gen_conf(FILE* f, char * suffix, char *be_name)
fprintf(f, "objectclass: nsSlapdPlugin\n"); \
fprintf(f, "objectclass: extensibleObject\n"); \
fprintf(f, "cn: %s\n",(_name)); \
- fprintf(f, "nsslapd-pluginpath: %s/lib/syntax-plugin%s\n", sroot, shared_lib); \
+ fprintf(f, "nsslapd-pluginpath: %s/lib/syntax-plugin%s\n", prefix, shared_lib); \
fprintf(f, "nsslapd-plugininitfunc: %s\n", (_fn)); \
fprintf(f, "nsslapd-plugintype: syntax\n"); \
fprintf(f, "nsslapd-pluginenabled: on\n"); \
@@ -3230,6 +3200,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
int rootdse = 0;
char *shared_lib;
struct passwd *pw = getpwnam(cf->servuser);
+ char *prefix = cf->prefix;
PR_snprintf(fn, sizeof(fn), "%s%c%s",
cf->config_dir, FILE_PATHSEP, DS_CONFIG_FILE);
@@ -3264,9 +3235,10 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass:top\n");
fprintf(f, "objectclass:extensibleObject\n");
fprintf(f, "objectclass:nsslapdConfig\n");
- fprintf(f, "nsslapd-instancedir: %s\n", cf->inst_dir);
fprintf(f, "nsslapd-schemadir: %s\n", cf->schema_dir);
- fprintf(f, "nsslapd-ldifdir: %s\n", cf->ldif_dir);
+ fprintf(f, "nsslapd-lockdir: %s\n", cf->lock_dir);
+ fprintf(f, "nsslapd-tmpdir: %s\n", cf->tmp_dir);
+ fprintf(f, "nsslapd-certdir: %s\n", cf->cert_dir);
fprintf(f, "nsslapd-accesslog-logging-enabled: on\n");
fprintf(f, "nsslapd-accesslog-maxlogsperdir: 10\n");
fprintf(f, "nsslapd-accesslog-mode: 600\n");
@@ -3276,11 +3248,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "nsslapd-accesslog-logrotationsync-enabled: off\n");
fprintf(f, "nsslapd-accesslog-logrotationsynchour: 0\n");
fprintf(f, "nsslapd-accesslog-logrotationsyncmin: 0\n");
-#if 0
fprintf(f, "nsslapd-accesslog: %s/access\n", cf->log_dir);
-#else /* will go away */
- fprintf(f, "nsslapd-accesslog: %s/logs/access\n", cs_path);
-#endif
fprintf(f, "nsslapd-enquote-sup-oc: off\n");
fprintf(f, "nsslapd-localhost: %s\n", cf->servname);
fprintf(f, "nsslapd-schemacheck: %s\n",
@@ -3303,18 +3271,10 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "nsslapd-errorlog-logrotationsync-enabled: off\n");
fprintf(f, "nsslapd-errorlog-logrotationsynchour: 0\n");
fprintf(f, "nsslapd-errorlog-logrotationsyncmin: 0\n");
-#if 0
fprintf(f, "nsslapd-errorlog: %s/errors\n", cf->log_dir);
-#else /* will go away */
- fprintf(f, "nsslapd-errorlog: %s/logs/errors\n", cs_path);
-#endif
if (cf->loglevel)
fprintf(f, "nsslapd-errorlog-level: %s\n", cf->loglevel);
-#if 0
fprintf(f, "nsslapd-auditlog: %s/audit\n", cf->log_dir);
-#else /* will go away */
- fprintf(f, "nsslapd-auditlog: %s/logs/audit\n", cs_path);
-#endif
fprintf(f, "nsslapd-auditlog-mode: 600\n");
fprintf(f, "nsslapd-auditlog-maxlogsize: 100\n");
fprintf(f, "nsslapd-auditlog-logrotationtime: 1\n");
@@ -3346,7 +3306,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: top\n");
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "cn: SSHA\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: ssha_pwd_storage_scheme_init\n");
fprintf(f, "nsslapd-plugintype: pwdstoragescheme\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3356,7 +3316,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: top\n");
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "cn: SSHA256\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: ssha256_pwd_storage_scheme_init\n");
fprintf(f, "nsslapd-plugintype: pwdstoragescheme\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3366,7 +3326,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: top\n");
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "cn: SSHA384\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: ssha384_pwd_storage_scheme_init\n");
fprintf(f, "nsslapd-plugintype: pwdstoragescheme\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3376,7 +3336,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: top\n");
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "cn: SSHA512\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: ssha512_pwd_storage_scheme_init\n");
fprintf(f, "nsslapd-plugintype: pwdstoragescheme\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3386,7 +3346,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: top\n");
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "cn: SHA\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: sha_pwd_storage_scheme_init\n");
fprintf(f, "nsslapd-plugintype: pwdstoragescheme\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3396,7 +3356,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: top\n");
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "cn: SHA256\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: sha256_pwd_storage_scheme_init\n");
fprintf(f, "nsslapd-plugintype: pwdstoragescheme\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3406,7 +3366,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: top\n");
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "cn: SHA384\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: sha384_pwd_storage_scheme_init\n");
fprintf(f, "nsslapd-plugintype: pwdstoragescheme\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3416,7 +3376,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: top\n");
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "cn: SHA512\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: sha512_pwd_storage_scheme_init\n");
fprintf(f, "nsslapd-plugintype: pwdstoragescheme\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3427,7 +3387,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: top\n");
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "cn: CRYPT\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: crypt_pwd_storage_scheme_init\n");
fprintf(f, "nsslapd-plugintype: pwdstoragescheme\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3438,7 +3398,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: top\n");
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "cn: MD5\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: md5_pwd_storage_scheme_init\n");
fprintf(f, "nsslapd-plugintype: pwdstoragescheme\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3448,7 +3408,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: top\n");
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "cn: CLEAR\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: clear_pwd_storage_scheme_init\n");
fprintf(f, "nsslapd-plugintype: pwdstoragescheme\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3458,7 +3418,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: top\n");
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "cn: NS-MTA-MD5\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/pwdstorage-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: ns_mta_md5_pwd_storage_scheme_init\n");
fprintf(f, "nsslapd-plugintype: pwdstoragescheme\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3469,7 +3429,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: DES\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/des-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/des-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: des_init\n");
fprintf(f, "nsslapd-plugintype: reverpwdstoragescheme\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3499,7 +3459,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: State Change Plugin\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/statechange-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/statechange-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: statechange_init\n");
fprintf(f, "nsslapd-plugintype: postoperation\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3510,7 +3470,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: Roles Plugin\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/roles-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/roles-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: roles_init\n");
fprintf(f, "nsslapd-plugintype: postoperation\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3524,7 +3484,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: ACL Plugin\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/acl-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/acl-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: acl_init\n");
fprintf(f, "nsslapd-plugintype: accesscontrol\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3536,7 +3496,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: ACL preoperation\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/acl-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/acl-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: acl_preopInit\n");
fprintf(f, "nsslapd-plugintype: preoperation\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3548,7 +3508,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: Legacy Replication Plugin\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/replication-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/replication-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: replication_legacy_plugin_init\n");
fprintf(f, "nsslapd-plugintype: object\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3561,7 +3521,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: Multimaster Replication Plugin\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/replication-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/replication-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: replication_multimaster_plugin_init\n");
fprintf(f, "nsslapd-plugintype: object\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3574,7 +3534,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: Retro Changelog Plugin\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/retrocl-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/retrocl-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: retrocl_plugin_init\n");
fprintf(f, "nsslapd-plugintype: object\n");
fprintf(f, "nsslapd-pluginenabled: off\n");
@@ -3588,7 +3548,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: Class of Service\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/cos-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/cos-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: cos_init\n");
fprintf(f, "nsslapd-plugintype: postoperation\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3602,7 +3562,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: Views\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/views-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/views-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: views_init\n");
fprintf(f, "nsslapd-plugintype: object\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3619,7 +3579,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: referential integrity postoperation\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/referint-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/referint-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: referint_postop_init\n");
fprintf(f, "nsslapd-plugintype: postoperation\n");
fprintf(f, "nsslapd-pluginenabled: off\n");
@@ -3640,7 +3600,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: ntSynchService preoperation\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/ntsynch-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/ntsynch-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: libntsynch_plugin_preop_init\n");
fprintf(f, "nsslapd-plugintype: preoperation\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3651,7 +3611,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: ntSynchService postoperation\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/ntsynch-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/ntsynch-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: libntsynch_plugin_postop_init\n");
fprintf(f, "nsslapd-plugintype: postoperation\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3672,7 +3632,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: attribute uniqueness\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/attr-unique-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/attr-unique-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: NSUniqueAttr_Init\n");
fprintf(f, "nsslapd-plugintype: preoperation\n");
fprintf(f, "nsslapd-pluginenabled: off\n");
@@ -3686,7 +3646,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: 7-bit check\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/attr-unique-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/attr-unique-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: NS7bitAttr_Init\n");
fprintf(f, "nsslapd-plugintype: preoperation\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3705,7 +3665,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: Internationalization Plugin\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/liblcoll%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/liblcoll%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: orderingRule_init\n");
fprintf(f, "nsslapd-plugintype: matchingRule\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3718,7 +3678,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: HTTP Client\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/http-client-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/http-client-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: http_client_init\n");
fprintf(f, "nsslapd-plugintype: preoperation\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3732,7 +3692,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: Presence\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/presence-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/presence-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: presence_init\n");
fprintf(f, "nsslapd-plugintype: preoperation\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3792,12 +3752,12 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "\n");
#endif
- /* enable pass thru authentication */
+ /* enable pass thru authentication */
if (cf->use_existing_config_ds || cf->use_existing_user_ds)
{
LDAPURLDesc *desc = 0;
char *url = cf->use_existing_config_ds ? cf->config_ldap_url :
- cf->user_ldap_url;
+ cf->user_ldap_url;
if (url && !ldap_url_parse(url, &desc) && desc)
{
char *suffix = desc->lud_dn;
@@ -3814,7 +3774,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: Pass Through Authentication\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/passthru-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/passthru-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: passthruauth_init\n");
fprintf(f, "nsslapd-plugintype: preoperation\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3826,17 +3786,17 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
ldap_free_urldesc(desc);
}
} else { /* just add the config, disabled */
- fprintf(f, "dn: cn=Pass Through Authentication,cn=plugins,cn=config\n");
- fprintf(f, "objectclass: top\n");
- fprintf(f, "objectclass: nsSlapdPlugin\n");
- fprintf(f, "objectclass: extensibleObject\n");
- fprintf(f, "cn: Pass Through Authentication\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/passthru-plugin%s\n", sroot, shared_lib);
- fprintf(f, "nsslapd-plugininitfunc: passthruauth_init\n");
- fprintf(f, "nsslapd-plugintype: preoperation\n");
- fprintf(f, "nsslapd-pluginenabled: off\n");
- fprintf(f, "nsslapd-plugin-depends-on-type: database\n");
- fprintf(f, "\n");
+ fprintf(f, "dn: cn=Pass Through Authentication,cn=plugins,cn=config\n");
+ fprintf(f, "objectclass: top\n");
+ fprintf(f, "objectclass: nsSlapdPlugin\n");
+ fprintf(f, "objectclass: extensibleObject\n");
+ fprintf(f, "cn: Pass Through Authentication\n");
+ fprintf(f, "nsslapd-pluginpath: %s/lib/passthru-plugin%s\n", prefix, shared_lib);
+ fprintf(f, "nsslapd-plugininitfunc: passthruauth_init\n");
+ fprintf(f, "nsslapd-plugintype: preoperation\n");
+ fprintf(f, "nsslapd-pluginenabled: off\n");
+ fprintf(f, "nsslapd-plugin-depends-on-type: database\n");
+ fprintf(f, "\n");
}
#ifdef BUILD_PAM_PASSTHRU
@@ -3848,7 +3808,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "objectclass: pamConfig\n");
fprintf(f, "cn: PAM Pass Through Auth\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/pam-passthru-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/pam-passthru-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: pam_passthruauth_init\n");
fprintf(f, "nsslapd-plugintype: preoperation\n");
fprintf(f, "nsslapd-pluginenabled: off\n");
@@ -3872,7 +3832,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: ldbm database\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/libback-ldbm%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/libback-ldbm%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: ldbm_back_init\n");
fprintf(f, "nsslapd-plugintype: database\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3891,7 +3851,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "cn: config\n");
fprintf(f, "nsslapd-lookthroughlimit: 5000\n");
fprintf(f, "nsslapd-mode: 600\n");
- fprintf(f, "nsslapd-directory: %s/db\n", cs_path);
+ fprintf(f, "nsslapd-directory: %s\n", cf->db_dir);
fprintf(f, "nsslapd-dbcachesize: 10485760\n");
/* will be default from 6.2 or 6.11... */
if (getenv("USE_OLD_IDL_SWITCH")) {
@@ -3909,20 +3869,17 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
/* default user-defined ldbm indexes */
ds_gen_index(f, "cn=default indexes, cn=config,cn=ldbm database,cn=plugins,cn=config");
-
-
-
fprintf(f, "dn: cn=monitor, cn=ldbm database, cn=plugins, cn=config\n");
fprintf(f, "objectclass: top\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: monitor\n");
fprintf(f, "\n");
- fprintf(f, "dn: cn=database, cn=monitor, cn=ldbm database, cn=plugins, cn=config\n");
- fprintf(f, "objectclass: top\n");
- fprintf(f, "objectclass: extensibleObject\n");
- fprintf(f, "cn: database\n");
- fprintf(f, "\n");
+ fprintf(f, "dn: cn=database, cn=monitor, cn=ldbm database, cn=plugins, cn=config\n");
+ fprintf(f, "objectclass: top\n");
+ fprintf(f, "objectclass: extensibleObject\n");
+ fprintf(f, "cn: database\n");
+ fprintf(f, "\n");
/* Entries for the chaining backend plugin */
fprintf(f, "dn: cn=chaining database,cn=plugins,cn=config\n");
@@ -3930,7 +3887,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: nsSlapdPlugin\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: chaining database\n");
- fprintf(f, "nsslapd-pluginpath: %s/lib/chainingdb-plugin%s\n", sroot, shared_lib);
+ fprintf(f, "nsslapd-pluginpath: %s/lib/chainingdb-plugin%s\n", prefix, shared_lib);
fprintf(f, "nsslapd-plugininitfunc: chaining_back_init\n");
fprintf(f, "nsslapd-plugintype: database\n");
fprintf(f, "nsslapd-pluginenabled: on\n");
@@ -3940,10 +3897,10 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "objectclass: top\n");
fprintf(f, "objectclass: extensibleObject\n");
fprintf(f, "cn: config\n");
- fprintf(f, "nsTransmittedControls: 2.16.840.1.113730.3.4.2\n");
- fprintf(f, "nsTransmittedControls: 2.16.840.1.113730.3.4.9\n");
- fprintf(f, "nsTransmittedControls: 1.2.840.113556.1.4.473\n");
- fprintf(f, "nsTransmittedControls: 1.3.6.1.4.1.1466.29539.12\n");
+ fprintf(f, "nsTransmittedControls: 2.16.840.1.113730.3.4.2\n");
+ fprintf(f, "nsTransmittedControls: 2.16.840.1.113730.3.4.9\n");
+ fprintf(f, "nsTransmittedControls: 1.2.840.113556.1.4.473\n");
+ fprintf(f, "nsTransmittedControls: 1.3.6.1.4.1.1466.29539.12\n");
fprintf(f, "nsPossibleChainingComponents: cn=resource limits,cn=components,cn=config\n");
fprintf(f, "nsPossibleChainingComponents: cn=certificate-based authentication,cn=components,cn=config\n");
fprintf(f, "nsPossibleChainingComponents: cn=ACL Plugin,cn=plugins,cn=config\n");
@@ -4060,20 +4017,22 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fclose (f);
- PR_snprintf(src, sizeof(src), "%s%cdse.ldif", cf->config_dir, FILE_PATHSEP);
- PR_snprintf(dest, sizeof(dest), "%s%cdse_original.ldif", cf->config_dir, FILE_PATHSEP);
- create_instance_copy(src, dest, 0600);
+ PR_snprintf(src, sizeof(src), "%s%c%s",
+ cf->config_dir, FILE_PATHSEP, DS_CONFIG_FILE);
+ PR_snprintf(dest, sizeof(dest), "%s%c%s",
+ cf->config_dir, FILE_PATHSEP, DS_ORIGCONFIG_FILE);
+ create_instance_copy(src, dest, 0600, 0 );
- /* install certmap.conf at <sysconfig>/BRAND_DS */
+ /* install certmap.conf at <configdir> */
PR_snprintf(src, sizeof(src), "%s/bin/slapd/install/config/certmap.conf",
- cf->sroot);
+ cf->prefix);
PR_snprintf(dest, sizeof(dest), "%s/certmap.conf", cf->config_dir);
- create_instance_copy(src, dest, 0600);
+ create_instance_copy(src, dest, 0600, 0 );
- /* generate <sysconfdir>/BRAND_DS/slapd-collations.conf */
+ /* generate <confdir>/slapd-collations.conf */
PR_snprintf(src, sizeof(src),
"%s/bin/slapd/install/config/%s-collations.conf",
- cf->sroot, PRODUCT_NAME);
+ cf->prefix, PRODUCT_NAME);
PR_snprintf(dest, sizeof(dest), "%s%c%s-collations.conf",
cf->config_dir, FILE_PATHSEP, PRODUCT_NAME);
if (!(srcf = fopen(src, "r"))) {
@@ -4097,18 +4056,13 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
/*
* <sysconfdir>/BRAND_DS/schema to schema_dir
*/
-#if 0 /* going to be 1 !! */
- PR_snprintf(src, sizeof(src), "%s%c%s%cschema",
- cf->sysconfdir, FILE_PATHSEP, BRAND_DS, FILE_PATHSEP);
-#else
- PR_snprintf(src, sizeof(src), "%s/bin/slapd/install/schema", sroot);
-#endif
+ PR_snprintf(src, sizeof(src), "%s/bin/slapd/install/schema", cf->prefix);
if (NULL != (t = ds_copy_group_files(src, cf->schema_dir, 0)))
return t;
#if defined (BUILD_PRESENCE)
- PR_snprintf(src, sizeof(src), "%s/bin/slapd/install/presence", sroot);
- PR_snprintf(dest, sizeof(dest), "%s/config/presence", cs_path);
+ PR_snprintf(src, sizeof(src), "%s/bin/slapd/install/presence", cf->prefix);
+ PR_snprintf(dest, sizeof(dest), "%s/presence", cf->config_dir);
if (t = ds_copy_group_files(src, dest, 0))
return t;
#endif
@@ -4203,7 +4157,7 @@ ds_gen_gw_conf(char *sroot, char *cs_path, server_config_s *cf, int conf_type)
if (t != cf->suffix) free(t);
- fprintf(f, "securitypath\t\"%s%calias%c%s-cert.db\"\n\n", sroot, FILE_PATHSEP, FILE_PATHSEP, ctxt );
+ fprintf(f, "securitypath\t\"%s%calias%c%s-cert.db\"\n\n", cf->cert_dir, FILE_PATHSEP, FILE_PATHSEP, ctxt );
fprintf(f, "# The url base to the orgchart application.\n#No link from the DSGW to the orgchart will appear in the UI if this configuration line is commented out.\n");
fprintf(f, "url-orgchart-base\thttp://%s:%s/clients/orgchart/bin/org?context=%s&data=\n\n", cf->servname, cf->adminport ? cf->adminport : "80", ctxt);
@@ -4254,7 +4208,7 @@ ds_gen_gw_conf(char *sroot, char *cs_path, server_config_s *cf, int conf_type)
PR_snprintf(defaultconf, sizeof(defaultconf), "%s%cclients%cdsgw%ccontext%cdefault.conf", sroot,
FILE_PATHSEP,FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP);
- create_instance_copy(dest, defaultconf, NEWFILE_MODE);
+ create_instance_copy(dest, defaultconf, NEWFILE_MODE, 0 );
chownfile (pw, defaultconf);
}
unlink(src);
@@ -4437,7 +4391,8 @@ static int init_presence(char *sroot, server_config_s *cf, char *cs_path)
char precmd[PATH_SIZE];
precmd[0] = 0;
- PR_snprintf(tools, sizeof(tools), "%s%cshared%cbin", sroot, FILE_PATHSEP, FILE_PATHSEP);
+ PR_snprintf(tools, sizeof(tools), "%s%cshared%cbin",
+ cf->prefix, FILE_PATHSEP, FILE_PATHSEP);
#ifdef XP_UNIX
PR_snprintf(precmd, sizeof(precmd), "cd %s;", tools);
@@ -4519,7 +4474,6 @@ static char *install_ds(char *sroot, server_config_s *cf, char *param_name)
SLAPD_CONFIG slapd_conf;
QUERY_VARS query_vars;
char *t, src[PATH_SIZE], dest[PATH_SIZE], big_line[PATH_SIZE];
- char cs_path[PATH_SIZE];
struct passwd* pw = NULL;
int isrunning;
int status = 0;
@@ -4540,67 +4494,86 @@ static char *install_ds(char *sroot, server_config_s *cf, char *param_name)
}
#endif
- PR_snprintf(cs_path, sizeof(cs_path), "%s%c"PRODUCT_NAME"-%s", sroot, FILE_PATHSEP, cf->servid);
-
/* create all <a_server>/<subdirs> */
if ( (t = ds_cre_subdirs(cf, pw)) )
return(t);
/* Generate all scripts */
- if ( (t = ds_gen_scripts(sroot, cf, cs_path)) )
+ if ( (t = ds_gen_scripts(sroot, cf, cf->inst_dir)) )
return(t);
#if defined( XP_WIN32 )
ds_dostounixpath( sroot );
- ds_dostounixpath( cs_path );
+ ds_dostounixpath( cf->inst_dir );
#endif
/* Generate all conf files */
- if ( (t = ds_gen_confs(sroot, cf, cs_path)) )
+ if ( (t = ds_gen_confs(sroot, cf, cf->inst_dir)) )
return(t);
- PR_snprintf(src, sizeof(src), "%s%cbin%c"PRODUCT_NAME"%cinstall%cldif%cExample.ldif", sroot, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP,
- FILE_PATHSEP);
- PR_snprintf(dest, sizeof(dest), "%s%cExample.ldif", cf->ldif_dir, FILE_PATHSEP);
- create_instance_copy(src, dest, NEWFILE_MODE);
+ PR_snprintf(src, sizeof(src),
+ "%s%cbin%c"PRODUCT_NAME"%cinstall%cldif%cExample.ldif",
+ cf->prefix, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP,
+ FILE_PATHSEP, FILE_PATHSEP);
+ PR_snprintf(dest, sizeof(dest), "%s%cExample.ldif",
+ cf->ldif_dir, FILE_PATHSEP);
+ create_instance_copy(src, dest, NEWFILE_MODE, 1);
chownfile (pw, dest);
- PR_snprintf(src, sizeof(src), "%s%cbin%c"PRODUCT_NAME"%cinstall%cldif%cExample-roles.ldif", sroot, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP,
- FILE_PATHSEP);
- PR_snprintf(dest, sizeof(dest), "%s%cExample-roles.ldif", cf->ldif_dir, FILE_PATHSEP);
- create_instance_copy(src, dest, NEWFILE_MODE);
+ PR_snprintf(src, sizeof(src),
+ "%s%cbin%c"PRODUCT_NAME"%cinstall%cldif%cExample-roles.ldif",
+ cf->prefix, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP,
+ FILE_PATHSEP, FILE_PATHSEP);
+ PR_snprintf(dest, sizeof(dest), "%s%cExample-roles.ldif",
+ cf->ldif_dir, FILE_PATHSEP);
+ create_instance_copy(src, dest, NEWFILE_MODE, 1);
chownfile (pw, dest);
- PR_snprintf(src, sizeof(src), "%s%cbin%c"PRODUCT_NAME"%cinstall%cldif%cExample-views.ldif", sroot, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP,
- FILE_PATHSEP);
- PR_snprintf(dest, sizeof(dest), "%s%cExample-views.ldif", cf->ldif_dir, FILE_PATHSEP);
- create_instance_copy(src, dest, NEWFILE_MODE);
+ PR_snprintf(src, sizeof(src),
+ "%s%cbin%c"PRODUCT_NAME"%cinstall%cldif%cExample-views.ldif",
+ cf->prefix, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP,
+ FILE_PATHSEP, FILE_PATHSEP);
+ PR_snprintf(dest, sizeof(dest), "%s%cExample-views.ldif",
+ cf->ldif_dir, FILE_PATHSEP);
+ create_instance_copy(src, dest, NEWFILE_MODE, 1);
chownfile (pw, dest);
- PR_snprintf(src, sizeof(src), "%s%cbin%c"PRODUCT_NAME"%cinstall%cldif%cEuropean.ldif", sroot, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP,
- FILE_PATHSEP);
- PR_snprintf(dest, sizeof(dest), "%s%cEuropean.ldif", cf->ldif_dir, FILE_PATHSEP);
- create_instance_copy(src, dest, NEWFILE_MODE);
+ PR_snprintf(src, sizeof(src),
+ "%s%cbin%c"PRODUCT_NAME"%cinstall%cldif%cEuropean.ldif",
+ cf->prefix, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP,
+ FILE_PATHSEP, FILE_PATHSEP);
+ PR_snprintf(dest, sizeof(dest), "%s%cEuropean.ldif",
+ cf->ldif_dir, FILE_PATHSEP);
+ create_instance_copy(src, dest, NEWFILE_MODE, 1);
chownfile (pw, dest);
#ifdef DSML
/* new code for dsml sample files */
- PR_snprintf(src, sizeof(src), "%s%cbin%c"PRODUCT_NAME"%cinstall%cdsml%cExample.dsml", sroot, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP,
- FILE_PATHSEP);
- PR_snprintf(dest, sizeof(dest), "%s%cdsml%cExample.dsml", cs_path, FILE_PATHSEP, FILE_PATHSEP);
- create_instance_copy(src, dest, NEWFILE_MODE);
+ PR_snprintf(src, sizeof(src),
+ "%s%cbin%c"PRODUCT_NAME"%cinstall%cdsml%cExample.dsml",
+ cf->prefix, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP,
+ FILE_PATHSEP, FILE_PATHSEP);
+ PR_snprintf(dest, sizeof(dest), "%s%cdsml%cExample.dsml",
+ bogus, FILE_PATHSEP, FILE_PATHSEP);
+ create_instance_copy(src, dest, NEWFILE_MODE, 1);
chownfile (pw, dest);
- PR_snprintf(src, sizeof(src), "%s%cbin%c"PRODUCT_NAME"%cinstall%cdsml%cExample-roles.dsml", sroot, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP,
- FILE_PATHSEP);
- PR_snprintf(dest, sizeof(dest), "%s%cdsml%cExample-roles.dsml", cs_path, FILE_PATHSEP, FILE_PATHSEP);
- create_instance_copy(src, dest, NEWFILE_MODE);
+ PR_snprintf(src, sizeof(src),
+ "%s%cbin%c"PRODUCT_NAME"%cinstall%cdsml%cExample-roles.dsml",
+ cf->prefix, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP,
+ FILE_PATHSEP, FILE_PATHSEP);
+ PR_snprintf(dest, sizeof(dest), "%s%cdsml%cExample-roles.dsml",
+ bogus, FILE_PATHSEP, FILE_PATHSEP);
+ create_instance_copy(src, dest, NEWFILE_MODE, 1);
chownfile (pw, dest);
- PR_snprintf(src, sizeof(src), "%s%cbin%c"PRODUCT_NAME"%cinstall%cdsml%cEuropean.dsml", sroot, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP,
- FILE_PATHSEP);
- PR_snprintf(dest, sizeof(dest), "%s%cdsml%cEuropean.dsml", cs_path, FILE_PATHSEP, FILE_PATHSEP);
- create_instance_copy(src, dest, NEWFILE_MODE);
+ PR_snprintf(src, sizeof(src),
+ "%s%cbin%c"PRODUCT_NAME"%cinstall%cdsml%cEuropean.dsml",
+ sroot, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP,
+ FILE_PATHSEP, FILE_PATHSEP);
+ PR_snprintf(dest, sizeof(dest), "%s%cdsml%cEuropean.dsml",
+ bogus, FILE_PATHSEP, FILE_PATHSEP);
+ create_instance_copy(src, dest, NEWFILE_MODE, 1);
chownfile (pw, dest);
#endif
@@ -4647,11 +4620,7 @@ static char *install_ds(char *sroot, server_config_s *cf, char *param_name)
if (getenv("USE_DEBUGGER"))
verbose = 0;
/* error log file */
-#if 0
- PR_snprintf(errorlog, sizeof(errorlog), "%s%cerrors", cf->log_dir, FILE_PATHSEP,
-#else /* will go away */
- PR_snprintf(errorlog, sizeof(errorlog), "%s%clogs%cerrors", cf->inst_dir, FILE_PATHSEP, FILE_PATHSEP);
-#endif
+ PR_snprintf(errorlog, sizeof(errorlog), "%s%cerrors", cf->log_dir, FILE_PATHSEP);
start_status = ds_bring_up_server_install(verbose, cf->inst_dir, errorlog);
if (start_status != DS_SERVER_UP)
@@ -4750,17 +4719,17 @@ static char *install_ds(char *sroot, server_config_s *cf, char *param_name)
}
else if (t) /* just notify the user about the port conflict */
{
- ds_show_message(t);
+ ds_show_message(t);
}
#if defined (BUILD_PRESENCE)
/* Create script for initializing IM Presence images */
if ((NULL == t) && (0 == status))
{
- if ( (t = gen_presence_init_script(sroot, cf, cs_path)) )
+ if ( (t = gen_presence_init_script(sroot, cf, cf->inst_dir)) )
return(t);
/* Initialize IM Presence images */
- status = init_presence(sroot, cf, cs_path);
+ status = init_presence(sroot, cf, cf->inst_dir);
if (status)
return make_error ("ds_exec_and_report() failed (%d).", status);
}
@@ -4873,11 +4842,23 @@ set_path_attribute(char *attr, char *defaultval, char *prefix)
{
char *temp = ds_a_get_cgi_var(attr, NULL, NULL);
char *rstr = NULL;
- if (prefix) {
+ if (prefix && strlen(prefix) > 0) {
if (NULL == temp || '\0' == *temp) {
- rstr = PR_smprintf("%s%c%s", prefix, FILE_PATHSEP, defaultval);
+ if (NULL == defaultval) {
+ rstr = PR_smprintf("%s", prefix);
+ } else if (FILE_PATHSEP == *defaultval) {
+ rstr = PR_smprintf("%s%s", prefix, defaultval);
+ } else {
+ rstr = PR_smprintf("%s%c%s", prefix, FILE_PATHSEP, defaultval);
+ }
} else {
- rstr = PR_smprintf("%s%c%s", prefix, FILE_PATHSEP, temp);
+ if (NULL == temp) {
+ rstr = PR_smprintf("%s", prefix);
+ } else if (FILE_PATHSEP == *temp) {
+ rstr = PR_smprintf("%s%s", prefix, temp);
+ } else {
+ rstr = PR_smprintf("%s%c%s", prefix, FILE_PATHSEP, temp);
+ }
}
} else {
if (NULL == temp || '\0' == *temp) {
@@ -4905,28 +4886,39 @@ set_path_attribute(char *attr, char *defaultval, char *prefix)
* cf->lock_dir: <localstatedir>/lock/slapd-<servid>
* cf->log_dir: <localstatedir>/log/slapd-<servid>
* cf->run_dir: <localstatedir>/run/slapd-<servid>
+ * cf->db_dir: <localstatedir>/lib/slapd-<servid>/db
+ * cf->bak_dir: <localstatedir>/lib/slapd-<servid>/bak
+ * cf->tmp_dir: <localstatedir>/tmp/slapd-<servid>
+ * cf->ldif_dir: <datadir>/<brand-ds>/slapd-<servid>
+ * cf->cert_dir: <sysconfdir>/BRAND_DS/slapd-<servid>
+ *
+ * NOTE: If prefix is given, all the other paths start from prefix.
+ * NETSITE_ROOT is treated as a secondary prefix. (If prefix is also set,
+ * it's ignored. If prefix is not set, NETSITE_ROOT becomes prefix.
+ * If both are not set, the paths start from '/'.)
+ * Therefore, NETSITE_ROOT is not mandatory any more.
*/
int parse_form(server_config_s *cf)
{
char *rm = getenv("REQUEST_METHOD");
char *qs = getenv("QUERY_STRING");
- char* cfg_sspt_uid_pw1;
- char* cfg_sspt_uid_pw2;
- LDAPURLDesc *desc = 0;
- char *temp = 0;
+ char *cfg_sspt_uid_pw1 = NULL;
+ char *cfg_sspt_uid_pw2 = NULL;
+ char *temp = NULL;
char *prefix = NULL;
+ LDAPURLDesc *desc = 0;
cf->brand_ds = BRAND_DS;
- temp = getenv("NETSITE_ROOT");
+ prefix = getenv("NETSITE_ROOT");
+#if 0
if (NULL == temp) {
ds_report_error (DS_INCORRECT_USAGE,
" NETSITE_ROOT environment variable not set.",
"The environment variable NETSITE_ROOT must be set to the server root directory.");
return 1;
}
- cf->sroot = PL_strdup(temp);
-
+#endif
if (rm && qs && !strcmp(rm, "GET"))
{
ds_get_begin(qs);
@@ -4945,7 +4937,13 @@ int parse_form(server_config_s *cf)
temp = ds_a_get_cgi_var("prefix", NULL, NULL);
if (NULL != temp) {
prefix = cf->prefix = PL_strdup(temp);
+ } else if (NULL != prefix) {
+ cf->prefix = prefix;
+ } else {
+ prefix = cf->prefix = "";
}
+ cf->sroot = PR_smprintf("%s%clib%c%s",
+ prefix, FILE_PATHSEP, FILE_PATHSEP, cf->brand_ds);
if (!(cf->servname = ds_a_get_cgi_var("servname", "Server Name",
"Please give a hostname for your server.")))
@@ -5143,14 +5141,9 @@ int parse_form(server_config_s *cf)
temp = ds_a_get_cgi_var("log_dir", NULL, NULL);
if (NULL == temp) {
-#if 0
cf->log_dir = PR_smprintf("%s%clog%c%s-%s",
cf->localstatedir, FILE_PATHSEP, FILE_PATHSEP,
PRODUCT_NAME, cf->servid);
-#else /* will go away */
- cf->log_dir = PR_smprintf("%s%clogs",
- cf->inst_dir, FILE_PATHSEP);
-#endif
} else {
cf->log_dir = PL_strdup(temp);
}
@@ -5183,6 +5176,8 @@ int parse_form(server_config_s *cf)
} else {
cf->bak_dir = PL_strdup(temp);
}
+ /* set bak dir to the environment variable DS_BAK_DIR */
+ ds_set_bak_dir(cf->bak_dir);
temp = ds_a_get_cgi_var("ldif_dir", NULL, NULL);
if (NULL == temp) {
@@ -5192,5 +5187,25 @@ int parse_form(server_config_s *cf)
cf->ldif_dir = PL_strdup(temp);
}
+ temp = ds_a_get_cgi_var("tmp_dir", NULL, NULL);
+ if (NULL == temp) {
+ cf->tmp_dir = PR_smprintf("%s%ctmp%c%s-%s",
+ cf->localstatedir, FILE_PATHSEP, FILE_PATHSEP,
+ PRODUCT_NAME, cf->servid);
+ } else {
+ cf->tmp_dir = PL_strdup(temp);
+ }
+ /* set tmp dir to the environment variable DS_TMP_DIR */
+ ds_set_tmp_dir(cf->tmp_dir);
+
+ temp = ds_a_get_cgi_var("cert_dir", NULL, NULL);
+ if (NULL == temp) {
+ cf->cert_dir = PR_smprintf("%s%c%s%c%s-%s",
+ cf->sysconfdir, FILE_PATHSEP, cf->brand_ds,
+ FILE_PATHSEP, PRODUCT_NAME, cf->servid);
+ } else {
+ cf->cert_dir = PL_strdup(temp);
+ }
+
return 0;
}
diff --git a/ldap/admin/src/create_instance.h b/ldap/admin/src/create_instance.h
index 89500cf6..12893b0f 100644
--- a/ldap/admin/src/create_instance.h
+++ b/ldap/admin/src/create_instance.h
@@ -50,8 +50,6 @@ extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
#define BRAND_DS "fedora-ds"
-#define DS_CONFIG_DIR "DS_CONFIG_DIR"
-#define DS_CONFIG_FILE "dse.ldif"
#ifdef XP_UNIX
#define PRODUCT_NAME "slapd"
@@ -131,6 +129,8 @@ typedef struct {
char *db_dir;
char *bak_dir;
char *ldif_dir;
+ char *tmp_dir;
+ char *cert_dir;
char *prefix;
} server_config_s;
diff --git a/ldap/admin/src/ds_remove.c b/ldap/admin/src/ds_remove.c
index ee2491ac..aefc88bf 100644
--- a/ldap/admin/src/ds_remove.c
+++ b/ldap/admin/src/ds_remove.c
@@ -189,8 +189,8 @@ int main(int argc, char *argv[])
}
/*
- * Get the server pathto delete.
- * serevrpath = /export/serevrs/dirserv/slapd-talac
+ * Get the server path to delete.
+ * serverpath = /<server_root>/slapd-<id>
*/
if (!(servername = ds_get_cgi_var("InstanceName")))
servername = ds_get_server_name();
diff --git a/ldap/admin/src/scripts/template-bak2db.pl b/ldap/admin/src/scripts/template-bak2db.pl
index a409aeb2..0153666d 100644
--- a/ldap/admin/src/scripts/template-bak2db.pl
+++ b/ldap/admin/src/scripts/template-bak2db.pl
@@ -55,7 +55,7 @@ $taskname = "";
$archivedir = "";
$dbtype = "ldbm database";
$instance = "";
-$dsroot = "{{DS-ROOT}}";
+$prefix = "{{DS-ROOT}}";
$mydsroot = "{{MY-DS-ROOT}}";
$verbose = 0;
$rootdn = "";
@@ -127,7 +127,7 @@ $nsdbtype = "nsDatabaseType: $dbtype\n";
$entry = "${dn}${misc}${cn}${nsinstance}${nsarchivedir}${nsdbtype}";
$vstr = "";
if ($verbose != 0) { $vstr = "-v"; }
-chdir("$dsroot{{SEP}}shared{{SEP}}bin");
-open(FOO, "| $dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapmodify $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -a" );
+chdir("$prefix{{SEP}}shared{{SEP}}bin");
+open(FOO, "| $prefix{{SEP}}shared{{SEP}}bin{{SEP}}ldapmodify $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -a" );
print(FOO "$entry");
close(FOO);
diff --git a/ldap/admin/src/scripts/template-db2bak.pl b/ldap/admin/src/scripts/template-db2bak.pl
index 231bf920..9d9eb851 100644
--- a/ldap/admin/src/scripts/template-db2bak.pl
+++ b/ldap/admin/src/scripts/template-db2bak.pl
@@ -53,8 +53,8 @@ sub usage {
$taskname = "";
$archivedir = "";
$dbtype = "ldbm database";
-$dsroot = "{{DS-ROOT}}";
-$mydsroot = "{{MY-DS-ROOT}}";
+$prefix = "{{DS-ROOT}}";
+$mybakdir = "{{BAK-DIR}}";
$verbose = 0;
$rootdn = "";
$passwd = "";
@@ -105,7 +105,7 @@ if ( $rootdn eq "" || $passwd eq "") { &usage; exit(1); }
$mn++; $yr += 1900;
$taskname = "backup_${yr}_${mn}_${dy}_${h}_${m}_${s}";
if ($archivedir eq "") {
- $archivedir = "${mydsroot}{{SEP}}bak{{SEP}}${yr}_${mn}_${dy}_${h}_${m}_${s}";
+ $archivedir = "${bakdir}{{SEP}}bak{{SEP}}${yr}_${mn}_${dy}_${h}_${m}_${s}";
}
$dn = "dn: cn=$taskname, cn=backup, cn=tasks, cn=config\n";
$misc = "changetype: add\nobjectclass: top\nobjectclass: extensibleObject\n";
@@ -115,7 +115,7 @@ $nsdbtype = "nsDatabaseType: $dbtype\n";
$entry = "${dn}${misc}${cn}${nsarchivedir}${nsdbtype}";
$vstr = "";
if ($verbose != 0) { $vstr = "-v"; }
-chdir("$dsroot{{SEP}}shared{{SEP}}bin");
-open(FOO, "| $dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapmodify $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -a" );
+chdir("$prefix{{SEP}}shared{{SEP}}bin");
+open(FOO, "| $prefix{{SEP}}shared{{SEP}}bin{{SEP}}ldapmodify $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -a" );
print(FOO "$entry");
close(FOO);
diff --git a/ldap/admin/src/scripts/template-db2index.pl b/ldap/admin/src/scripts/template-db2index.pl
index 9e791098..80e5a613 100644
--- a/ldap/admin/src/scripts/template-db2index.pl
+++ b/ldap/admin/src/scripts/template-db2index.pl
@@ -65,8 +65,7 @@ $attribute_arg = "";
$vlvattribute_arg = "";
$verbose = 0;
-$dsroot = "{{DS-ROOT}}";
-$mydsroot = "{{MY-DS-ROOT}}";
+$prefix = "{{DS-ROOT}}";
$i = 0;
while ($i <= $#ARGV)
@@ -163,11 +162,11 @@ $attribute="";
$indexes_list="";
$vlvattribute="";
$vlvindexes_list="";
-chdir("$dsroot{{SEP}}shared{{SEP}}bin");
+chdir("$prefix{{SEP}}shared{{SEP}}bin");
if ( $attribute_arg eq "" && $vlvattribute_arg eq "" )
{
# Get the list of indexes from the entry
- $indexes_list="$dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapsearch $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -s one " .
+ $indexes_list="$prefix{{SEP}}shared{{SEP}}bin{{SEP}}ldapsearch $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -s one " .
"-b \"cn=index,cn=\"$instance\", cn=ldbm database,cn=plugins,cn=config\" \"(&(objectclass=*)(nsSystemIndex=false))\" cn";
# build the values of the attribute nsIndexAttribute
@@ -187,7 +186,7 @@ if ( $attribute_arg eq "" && $vlvattribute_arg eq "" )
}
# Get the list of indexes from the entry
- $vlvindexes_list="$dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapsearch $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -s sub -b \"cn=\"$instance\", cn=ldbm database,cn=plugins,cn=config\" \"objectclass=vlvIndex\" cn";
+ $vlvindexes_list="$prefix{{SEP}}shared{{SEP}}bin{{SEP}}ldapsearch $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -s sub -b \"cn=\"$instance\", cn=ldbm database,cn=plugins,cn=config\" \"objectclass=vlvIndex\" cn";
# build the values of the attribute nsIndexVlvAttribute
open(LDAP1, "$vlvindexes_list |");
@@ -220,6 +219,6 @@ $cn = "cn: $taskname\n";
$nsinstance = "nsInstance: ${instance}\n";
$entry = "${dn}${misc}${cn}${nsinstance}${attribute}${vlvattribute}";
-open(FOO, "| $dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapmodify $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -a" );
+open(FOO, "| $prefix{{SEP}}shared{{SEP}}bin{{SEP}}ldapmodify $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -a" );
print(FOO "$entry");
close(FOO);
diff --git a/ldap/admin/src/scripts/template-db2ldif.pl b/ldap/admin/src/scripts/template-db2ldif.pl
index be6efedc..19eb0f46 100644
--- a/ldap/admin/src/scripts/template-db2ldif.pl
+++ b/ldap/admin/src/scripts/template-db2ldif.pl
@@ -100,8 +100,9 @@ $printkey = 1;
$taskname = "";
$ldiffile = "";
$doreplica = 0;
-$dsroot = "{{DS-ROOT}}";
-$mydsroot = "{{MY-DS-ROOT}}";
+$prefix = "{{DS-ROOT}}";
+$ldifdir = "{{LDIF-DIR}}";
+$servid = "{{SERV-ID}}";
$verbose = 0;
$rootdn = "";
$passwd = "";
@@ -195,7 +196,7 @@ if (($instances[0] eq "" && $included[0] eq "") || $rootdn eq "" || $passwd eq "
$mn++; $yr += 1900;
$taskname = "export_${yr}_${mn}_${dy}_${h}_${m}_${s}";
if ($ldiffile eq "") {
- $ldiffile = "${mydsroot}{{SEP}}ldif{{SEP}}${yr}_${mn}_${dy}_${h}_${m}_${s}.ldif";
+ $ldiffile = "${ldifdir}{{SEP}}${servid}-${yr}_${mn}_${dy}_${h}_${m}_${s}.ldif";
}
$dn = "dn: cn=$taskname, cn=export, cn=tasks, cn=config\n";
$misc = "changetype: add\nobjectclass: top\nobjectclass: extensibleObject\n";
@@ -241,7 +242,7 @@ $nsldiffile = "nsFilename: ${ldiffile}\n";
$entry = "${dn}${misc}${cn}${nsinstance}${nsincluded}${nsexcluded}${nsreplica}${nsnobase64}${nsnowrap}${nsnoversion}${nsnouniqueid}${nsuseid2entry}${nsonefile}${nsexportdecrypt}${nsprintkey}${nsldiffile}";
$vstr = "";
if ($verbose != 0) { $vstr = "-v"; }
-chdir("$dsroot{{SEP}}shared{{SEP}}bin");
-open(FOO, "| $dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapmodify $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -a" );
+chdir("$prefix{{SEP}}shared{{SEP}}bin");
+open(FOO, "| $prefix{{SEP}}shared{{SEP}}bin{{SEP}}ldapmodify $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -a" );
print(FOO "$entry");
close(FOO);
diff --git a/ldap/admin/src/scripts/template-ldif2db.pl b/ldap/admin/src/scripts/template-ldif2db.pl
index 04aa2f22..148c9d6e 100644
--- a/ldap/admin/src/scripts/template-ldif2db.pl
+++ b/ldap/admin/src/scripts/template-ldif2db.pl
@@ -93,7 +93,7 @@ $mergechunksiz = 0;
$genuniqid = "time";
$uniqidname = "";
$taskname = "";
-$dsroot = "{{DS-ROOT}}";
+$prefix = "{{DS-ROOT}}";
$mydsroot = "{{MY-DS-ROOT}}";
$verbose = 0;
$rootdn = "";
@@ -219,7 +219,7 @@ if ($uniqidname ne "") { $nsuniqidname = "nsUniqueIdGeneratorNamespace: ${uniqid
$entry = "${dn}${misc}${cn}${nsinstance}${nsincluded}${nsexcluded}${nsldiffiles}${nsnoattrindexes}${nsimportencrypt}${nsmergechunksiz}${nsgenuniqid}${nsuniqidname}";
$vstr = "";
if ($verbose != 0) { $vstr = "-v"; }
-chdir("$dsroot{{SEP}}shared{{SEP}}bin");
-open(FOO, "| $dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapmodify $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -a" );
+chdir("$prefix{{SEP}}shared{{SEP}}bin");
+open(FOO, "| $prefix{{SEP}}shared{{SEP}}bin{{SEP}}ldapmodify $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -a" );
print(FOO "$entry");
close(FOO);
diff --git a/ldap/admin/src/scripts/template-ns-accountstatus.pl b/ldap/admin/src/scripts/template-ns-accountstatus.pl
index 0cc5c3ee..96c31ed8 100644
--- a/ldap/admin/src/scripts/template-ns-accountstatus.pl
+++ b/ldap/admin/src/scripts/template-ns-accountstatus.pl
@@ -356,7 +356,7 @@ sub checkScope
###############################
# Generated variable
-$dsroot="{{DS-ROOT}}";
+$prefix="{{DS-ROOT}}";
# Determine which command we are running
if ( $0 =~ /ns-inactivate(.pl)?$/ )
@@ -392,7 +392,7 @@ else
debug("Running ** $cmd ** $operation\n");
-$dsbinroot="$dsroot{{SEP}}shared{{SEP}}bin";
+$dsbinroot="$prefix{{SEP}}shared{{SEP}}bin";
$ldapsearch="$dsbinroot{{SEP}}ldapsearch -1";
$ldapmodify="$dsbinroot{{SEP}}ldapmodify";
diff --git a/ldap/admin/src/scripts/template-ns-activate.pl b/ldap/admin/src/scripts/template-ns-activate.pl
index 0cc5c3ee..96c31ed8 100644
--- a/ldap/admin/src/scripts/template-ns-activate.pl
+++ b/ldap/admin/src/scripts/template-ns-activate.pl
@@ -356,7 +356,7 @@ sub checkScope
###############################
# Generated variable
-$dsroot="{{DS-ROOT}}";
+$prefix="{{DS-ROOT}}";
# Determine which command we are running
if ( $0 =~ /ns-inactivate(.pl)?$/ )
@@ -392,7 +392,7 @@ else
debug("Running ** $cmd ** $operation\n");
-$dsbinroot="$dsroot{{SEP}}shared{{SEP}}bin";
+$dsbinroot="$prefix{{SEP}}shared{{SEP}}bin";
$ldapsearch="$dsbinroot{{SEP}}ldapsearch -1";
$ldapmodify="$dsbinroot{{SEP}}ldapmodify";
diff --git a/ldap/admin/src/scripts/template-ns-inactivate.pl b/ldap/admin/src/scripts/template-ns-inactivate.pl
index 0cc5c3ee..96c31ed8 100644
--- a/ldap/admin/src/scripts/template-ns-inactivate.pl
+++ b/ldap/admin/src/scripts/template-ns-inactivate.pl
@@ -356,7 +356,7 @@ sub checkScope
###############################
# Generated variable
-$dsroot="{{DS-ROOT}}";
+$prefix="{{DS-ROOT}}";
# Determine which command we are running
if ( $0 =~ /ns-inactivate(.pl)?$/ )
@@ -392,7 +392,7 @@ else
debug("Running ** $cmd ** $operation\n");
-$dsbinroot="$dsroot{{SEP}}shared{{SEP}}bin";
+$dsbinroot="$prefix{{SEP}}shared{{SEP}}bin";
$ldapsearch="$dsbinroot{{SEP}}ldapsearch -1";
$ldapmodify="$dsbinroot{{SEP}}ldapmodify";
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 */