# End Source File
# Begin Source File
+SOURCE=.\os\win32\ap_regkey.h
+
+!IF "$(CFG)" == "libhttpd - Win32 Release"
+
+# PROP Ignore_Default_Tool 1
+# Begin Custom Build - Creating include/ap_regkey.h
+InputPath=.\os\win32\ap_regkey.h
+
+".\include\ap_regkey.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ type .\os\win32\ap_regkey.h > .\include\ap_regkey.h
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "libhttpd - Win32 Debug"
+
+# PROP Ignore_Default_Tool 1
+# Begin Custom Build - Creating include/ap_regkey.h
+InputPath=.\os\win32\ap_regkey.h
+
+".\include\ap_regkey.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ type .\os\win32\ap_regkey.h > .\include\ap_regkey.h
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
SOURCE=.\modules\http\mod_core.h
!IF "$(CFG)" == "libhttpd - Win32 Release"
# End Source File
# Begin Source File
-SOURCE=.\os\win32\ap_regkey.h
-# End Source File
-# Begin Source File
-
SOURCE=.\server\error_bucket.c
# End Source File
# Begin Source File
# End Source File
# Begin Source File
-SOURCE=.\server\mpm\winnt\registry.c
-# End Source File
-# Begin Source File
-
SOURCE=.\server\mpm\winnt\service.c
# End Source File
# End Group
typedef HANDLE thread;
/* Definitions of WINNT MPM specific config globals */
-static apr_pool_t *pconf;
+apr_pool_t *pconf;
static apr_pool_t *pchild = NULL;
static int workers_may_exit = 0;
static int shutdown_in_progress = 0;
int running_as_service = 1;
int errout = 0;
+ pconf = process->pconf;
+
osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osver);
#include "ap_listen.h"
-/* From registry.c: */
-
-apr_status_t ap_registry_create_key(const char *key);
-apr_status_t ap_registry_delete_key(const char *key);
-
-apr_status_t ap_registry_store_value(const char *key, const char *name,
- const char *value);
-apr_status_t ap_registry_get_value(apr_pool_t *p, const char *key,
- const char *name, char **ppValue);
-apr_status_t ap_registry_store_array(apr_pool_t *p, const char *key,
- const char *name, int nelts,
- char const* const* elts);
-apr_status_t ap_registry_get_array(apr_pool_t *p, const char *key,
- const char *name,
- apr_array_header_t **parray);
-apr_status_t ap_registry_delete_value(const char *key, const char *name);
-
-
/* From service.c: */
#define SERVICE_APACHE_RESTART 128
+++ /dev/null
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- * Portions of this software are based upon public domain software
- * originally written at the National Center for Supercomputing Applications,
- * University of Illinois, Urbana-Champaign.
- */
-
-/*
- * Functions to handle interacting with the Win32 registry
- */
-
-/*
- * Apache registry key structure
- *
- * Apache's registry information is stored in the HKEY_LOCAL_MACHINE
- * key, under
- *
- * HKLM\SOFTWARE\Apache Software Foundation\Apache\version
- *
- * These keys are defined in this file. The definition of the "version" part
- * will need updating each time Apache moves from beta to non-beta or from a
- * release to a development or beta version.
- */
-
-#include "httpd.h"
-#include "http_log.h"
-#include "mpm_winnt.h"
-#include "apr_strings.h"
-
-/* bet you are looking to change revisions to roll the tarball...
- * Guess what, you already did. Revised May '00 to save you from
- * searching all over creation for every revision tag.
- */
-
-#define VENDOR AP_SERVER_BASEVENDOR
-#define SOFTWARE AP_SERVER_BASEPRODUCT
-#define VERSION AP_SERVER_BASEREVISION
-
-#define REGKEY "SOFTWARE\\" VENDOR "\\" SOFTWARE "\\" VERSION
-
-/*
- * The Windows API registry key functions don't set the last error
- * value (the windows equivalent of errno). So we need to set it
- * with SetLastError() before calling the aplog_error() function.
- * Because this is common, let's have a macro.
- */
-#define return_error(rv) return (apr_set_os_error(APR_FROM_OS_ERROR(rv)),\
- APR_FROM_OS_ERROR(rv));
-
-apr_status_t ap_registry_create_key(const char *key)
-{
- HKEY hKey = HKEY_LOCAL_MACHINE;
- HKEY hKeyNext;
- char keystr[MAX_PATH + 1];
- char *parsekey = keystr;
- char *nextkey = keystr;
- DWORD result;
- int rv;
-
- apr_cpystrn(keystr, key, sizeof(keystr) - 1);
-
- /* Walk the tree, creating at each stage if necessary */
- while (parsekey) {
- if (nextkey = strchr(parsekey, '\\'))
- *(nextkey++) = '\0';
-
- rv = RegCreateKeyEx(hKey,
- parsekey, /* subkey */
- 0, /* reserved */
- NULL, /* class */
- REG_OPTION_NON_VOLATILE,
- KEY_WRITE,
- NULL,
- &hKeyNext,
- &result);
-
- /* Close the old key */
- if (hKey != HKEY_LOCAL_MACHINE)
- RegCloseKey(hKey);
- hKey = hKeyNext;
-
- if (rv != ERROR_SUCCESS)
- break;
-
- parsekey = nextkey;
- }
-
- if (hKey != HKEY_LOCAL_MACHINE)
- RegCloseKey(hKey);
-
- return_error(rv);
-}
-
-apr_status_t ap_registry_delete_key(const char *key)
-{
- apr_status_t rv;
- HKEY hKey;
- int nSize = 0;
- char tempkey[MAX_PATH + 1];
- char *parsekey;
-
- apr_cpystrn(tempkey, key, sizeof(parsekey) - 1);
- parsekey = strrchr(tempkey, '\\');
-
- if (parsekey) {
- *(parsekey++) = '\0';
- rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- tempkey,
- 0,
- KEY_WRITE,
- &hKey);
-
- if (rv != ERROR_SUCCESS)
- return_error(rv);
- }
- else {
- parsekey = tempkey;
- hKey = HKEY_LOCAL_MACHINE;
- }
-
- rv = RegDeleteKey(hKey, key);
-
- if (hKey != HKEY_LOCAL_MACHINE)
- RegCloseKey(hKey);
-
- return_error(rv);
-}
-
-/* Clean up a way over complicated process.
- *
- * The return value is APR_SUCCESS, APR_ENOENT, APR_NOTFOUND, or the OS error
- */
-
-apr_status_t ap_registry_get_value(apr_pool_t *p, const char *key, const char *name, char **ppValue)
-{
- apr_status_t rv;
- HKEY hKey;
- int nSize = 0;
-
- rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- key,
- 0,
- KEY_READ,
- &hKey);
-
- if (rv != ERROR_SUCCESS)
- return_error(rv);
-
- /* Find the size required for the data by passing NULL as the buffer
- * pointer. On return nSize will contain the size required for the
- * buffer if the return value is ERROR_SUCCESS.
- */
- rv = RegQueryValueEx(hKey,
- name, /* key name */
- NULL, /* reserved */
- NULL, /* type */
- NULL, /* for value */
- &nSize); /* for size of "value" */
-
- if (rv != ERROR_SUCCESS)
- return_error(rv);
-
- *ppValue = apr_palloc(p, nSize + 1);
- (*ppValue)[nSize] = '\0';
-
- rv = RegQueryValueEx(hKey,
- name, /* key name */
- NULL, /* reserved */
- NULL, /* type */
- *ppValue, /* for value */
- &nSize); /* for size of "value" */
-
- RegCloseKey(hKey);
-
- return_error(rv);
-}
-
-apr_status_t ap_registry_get_array(apr_pool_t *p, const char *key, const char *name, apr_array_header_t **parray)
-{
- char *pValue;
- char *tmp;
- char **newelem;
- apr_status_t rv;
- HKEY hKey;
- int nSize = 0;
-
- rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- key,
- 0,
- KEY_READ,
- &hKey);
-
- if (rv != ERROR_SUCCESS)
- return_error(rv);
-
- /* Find the size required for the data by passing NULL as the buffer
- * pointer. On return nSize will contain the size required for the
- * buffer if the return value is ERROR_SUCCESS.
- */
- rv = RegQueryValueEx(hKey,
- name, /* key name */
- NULL, /* reserved */
- NULL, /* type */
- NULL, /* for value */
- &nSize); /* for size of "value" */
-
- if (rv != ERROR_SUCCESS) {
- return_error(rv);
- }
- else
- {
- /* Small possiblity the array is either unterminated
- * or single NULL terminated. Avert.
- */
- pValue = apr_palloc(p, nSize + 2);
- pValue[nSize + 1] = '\0';
- pValue[nSize] = '\0';
-
- rv = RegQueryValueEx(hKey,
- name, /* key name */
- NULL, /* reserved */
- NULL, /* type */
- pValue, /* for value */
- &nSize); /* for size of "value" */
-
- nSize = 0; /* Element Count */
- for (tmp = pValue; *tmp; ++tmp) {
- ++nSize;
- while (*tmp) {
- ++tmp;
- }
- }
-
- *parray = apr_array_make(p, nSize, sizeof(char *));
- for (tmp = pValue; *tmp; ++tmp) {
- newelem = (char **) apr_array_push(*parray);
- *newelem = tmp;
- while (*tmp) {
- ++tmp;
- }
- }
- }
-
- RegCloseKey(hKey);
-
- return_error(rv);
-}
-
-/*
- * ap_registry_store_key_value() stores a value name and value under the
- * Apache registry key. If the Apache key does not exist it is created
- * first. This function is intended to be called from a wrapper function
- * in this file to set particular data values, such as
- * ap_registry_set_server_root() below.
- *
- * Returns 0 if the value name and data was stored successfully, or
- * returns -1 if the Apache key does not exist (since we try to create
- * this key, this should never happen), or -4 if any other error occurred
- * (these values are consistent with ap_registry_get_key_value()).
- * If the return value is negative then the error will already have been
- * logged via aplog_error().
- */
-
-apr_status_t ap_registry_store_value(const char *key, const char *name, const char *value)
-{
- long rv;
- HKEY hKey;
-
- rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- key,
- 0,
- KEY_WRITE,
- &hKey);
-
- if (rv == ERROR_FILE_NOT_FOUND)
- {
- rv = ap_registry_create_key(key);
-
- if (rv != APR_SUCCESS)
- return_error(rv);
-
- rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- key,
- 0,
- KEY_WRITE,
- &hKey);
- }
-
- if (rv != ERROR_SUCCESS)
- return_error(rv);
-
- /* Now set the value and data */
- rv = RegSetValueEx(hKey,
- name, /* value key name */
- 0, /* reserved */
- REG_SZ, /* type */
- value, /* value data */
- (DWORD) strlen(value) + 1); /* for size of "value" */
-
- if (rv == ERROR_SUCCESS) {
- ap_log_error(APLOG_MARK,APLOG_INFO,rv,NULL,
- "Registry stored HKLM\\" REGKEY "\\%s value %s", key, value);
- }
-
- /* Make sure we close the key even if there was an error storing
- * the data
- */
- RegCloseKey(hKey);
-
- return_error(rv);
-}
-
-apr_status_t ap_registry_store_array(apr_pool_t *p,
- const char *key, const char *name,
- int nelts, const char * const * elts)
-{
- int bufsize, i;
- char *buf, *tmp;
- long rv;
- HKEY hKey;
-
- rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- key,
- 0,
- KEY_WRITE,
- &hKey);
-
- if (rv == ERROR_FILE_NOT_FOUND)
- {
- rv = ap_registry_create_key(key);
-
- if (rv != APR_SUCCESS)
- return_error(rv);
-
- rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- key,
- 0,
- KEY_WRITE,
- &hKey);
- }
-
- if (rv != ERROR_SUCCESS)
- return_error(rv);
-
- bufsize = 1; /* For trailing second null */
- for (i = 0; i < nelts; ++i)
- {
- bufsize += strlen(elts[i]) + 1;
- }
- if (!nelts)
- ++bufsize;
-
- buf = apr_palloc(p, bufsize);
- tmp = buf;
- for (i = 0; i < nelts; ++i)
- {
- strcpy(tmp, elts[i]);
- tmp += strlen(elts[i]) + 1;
- }
- if (!nelts)
- (*tmp++) = '\0';
- *tmp = '\0'; /* Trailing second null */
-
- /* Now set the value and data */
- rv = RegSetValueEx(hKey,
- name, /* value key name */
- 0, /* reserved */
- REG_MULTI_SZ, /* type */
- buf, /* value data */
- (DWORD) bufsize); /* for size of "value" */
-
- if (rv == ERROR_SUCCESS) {
- ap_log_error(APLOG_MARK,APLOG_INFO,rv,NULL,
- "Registry stored HKLM\\" REGKEY "\\%s", key);
- }
-
- /* Make sure we close the key even if there was an error storing
- * the data
- */
- RegCloseKey(hKey);
-
- return_error(rv);
-}
-
-/* A key or value that does not exist is _not_ an error while deleting. */
-
-apr_status_t ap_registry_delete_value(const char *key, const char *name)
-{
- apr_status_t rv;
- HKEY hKey;
-
- rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- key,
- 0,
- KEY_WRITE,
- &hKey);
-
- if (rv == ERROR_FILE_NOT_FOUND)
- return APR_SUCCESS;
-
- if (rv != ERROR_SUCCESS)
- return_error(rv);
-
- rv = RegDeleteValue(hKey, name);
-
- if (rv == ERROR_FILE_NOT_FOUND)
- rv = APR_SUCCESS;
-
- RegCloseKey(hKey);
- return_error(rv);
-}
-
-/*
- * Get the server root from the registry into 'dir' which is
- * size bytes long. Returns 0 if the server root was found
- * or if the serverroot key does not exist (in which case
- * dir will contain an empty string), or -1 if there was
- * an error getting the key.
- */
-apr_status_t ap_registry_get_server_root(apr_pool_t *p, char **buf)
-{
- apr_status_t rv;
-
- rv = ap_registry_get_value(p, REGKEY, "ServerRoot", buf);
- if (rv)
- *buf = NULL;
-
- return rv;
-}
-
-
-/*
- * Sets the serverroot value within the registry. Returns 0 on success
- * or -1 on error. If -1 is return the error will already have been
- * logged via aplog_error().
- */
-
-apr_status_t ap_registry_set_server_root(char *dir)
-{
- return ap_registry_store_value(REGKEY, "ServerRoot", dir);
-}
#include "mpm_winnt.h"
#include "apr_strings.h"
#include "apr_lib.h"
+#include "ap_regkey.h"
#ifdef NOUSER
#undef NOUSER
static int ReportStatusToSCMgr(int currentState, int exitCode, int waitHint);
+
+#define PRODREGKEY "SOFTWARE\\" AP_SERVER_BASEVENDOR "\\" \
+ AP_SERVER_BASEPRODUCT "\\" AP_SERVER_BASEREVISION
+
+/*
+ * Get the server root from the registry into 'dir' which is
+ * size bytes long. Returns 0 if the server root was found
+ * or if the serverroot key does not exist (in which case
+ * dir will contain an empty string), or -1 if there was
+ * an error getting the key.
+ */
+apr_status_t ap_registry_get_server_root(apr_pool_t *p, char **buf)
+{
+ apr_status_t rv;
+ ap_regkey_t *key;
+
+ if ((rv = ap_regkey_open(&key, AP_REGKEY_LOCAL_MACHINE, PRODREGKEY,
+ APR_READ, p)) == APR_SUCCESS) {
+ rv = ap_regkey_value_get(buf, key, "ServerRoot", p);
+ ap_regkey_close(key);
+ if (rv == APR_SUCCESS)
+ return rv;
+ }
+
+ if ((rv = ap_regkey_open(&key, AP_REGKEY_CURRENT_USER, PRODREGKEY,
+ APR_READ, p)) == APR_SUCCESS) {
+ rv = ap_regkey_value_get(buf, key, "ServerRoot", p);
+ ap_regkey_close(key);
+ if (rv == APR_SUCCESS)
+ return rv;
+ }
+
+ *buf = NULL;
+ return rv;
+}
+
+
/* The service configuration's is stored under the following trees:
*
* HKLM\System\CurrentControlSet\Services\[service name]
* notify the service control manager of the name change.
*/
+/* borrowed from mpm_winnt.c */
+extern apr_pool_t *pconf;
+
/* Windows 2000 alone supports ChangeServiceConfig2 in order to
* register our server_version string... so we need some fixups
* to avoid binding to that function if we are on WinNT/9x.
/* Cast is necessary, ChangeServiceConfig2 handles multiple
* object types, some volatile, some not.
*/
+ /* ###: utf-ize */
if (ChangeServiceConfig2(schService,
1 /* SERVICE_CONFIG_DESCRIPTION */,
(LPVOID) &full_description)) {
if (full_description)
{
char szPath[MAX_PATH];
- HKEY hkey;
+ ap_regkey_t *svckey;
+ apr_status_t rv;
- /* Create/Find the Service key that Monitor Applications iterate */
+ /* Find the Service key that Monitor Applications iterate */
apr_snprintf(szPath, sizeof(szPath),
"SYSTEM\\CurrentControlSet\\Services\\%s",
mpm_service_name);
- if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, szPath, 0, KEY_SET_VALUE, &hkey)
- != ERROR_SUCCESS) {
+ rv = ap_regkey_open(&svckey, AP_REGKEY_LOCAL_MACHINE, szPath,
+ APR_WRITE, pconf);
+ if (rv != APR_SUCCESS) {
return;
}
-
/* Attempt to set the Description value for our service */
- RegSetValueEx(hkey, "Description", 0, REG_SZ,
- (unsigned char *) full_description,
- strlen(full_description) + 1);
- RegCloseKey(hkey);
+ ap_regkey_value_set(svckey, "Description", full_description, pconf);
+ ap_regkey_close(svckey);
}
}
*/
extern apr_array_header_t *mpm_new_argv;
+/* ###: utf-ize */
static void __stdcall service_nt_main_fn(DWORD argc, LPTSTR *argv)
{
const char *ignored;
globdat.ssStatus.dwCurrentState = SERVICE_START_PENDING;
globdat.ssStatus.dwCheckPoint = 1;
+ /* ###: utf-ize */
if (!(globdat.hServiceStatus = RegisterServiceCtrlHandler(argv[0], service_nt_ctrl)))
{
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, apr_get_os_error(),
{ NULL, NULL }
};
+ /* ###: utf-ize */
if (!StartServiceCtrlDispatcher(dispatchTable))
{
/* This is a genuine failure of the SCM. */
const char *set_name)
{
char key_name[MAX_PATH];
+ ap_regkey_t *key;
apr_status_t rv;
/* ### Needs improvement, on Win2K the user can _easily_
mpm_service_name = apr_palloc(p, strlen(set_name) + 1);
apr_collapse_spaces((char*) mpm_service_name, set_name);
apr_snprintf(key_name, sizeof(key_name), SERVICECONFIG, mpm_service_name);
- rv = ap_registry_get_value(p, key_name, "DisplayName", &mpm_display_name);
+ rv = ap_regkey_open(&key, AP_REGKEY_LOCAL_MACHINE, key_name, APR_READ, pconf);
+ if (rv == APR_SUCCESS) {
+ rv = ap_regkey_value_get(&mpm_display_name, key, "DisplayName", pconf);
+ ap_regkey_close(key);
+ }
if (rv != APR_SUCCESS) {
/* Take the given literal name if there is no service entry */
mpm_display_name = apr_pstrdup(p, set_name);
- }
+ }
*display_name = mpm_display_name;
return rv;
}
char conf_key[MAX_PATH];
char **cmb_data;
apr_status_t rv;
+ ap_regkey_t *key;
apr_snprintf(conf_key, sizeof(conf_key), SERVICEPARAMS, mpm_service_name);
- rv = ap_registry_get_array(p, conf_key, "ConfigArgs", &svc_args);
+ rv = ap_regkey_open(&key, AP_REGKEY_LOCAL_MACHINE, conf_key, APR_READ, p);
+ if (rv == APR_SUCCESS) {
+ rv = ap_regkey_value_array_get(&svc_args, key, "ConfigArgs", p);
+ ap_regkey_close(key);
+ }
if (rv != APR_SUCCESS) {
if (rv == ERROR_FILE_NOT_FOUND) {
ap_log_error(APLOG_MARK, APLOG_INFO, 0, NULL,
char key_name[MAX_PATH];
char exe_path[MAX_PATH];
char *launch_cmd;
- apr_status_t(rv);
+ ap_regkey_t *key;
+ apr_status_t rv;
fprintf(stderr,reconfig ? "Reconfiguring the %s service\n"
: "Installing the %s service\n", mpm_display_name);
+ /* ###: utf-ize */
if (GetModuleFileName(NULL, exe_path, sizeof(exe_path)) == 0)
{
apr_status_t rv = apr_get_os_error();
launch_cmd = apr_psprintf(ptemp, "\"%s\" -k runservice", exe_path);
if (reconfig) {
+ /* ###: utf-ize */
schService = OpenService(schSCManager, mpm_service_name,
SERVICE_ALL_ACCESS);
if (!schService) {
apr_get_os_error(), NULL,
"OpenService failed");
}
+ /* ###: utf-ize */
else if (!ChangeServiceConfig(schService,
SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START,
* be warned that future apache modules or ISAPI dll's may
* depend on it.
*/
+ /* ###: utf-ize */
schService = CreateService(schSCManager, // SCManager database
mpm_service_name, // name of service
mpm_display_name, // name to display
/* Store the launch command in the registry */
launch_cmd = apr_psprintf(ptemp, "\"%s\" -n %s -k runservice",
exe_path, mpm_service_name);
- rv = ap_registry_store_value(SERVICECONFIG9X, mpm_service_name, launch_cmd);
+ rv = ap_regkey_open(&key, AP_REGKEY_LOCAL_MACHINE, SERVICECONFIG9X,
+ APR_READ, pconf);
+ if (rv == APR_SUCCESS) {
+ rv = ap_regkey_value_set(key, mpm_service_name, launch_cmd, pconf);
+ ap_regkey_close(key);
+ }
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
"%s: Failed to add the RunServices registry entry.",
}
apr_snprintf(key_name, sizeof(key_name), SERVICECONFIG, mpm_service_name);
- rv = ap_registry_store_value(key_name, "ImagePath", launch_cmd);
+ rv = ap_regkey_open(&key, AP_REGKEY_LOCAL_MACHINE, key_name,
+ APR_READ, pconf);
+ if (rv != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
+ "%s: Failed to create the registry service key.",
+ mpm_display_name);
+ return (rv);
+ }
+ rv = ap_regkey_value_set(key, "ImagePath", launch_cmd, pconf);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
"%s: Failed to store ImagePath in the registry.",
mpm_display_name);
+ ap_regkey_close(key);
return (rv);
}
- rv = ap_registry_store_value(key_name, "DisplayName", mpm_display_name);
+ rv = ap_regkey_value_set(key, "DisplayName", mpm_display_name, pconf);
+ ap_regkey_close(key);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
"%s: Failed to store DisplayName in the registry.",
/* For both WinNT & Win9x store the service ConfigArgs in the registry...
*/
apr_snprintf(key_name, sizeof(key_name), SERVICEPARAMS, mpm_service_name);
- rv = ap_registry_store_array(ptemp, key_name, "ConfigArgs", argc, argv);
+ rv = ap_regkey_open(&key, AP_REGKEY_LOCAL_MACHINE, key_name,
+ APR_READ, pconf);
+ if (rv == APR_SUCCESS) {
+ rv = ap_regkey_value_array_set(key, "ConfigArgs", argc, argv, pconf);
+ ap_regkey_close(key);
+ }
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
"%s: Failed to store the ConfigArgs in the registry.",
return (rv);
}
+ /* ###: utf-ize */
schService = OpenService(schSCManager, mpm_service_name, SERVICE_ALL_ACCESS);
if (!schService) {
}
else /* osver.dwPlatformId != VER_PLATFORM_WIN32_NT */
{
+ apr_status_t rv2, rv3;
+ ap_regkey_t *key;
fprintf(stderr,"Removing the %s service\n", mpm_display_name);
/* TODO: assure the service is stopped before continuing */
- if (ap_registry_delete_value(SERVICECONFIG9X, mpm_service_name)) {
- rv = apr_get_os_error();
+ rv = ap_regkey_open(&key, AP_REGKEY_LOCAL_MACHINE, SERVICECONFIG9X,
+ APR_WRITE, pconf);
+ if (rv == APR_SUCCESS) {
+ rv = ap_regkey_value_remove(key, mpm_service_name, pconf);
+ ap_regkey_close(key);
+ }
+ if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
"%s: Failed to remove the RunServices registry "
"entry.", mpm_display_name);
- return (rv);
}
/* we blast Services/us, not just the Services/us/Parameters branch */
+ apr_snprintf(key_name, sizeof(key_name), SERVICEPARAMS, mpm_service_name);
+ rv2 = ap_regkey_remove(AP_REGKEY_LOCAL_MACHINE, key_name, pconf);
apr_snprintf(key_name, sizeof(key_name), SERVICECONFIG, mpm_service_name);
- if (ap_registry_delete_key(key_name))
- {
- rv = apr_get_os_error();
- ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
+ rv3 = ap_regkey_remove(AP_REGKEY_LOCAL_MACHINE, key_name, pconf);
+ rv2 = (rv2 != APR_SUCCESS) ? rv2 : rv3;
+ if (rv2 != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv2, NULL,
"%s: Failed to remove the service config from the "
"registry.", mpm_display_name);
- return (rv);
}
+ rv = (rv != APR_SUCCESS) ? rv : rv2;
+ if (rv != APR_SUCCESS)
+ return rv;
}
fprintf(stderr,"The %s service has been removed successfully.\n", mpm_display_name);
return APR_SUCCESS;
return (rv);
}
+ /* ###: utf-ize */
schService = OpenService(schSCManager, mpm_service_name,
SERVICE_START | SERVICE_QUERY_STATUS);
if (!schService) {
start_argv[argc] = NULL;
rv = APR_EINIT;
+ /* ###: utf-ize */
if (StartService(schService, argc, start_argv)
&& signal_service_transition(schService, 0, /* test only */
SERVICE_START_PENDING,
"Failed to open the NT Service Manager");
return;
}
-
+
+ /* ###: utf-ize */
schService = OpenService(schSCManager, mpm_service_name,
SERVICE_ALL_ACCESS);