Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/admin/lib
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv16463/ldap/admin/lib
Modified Files:
dsalib_conf.c dsalib_location.c dsalib_updown.c
Log Message:
[207427] parameterizing the hardcoded paths (Comment #15)
phase 1. parameterizing config, schema and ldif directory
Index: dsalib_conf.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/lib/dsalib_conf.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- dsalib_conf.c 19 Apr 2005 22:06:54 -0000 1.5
+++ dsalib_conf.c 27 Sep 2006 23:40:44 -0000 1.6
@@ -51,7 +51,7 @@
#include "nspr.h"
-#define CONF_FILE_NAME "config/dse.ldif"
+#define CONF_FILE_NAME "dse.ldif"
#define CONF_SUFFIX "cn=config"
DS_EXPORT_SYMBOL char *
@@ -69,7 +69,7 @@
ds_get_config(int type)
{
char conffile[PATH_MAX];
- char *root;
+ char *configdir;
FILE *sf = NULL;
char **conf_list = NULL;
@@ -78,12 +78,12 @@
return(NULL);
}
- if ( (root = ds_get_install_root()) == NULL ) {
- ds_send_error("Cannot find server root directory.", 0);
+ if ( (configdir = ds_get_config_dir()) == NULL ) {
+ ds_send_error("Cannot find configuration directory.", 0);
return(NULL);
}
- PR_snprintf(conffile, PATH_MAX, "%s/%s", root, CONF_FILE_NAME);
+ PR_snprintf(conffile, PATH_MAX, "%s/%s", configdir, CONF_FILE_NAME);
if ( !(sf = fopen(conffile, "r")) ) {
ds_send_error("could not read config file.", 1);
Index: dsalib_location.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/lib/dsalib_location.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- dsalib_location.c 19 Apr 2005 22:06:54 -0000 1.6
+++ dsalib_location.c 27 Sep 2006 23:40:44 -0000 1.7
@@ -58,11 +58,11 @@
if ( (root = getenv("NETSITE_ROOT")) == NULL )
return(NULL);
- /* WIN32: Needed to take care of embedded space, */
- /* otherwise system() call fails */
- root = ds_makeshort( root );
+ /* WIN32: Needed to take care of embedded space, */
+ /* otherwise system() call fails */
+ root = ds_makeshort( root );
- return root;
+ return root;
}
/*
@@ -87,6 +87,52 @@
}
/*
+ * Returns the config file location of the server. Info is
+ * returned in a static area. The caller must copy it
+ * for reuse if needed.
+ */
+DS_EXPORT_SYMBOL char *
+ds_get_config_dir()
+{
+ return getenv("DS_CONFIG_DIR");
+}
+
+/*
+ * set config_dir to environment variable DS_CONFIG_DIR
+ * to retrieve the value using ds_get_config_dir later.
+ */
+DS_EXPORT_SYMBOL void
+ds_set_config_dir(char *config_dir)
+{
+ static char env[PATH_MAX];
+ PR_snprintf(env, sizeof(env), "DS_CONFIG_DIR=%s", config_dir);
+ putenv(env);
+}
+
+/*
+ * Returns the run dir of the server, where pid 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_run_dir()
+{
+ return getenv("DS_RUN_DIR");
+}
+
+/*
+ * set run_dir to environment variable DS_RUN_DIR
+ * to retrieve the value using ds_get_run_dir later.
+ */
+DS_EXPORT_SYMBOL void
+ds_set_run_dir(char *run_dir)
+{
+ static char env[PATH_MAX];
+ PR_snprintf(env, sizeof(env), "DS_RUN_DIR=%s", run_dir);
+ putenv(env);
+}
+
+/*
* Returns the install location of the server under the admserv
* directory.
*/
@@ -109,50 +155,50 @@
ds_get_server_name()
{
if( getenv("SERVER_NAMES") )
- return( getenv("SERVER_NAMES") );
- else {
- static char logfile[PATH_MAX];
- char *buf;
- char *out = logfile;
- buf = getenv("SCRIPT_NAME");
- if ( buf && (*buf == '/') )
- buf++;
- while ( *buf && (*buf != '/') ) {
- *out++ = *buf++;
- }
- *out = 0;
- return logfile;
- }
+ return( getenv("SERVER_NAMES") );
+ else {
+ static char logfile[PATH_MAX];
+ char *buf;
+ char *out = logfile;
+ buf = getenv("SCRIPT_NAME");
+ if ( buf && (*buf == '/') )
+ buf++;
+ while ( *buf && (*buf != '/') ) {
+ *out++ = *buf++;
+ }
+ *out = 0;
+ return logfile;
+ }
}
DS_EXPORT_SYMBOL char *
ds_get_logfile_name(int config_type)
{
char *filename;
- char **ds_config = NULL;
+ char **ds_config = NULL;
static char logfile[PATH_MAX+1];
if ( (ds_config = ds_get_config(DS_REAL_CONFIG)) == NULL ) {
- /* For DS 4.0, no error output if file doesn't exist - that's
- a normal situation */
- /* ds_send_error("ds_get_config(DS_REAL_CONFIG) == NULL", 0); */
+ /* For DS 4.0, no error output if file doesn't exist - that's
+ a normal situation */
+ /* ds_send_error("ds_get_config(DS_REAL_CONFIG) == NULL", 0); */
return(NULL);
}
filename = ds_get_value(ds_config, ds_get_var_name(config_type), 0, 1);
if ( filename == NULL ) {
- /* For DS 4.0, no error output if file doesn't exist - that's
- a normal situation */
- /* ds_send_error("ds_get_logfile_name: filename == NULL", 0); */
+ /* For DS 4.0, no error output if file doesn't exist - that's
+ a normal situation */
+ /* ds_send_error("ds_get_logfile_name: filename == NULL", 0); */
return(NULL);
}
if ( ((int) strlen(filename)) >= PATH_MAX ) {
- ds_send_error("ds_get_logfile_name: filename too long", 0);
- free(filename);
+ ds_send_error("ds_get_logfile_name: filename too long", 0);
+ free(filename);
return(NULL);
}
PL_strncpyz(logfile, filename, sizeof(logfile));
- free(filename);
+ free(filename);
return(logfile);
}
Index: dsalib_updown.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/lib/dsalib_updown.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- dsalib_updown.c 19 Apr 2005 22:06:54 -0000 1.6
+++ dsalib_updown.c 27 Sep 2006 23:40:44 -0000 1.7
@@ -80,44 +80,44 @@
DS_EXPORT_SYMBOL int
ds_get_updown_status()
{
- char pid_file_name[BIG_LINE];
- char *root;
- FILE *pidfile;
- int ipid = -1;
- int status = 0;
+ char pid_file_name[BIG_LINE];
+ char *rundir;
+ FILE *pidfile;
+ int ipid = -1;
+ int status = 0;
- if ( (root = ds_get_install_root()) == NULL ) {
- fprintf(stderr, "ds_get_updown_status: could not get install root\n");
+ if ( (rundir = ds_get_run_dir()) == NULL ) {
+ fprintf(stderr, "ds_get_updown_status: could not get install root\n");
return(DS_SERVER_UNKNOWN);
- }
- PR_snprintf(pid_file_name, BIG_LINE, "%s/logs/pid", root);
+ }
+ PR_snprintf(pid_file_name, BIG_LINE, "%s/pid", rundir);
pidfile = fopen(pid_file_name, "r");
if ( pidfile == NULL ) {
-/*
- fprintf(stderr,
- "ds_get_updown_status: could not open pid file=%s errno=%d\n",
- pid_file_name, errno);
+/*
+ fprintf(stderr,
+ "ds_get_updown_status: could not open pid file=%s errno=%d\n",
+ pid_file_name, errno);
*/
return(DS_SERVER_DOWN);
- }
- status = fscanf(pidfile, "%d\n", &ipid);
- fclose(pidfile);
+ }
+ status = fscanf(pidfile, "%d\n", &ipid);
+ fclose(pidfile);
if ( status == -1 ) {
- fprintf(stderr,
- "ds_get_updown_status: pidfile=%s server_pid=%d errno=%d\n",
- pid_file_name, ipid, errno);
+ fprintf(stderr,
+ "ds_get_updown_status: pidfile=%s server_pid=%d errno=%d\n",
+ pid_file_name, ipid, errno);
unlink(pid_file_name); /* junk in file? */
return(DS_SERVER_DOWN);
}
server_pid = (pid_t) ipid;
if ( (status = kill(server_pid, 0)) != 0 && errno != EPERM ) {
- /* we should get ESRCH if the server is down, anything else may be
- a real problem */
- if (errno != ESRCH) {
- fprintf(stderr,
- "ds_get_updown_status: pidfile=%s server_pid=%d status=%d errno=%d\n",
- pid_file_name, server_pid, status, errno);
- }
+ /* we should get ESRCH if the server is down, anything else may be
+ a real problem */
+ if (errno != ESRCH) {
+ fprintf(stderr,
+ "ds_get_updown_status: pidfile=%s server_pid=%d status=%d
errno=%d\n",
+ pid_file_name, server_pid, status, errno);
+ }
unlink(pid_file_name); /* pid does not exist! */
return(DS_SERVER_DOWN);
}
@@ -127,12 +127,12 @@
DS_EXPORT_SYMBOL int
ds_get_updown_status()
{
- char *ds_name = ds_get_server_name();
+ char *ds_name = ds_get_server_name();
HANDLE hServerDoneEvent = NULL;
/* watchdog.c creates a global event of this same name */
if((hServerDoneEvent = OpenEvent(EVENT_ALL_ACCESS, TRUE, ds_name)) != NULL)
- {
+ {
CloseHandle(hServerDoneEvent);
return(DS_SERVER_UP);
}
@@ -154,17 +154,17 @@
ds_bring_up_server_install(int verbose, char *root, char *errorlog)
{
#if !defined( XP_WIN32 )
- char startup_line[BIG_LINE];
- char statfile[PATH_MAX];
- char *tmp_dir;
+ char startup_line[BIG_LINE];
+ char statfile[PATH_MAX];
+ char *tmp_dir;
#endif
int error = -1;
- int status = DS_SERVER_DOWN;
- int cur_size = 0;
- FILE *sf = NULL;
- char msgBuf[BIG_LINE] = {0};
- int secondsToWaitForServer = 600;
- char *serverStartupString = "slapd started.";
+ int status = DS_SERVER_DOWN;
+ int cur_size = 0;
+ FILE *sf = NULL;
+ char msgBuf[BIG_LINE] = {0};
+ int secondsToWaitForServer = 600;
+ char *serverStartupString = "slapd started.";
status = ds_get_updown_status();
if ( status == DS_SERVER_UP )
@@ -173,116 +173,116 @@
return(DS_SERVER_UNKNOWN);
if (verbose) {
- ds_send_status("starting up server ...");
- cur_size = ds_get_file_size(errorlog);
- }
+ ds_send_status("starting up server ...");
+ cur_size = ds_get_file_size(errorlog);
+ }
#if !defined( XP_WIN32 )
tmp_dir = ds_get_tmp_dir();
PR_snprintf(statfile, PATH_MAX, "%s%cstartup.%d", tmp_dir, FILE_SEP,
(int)getpid());
PR_snprintf(startup_line, BIG_LINE, "%s%c%s > %s 2>&1",
- root, FILE_SEP, START_SCRIPT, statfile);
+ root, FILE_SEP, START_SCRIPT, statfile);
alter_startup_line(startup_line);
error = system(startup_line);
if (error == -1)
- error = DS_SERVER_DOWN; /* could not start server */
+ error = DS_SERVER_DOWN; /* could not start server */
else
- error = DS_SERVER_UP; /* started server */
+ error = DS_SERVER_UP; /* started server */
#else
error = StartServer();
#endif
- if (error != DS_SERVER_UP)
- {
+ if (error != DS_SERVER_UP)
+ {
#if !defined( XP_WIN32 )
- FILE* fp = fopen(statfile, "r");
- if (fp)
- {
- while(fgets(msgBuf, BIG_LINE, fp))
- ds_send_status(msgBuf);
- fclose(fp);
- }
+ FILE* fp = fopen(statfile, "r");
+ if (fp)
+ {
+ while(fgets(msgBuf, BIG_LINE, fp))
+ ds_send_status(msgBuf);
+ fclose(fp);
+ }
#endif
- return DS_SERVER_COULD_NOT_START;
- }
+ return DS_SERVER_COULD_NOT_START;
+ }
if (verbose)
{
- /*
- * Stop in N secs or whenever the startup message comes up.
- * Do whichever happens first. msgBuf will contain the last
- * line read from the errorlog.
- */
- ds_display_tail(errorlog, secondsToWaitForServer, cur_size,
- serverStartupString, msgBuf);
+ /*
+ * Stop in N secs or whenever the startup message comes up.
+ * Do whichever happens first. msgBuf will contain the last
+ * line read from the errorlog.
+ */
+ ds_display_tail(errorlog, secondsToWaitForServer, cur_size,
+ serverStartupString, msgBuf);
}
if ( error != DS_SERVER_UP ) {
- int retval = DS_SERVER_UNKNOWN;
- if (strstr(msgBuf, "semget"))
- retval = DS_SERVER_MAX_SEMAPHORES;
- else if (strstr(msgBuf, "Back-End Initialization Failed"))
- retval = DS_SERVER_CORRUPTED_DB;
- else if (strstr(msgBuf, "not initialized... exiting"))
- retval = DS_SERVER_CORRUPTED_DB;
- else if (strstr(msgBuf, "address is in use"))
- retval = DS_SERVER_PORT_IN_USE;
+ int retval = DS_SERVER_UNKNOWN;
+ if (strstr(msgBuf, "semget"))
+ retval = DS_SERVER_MAX_SEMAPHORES;
+ else if (strstr(msgBuf, "Back-End Initialization Failed"))
+ retval = DS_SERVER_CORRUPTED_DB;
+ else if (strstr(msgBuf, "not initialized... exiting"))
+ retval = DS_SERVER_CORRUPTED_DB;
+ else if (strstr(msgBuf, "address is in use"))
+ retval = DS_SERVER_PORT_IN_USE;
#if defined( XP_WIN32 )
- /* on NT, if we run out of resources, there will not even be an error
- log
- */
- else if (msgBuf[0] == 0) {
- retval = DS_SERVER_NO_RESOURCES;
- }
-#endif
- if (verbose)
- ds_send_error("error in starting server.", 1);
- return(retval);
+ /* on NT, if we run out of resources, there will not even be an error
+ log
+ */
+ else if (msgBuf[0] == 0) {
+ retval = DS_SERVER_NO_RESOURCES;
+ }
+#endif
+ if (verbose)
+ ds_send_error("error in starting server.", 1);
+ return(retval);
}
if (verbose) {
#if !defined( XP_WIN32 )
- if( !(sf = fopen(statfile, "r")) ) {
- ds_send_error("could not read status file.", 1);
- return(DS_SERVER_UNKNOWN);
- }
-
- while ( fgets(startup_line, BIG_LINE, sf) )
- ds_send_error(startup_line, 0);
- fclose(sf);
- unlink(statfile);
-#endif
- status = DS_SERVER_UNKNOWN;
- if (strstr(msgBuf, "semget"))
- status = DS_SERVER_MAX_SEMAPHORES;
- else if (strstr(msgBuf, "Back-End Initialization Failed"))
- status = DS_SERVER_CORRUPTED_DB;
- else if (strstr(msgBuf, "not initialized... exiting"))
- status = DS_SERVER_CORRUPTED_DB;
- else if (strstr(msgBuf, "address is in use"))
- status = DS_SERVER_PORT_IN_USE;
+ if( !(sf = fopen(statfile, "r")) ) {
+ ds_send_error("could not read status file.", 1);
+ return(DS_SERVER_UNKNOWN);
+ }
+
+ while ( fgets(startup_line, BIG_LINE, sf) )
+ ds_send_error(startup_line, 0);
+ fclose(sf);
+ unlink(statfile);
+#endif
+ status = DS_SERVER_UNKNOWN;
+ if (strstr(msgBuf, "semget"))
+ status = DS_SERVER_MAX_SEMAPHORES;
+ else if (strstr(msgBuf, "Back-End Initialization Failed"))
+ status = DS_SERVER_CORRUPTED_DB;
+ else if (strstr(msgBuf, "not initialized... exiting"))
+ status = DS_SERVER_CORRUPTED_DB;
+ else if (strstr(msgBuf, "address is in use"))
+ status = DS_SERVER_PORT_IN_USE;
#if defined( XP_WIN32 )
- /* on NT, if we run out of resources, there will not even be an error
- log
- */
- else if (msgBuf[0] == 0) {
- status = DS_SERVER_NO_RESOURCES;
- }
+ /* on NT, if we run out of resources, there will not even be an error
+ log
+ */
+ else if (msgBuf[0] == 0) {
+ status = DS_SERVER_NO_RESOURCES;
+ }
#endif
} else {
- int tries;
- for (tries = 0; tries < secondsToWaitForServer; tries++) {
- if (ds_get_updown_status() == DS_SERVER_UP) break;
- PR_Sleep(PR_SecondsToInterval(1));
- }
- if (verbose) {
- char str[100];
- PR_snprintf(str, sizeof(str), "Had to retry %d times", tries);
- ds_send_status(str);
- }
+ int tries;
+ for (tries = 0; tries < secondsToWaitForServer; tries++) {
+ if (ds_get_updown_status() == DS_SERVER_UP) break;
+ PR_Sleep(PR_SecondsToInterval(1));
+ }
+ if (verbose) {
+ char str[100];
+ PR_snprintf(str, sizeof(str), "Had to retry %d times", tries);
+ ds_send_status(str);
+ }
}
if ( (status == DS_SERVER_DOWN) || (status == DS_SERVER_UNKNOWN) )
- status = ds_get_updown_status();
+ status = ds_get_updown_status();
return(status);
}
@@ -300,8 +300,8 @@
ds_bring_up_server(int verbose)
{
char *root;
- int status;
- char *errorlog;
+ int status;
+ char *errorlog;
status = ds_get_updown_status();
if ( status == DS_SERVER_UP )
return(DS_SERVER_ALREADY_UP);
@@ -310,66 +310,66 @@
errorlog = ds_get_config_value(DS_ERRORLOG);
if ( errorlog == NULL ) {
- errorlog = ds_get_errors_name(); /* fallback */
+ errorlog = ds_get_errors_name(); /* fallback */
}
- return ds_bring_up_server_install(verbose, root, errorlog);
+ return ds_bring_up_server_install(verbose, root, errorlog);
}
DS_EXPORT_SYMBOL int
ds_bring_down_server()
{
char *root;
- int status;
- int cur_size;
+ int status;
+ int cur_size;
char *errorlog;
- status = ds_get_updown_status(); /* set server_pid too! */
+ status = ds_get_updown_status(); /* set server_pid too! */
if ( status != DS_SERVER_UP ) {
- ds_send_error("The server is not up.", 0);
+ ds_send_error("The server is not up.", 0);
return(DS_SERVER_ALREADY_DOWN);
}
if ( (root = ds_get_install_root()) == NULL ) {
- ds_send_error("Could not get the server root directory.", 0);
+ ds_send_error("Could not get the server root directory.", 0);
return(DS_SERVER_UNKNOWN);
}
ds_send_status("shutting down server ...");
if (!(errorlog = ds_get_errors_name())) {
- ds_send_error("Could not get the error log filename.", 0);
- return DS_SERVER_UNKNOWN;
+ ds_send_error("Could not get the error log filename.", 0);
+ return DS_SERVER_UNKNOWN;
}
cur_size = ds_get_file_size(errorlog);
#if !defined( XP_WIN32 )
if ( (kill(server_pid, SIGTERM)) != 0) {
- if (errno == EPERM) {
- ds_send_error("Not permitted to kill server.", 0);
- fprintf (stdout, "[%s]: kill (%li, SIGTERM) failed with errno =
EPERM.<br>\n",
- ds_get_server_name(), (long)server_pid);
- } else {
- ds_send_error("error in killing server.", 1);
- }
+ if (errno == EPERM) {
+ ds_send_error("Not permitted to kill server.", 0);
+ fprintf (stdout, "[%s]: kill (%li, SIGTERM) failed with errno =
EPERM.<br>\n",
+ ds_get_server_name(), (long)server_pid);
+ } else {
+ ds_send_error("error in killing server.", 1);
+ }
return(DS_SERVER_UNKNOWN);
}
#else
if( StopServer() == DS_SERVER_DOWN )
- {
- ds_send_status("shutdown: server shut down");
- }
- else
- {
+ {
+ ds_send_status("shutdown: server shut down");
+ }
+ else
+ {
ds_send_error("error in killing server.", 1);
return(DS_SERVER_UNKNOWN);
- }
+ }
#endif
/*
* Wait up to SERVER_STOP_TIMEOUT seconds for the stopped message to
- * appear in the error log.
+ * appear in the error log.
*/
ds_display_tail(errorlog, SERVER_STOP_TIMEOUT, cur_size, "slapd stopped.",
NULL);
/* in some cases, the server will tell us it's down when it's really not,
so give the OS a chance to remove it from the process table */
- PR_Sleep(PR_SecondsToInterval(1));
+ PR_Sleep(PR_SecondsToInterval(1));
return(ds_get_updown_status());
}
@@ -379,32 +379,32 @@
IsService()
{
#if 0
- CHAR ServerKey[512], *ValueString;
- HKEY hServerKey;
- DWORD dwType, ValueLength, Result;
-
- PR_snprintf(ServerKey,sizeof(ServerKey), "%s\\%s", COMPANY_KEY, PRODUCT_KEY);
-
- Result = RegOpenKey(HKEY_LOCAL_MACHINE, ServerKey, &hServerKey);
- if (Result != ERROR_SUCCESS) {
- return TRUE;
- }
- ValueLength = 512;
- ValueString = (PCHAR)malloc(ValueLength);
-
- Result = RegQueryValueEx(hServerKey, IS_SERVICE_KEY, NULL,
- &dwType, ValueString, &ValueLength);
- if (Result != ERROR_SUCCESS) {
- return TRUE;
- }
- if (strcmp(ValueString, "yes")) {
- return FALSE;
- }
- else {
- return TRUE;
- }
+ CHAR ServerKey[512], *ValueString;
+ HKEY hServerKey;
+ DWORD dwType, ValueLength, Result;
+
+ PR_snprintf(ServerKey,sizeof(ServerKey), "%s\\%s", COMPANY_KEY,
PRODUCT_KEY);
+
+ Result = RegOpenKey(HKEY_LOCAL_MACHINE, ServerKey, &hServerKey);
+ if (Result != ERROR_SUCCESS) {
+ return TRUE;
+ }
+ ValueLength = 512;
+ ValueString = (PCHAR)malloc(ValueLength);
+
+ Result = RegQueryValueEx(hServerKey, IS_SERVICE_KEY, NULL,
+ &dwType, ValueString, &ValueLength);
+ if (Result != ERROR_SUCCESS) {
+ return TRUE;
+ }
+ if (strcmp(ValueString, "yes")) {
+ return FALSE;
+ }
+ else {
+ return TRUE;
+ }
#else
- return TRUE;
+ return TRUE;
#endif
}
@@ -412,29 +412,29 @@
NSAPI_PUBLIC BOOLEAN
IsAdminService()
{
- CHAR AdminKey[512], *ValueString;
- HKEY hAdminKey;
- DWORD dwType, ValueLength, Result;
-
- PR_snprintf(AdminKey,sizeof(AdminKey), "%s\\%s", COMPANY_KEY,
ADMIN_REGISTRY_ROOT_KEY);
-
- Result = RegOpenKey(HKEY_LOCAL_MACHINE, AdminKey, &hAdminKey);
- if (Result != ERROR_SUCCESS) {
- return TRUE;
- }
- ValueLength = 512;
- ValueString = (PCHAR)malloc(ValueLength);
-
- Result = RegQueryValueEx(hAdminKey, IS_SERVICE_KEY, NULL,
- &dwType, ValueString, &ValueLength);
- if (Result != ERROR_SUCCESS) {
- return TRUE;
- }
- if (strcmp(ValueString, "yes")) {
- return FALSE;
- } else {
- return TRUE;
- }
+ CHAR AdminKey[512], *ValueString;
+ HKEY hAdminKey;
+ DWORD dwType, ValueLength, Result;
+
+ PR_snprintf(AdminKey,sizeof(AdminKey), "%s\\%s", COMPANY_KEY,
ADMIN_REGISTRY_ROOT_KEY);
+
+ Result = RegOpenKey(HKEY_LOCAL_MACHINE, AdminKey, &hAdminKey);
+ if (Result != ERROR_SUCCESS) {
+ return TRUE;
+ }
+ ValueLength = 512;
+ ValueString = (PCHAR)malloc(ValueLength);
+
+ Result = RegQueryValueEx(hAdminKey, IS_SERVICE_KEY, NULL,
+ &dwType, ValueString, &ValueLength);
+ if (Result != ERROR_SUCCESS) {
+ return TRUE;
+ }
+ if (strcmp(ValueString, "yes")) {
+ return FALSE;
+ } else {
+ return TRUE;
+ }
}
#endif
@@ -453,7 +453,7 @@
NULL, // database (NULL == default)
SC_MANAGER_ALL_ACCESS // access required
))) {
- PR_snprintf(ErrorString, sizeof(ErrorString),
+ PR_snprintf(ErrorString, sizeof(ErrorString),
"Error: Could not open the ServiceControlManager:%d "
"Please restart the server %s from the Services Program Item "
"in the Control Panel", ds_get_server_name(), GetLastError());
@@ -519,7 +519,7 @@
"Error: Could not open the ServiceControlManager:%d "
"Please restart the server %s from the Services Program Item "
"in the Control Panel", ds_get_server_name(), GetLastError());
- ds_send_error(ErrorString, 0);
+ ds_send_error(ErrorString, 0);
return(DS_SERVER_UNKNOWN);
}
return(StopNetscapeService());
@@ -534,9 +534,9 @@
char line[BIG_LINE], cmd[BIG_LINE];
char *tmp = ds_get_install_root();
- CHAR ErrorString[512];
- STARTUPINFO siStartInfo;
- PROCESS_INFORMATION piProcInfo;
+ CHAR ErrorString[512];
+ STARTUPINFO siStartInfo;
+ PROCESS_INFORMATION piProcInfo;
FILE *CmdFile;
ZeroMemory(line, sizeof(line));
@@ -545,7 +545,7 @@
CmdFile = fopen(line, "r");
if (!CmdFile)
- {
+ {
PR_snprintf(ErrorString, sizeof(ErrorString), "Error:Tried to start server
%s "
": Could not open the startup script %s :Error %d. Please "
"run startsrv.bat from the server's root directory.",
@@ -556,7 +556,7 @@
ZeroMemory(cmd, sizeof(cmd));
if (!fread(cmd, 1, BIG_LINE, CmdFile))
- {
+ {
PR_snprintf(ErrorString, sizeof(ErrorString), "Error:Tried to start server
%s "
": Could not read the startup script %s :Error %d. Please "
"run startsrv.bat from the server's root directory.",
@@ -565,25 +565,25 @@
return(DS_SERVER_DOWN);
}
- ZeroMemory(&siStartInfo, sizeof(STARTUPINFO));
- siStartInfo.cb = sizeof(STARTUPINFO);
- siStartInfo.lpReserved = siStartInfo.lpReserved2 = NULL;
- siStartInfo.cbReserved2 = 0;
- siStartInfo.lpDesktop = NULL;
-
- if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE,
- 0, NULL, NULL, &siStartInfo, &piProcInfo))
- {
+ ZeroMemory(&siStartInfo, sizeof(STARTUPINFO));
+ siStartInfo.cb = sizeof(STARTUPINFO);
+ siStartInfo.lpReserved = siStartInfo.lpReserved2 = NULL;
+ siStartInfo.cbReserved2 = 0;
+ siStartInfo.lpDesktop = NULL;
+
+ if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE,
+ 0, NULL, NULL, &siStartInfo, &piProcInfo))
+ {
PR_snprintf(ErrorString, sizeof(ErrorString), "Error:Tried to start server
%s "
": Could not start up the startup script %s :Error %d. Please "
"run startsrv.bat from the server's root directory.",
ds_get_server_name(), line, GetLastError());
ds_send_error(ErrorString, 0);
return(DS_SERVER_DOWN);
- }
+ }
- CloseHandle(piProcInfo.hProcess);
- CloseHandle(piProcInfo.hThread);
+ CloseHandle(piProcInfo.hProcess);
+ CloseHandle(piProcInfo.hThread);
return(DS_SERVER_UP);
}
@@ -596,7 +596,7 @@
hEvent = CreateEvent(NULL, TRUE, FALSE, servid);
if(!SetEvent(hEvent))
- {
+ {
PR_snprintf(ErrorString, sizeof(ErrorString), "Tried to stop existing server
%s"
": Could not signal it to stop :Error %d",
servid, GetLastError());
@@ -619,7 +619,7 @@
schService = OpenService(schSCManager, serviceName, SERVICE_ALL_ACCESS);
if (schService == NULL)
- {
+ {
PR_snprintf(ErrorString, sizeof(ErrorString), "Tried to open service"
" %s: Error %d (%s). Please"
" stop the server from the Services Item in the Control Panel",
@@ -644,7 +644,7 @@
return(DS_SERVER_DOWN);
}
else if (Error != ERROR_SERVICE_NOT_ACTIVE)
- {
+ {
PR_snprintf(ErrorString, sizeof(ErrorString), "Tried to stop service"
" %s: Error %d (%s)."
" Please stop the server from the Services Item in the"
@@ -668,7 +668,7 @@
serviceName, // name of service
SERVICE_ALL_ACCESS);
if (schService == NULL)
- {
+ {
CloseServiceHandle(schService);
PR_snprintf(ErrorString, sizeof(ErrorString),"Tried to start"
" the service %s: Error %d. Please"
@@ -679,7 +679,7 @@
}
if (!StartService(schService, 0, NULL))
- {
+ {
CloseServiceHandle(schService);
PR_snprintf(ErrorString, sizeof(ErrorString), "StartService:Could not start
"
"the Directory service %s: Error %d. Please restart the server "
@@ -703,7 +703,7 @@
RETRY:
- newServiceName = PR_smprintf("NS_%s", serviceName);
+ newServiceName = PR_smprintf("NS_%s", serviceName);
hServDoneSemaphore = CreateSemaphore(
NULL, // security attributes