]> granicus.if.org Git - apache/commitdiff
A bit more ap_regkey and apr-ization. Fixes some new bugs where the
authorWilliam A. Rowe Jr <wrowe@apache.org>
Tue, 2 Jul 2002 19:03:15 +0000 (19:03 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Tue, 2 Jul 2002 19:03:15 +0000 (19:03 +0000)
  AP_REGKEY_CREATE flag wasn't passed for ap_regkey_open (when the key
  is expected to not yet exist), and adds the new flags arg to value_set.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95937 13f79535-47bb-0310-9956-ffa450edef68

server/mpm/winnt/mpm_winnt.c
server/mpm/winnt/nt_eventlog.c
server/mpm/winnt/service.c

index 5af17f45e4c52af961b79979e7a7af07c378e9ce..11a48f4eb5c350177a9f5c0e98b9ebab8125028c 100644 (file)
@@ -2157,7 +2157,7 @@ void winnt_rewrite_args(process_rec *process)
          * without a drive letter.  Change to the default root
          * (path to apache root, above /bin) for safety.
          */
-        SetCurrentDirectory(def_server_root);
+        apr_filepath_set(def_server_root, process->pool);
         
         /* Any other process has a console, so we don't to begin
          * a Win9x service until the configuration is parsed and
index 24e146109f307a5f513044141776b8cf50925aab..65122a95bf4d3fd04effdd297e686fd7374b4167 100644 (file)
@@ -63,6 +63,7 @@
 #include "mpm_winnt.h"
 #include "apr_strings.h"
 #include "apr_lib.h"
+#include "ap_regkey.h"
 
 static char  *display_name  = NULL;
 static HANDLE stderr_thread = NULL;
@@ -76,8 +77,12 @@ static DWORD WINAPI service_stderr_thread(LPVOID hPipe)
     char *errmsg = errbuf;
     const char *errarg[9];
     DWORD errres;
-    HKEY hk;
+    ap_regkey_t *regkey;
+    apr_status_t rv;
+    apr_pool_t *p;
     
+    apr_pool_sub_make(&p, NULL, NULL);
+
     errarg[0] = "The Apache service named";
     errarg[1] = display_name;
     errarg[2] = "reported the following error:\r\n>>>";
@@ -89,23 +94,26 @@ static DWORD WINAPI service_stderr_thread(LPVOID hPipe)
     errarg[8] = NULL;
 
     /* What are we going to do in here, bail on the user?  not. */
-    if (!RegCreateKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services"
-                      "\\EventLog\\Application\\Apache Service", &hk)) 
+    if ((rv = ap_regkey_open(&regkey, AP_REGKEY_LOCAL_MACHINE, 
+                             "SYSTEM\\CurrentControlSet\\Services\\"
+                             "EventLog\\Application\\Apache Service",
+                             APR_READ | APR_WRITE | APR_CREATE, p)) 
+            == APR_SUCCESS)
     {
-        /* The stock message file */
-        char *netmsgkey = "%SystemRoot%\\System32\\netmsg.dll";
         DWORD dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | 
                        EVENTLOG_INFORMATION_TYPE; 
  
-        RegSetValueEx(hk, "EventMessageFile", 0, REG_EXPAND_SZ,
-                          (LPBYTE) netmsgkey, strlen(netmsgkey) + 1);
+        /* The stock message file */
+        ap_regkey_value_set(regkey, "EventMessageFile", 
+                            "%SystemRoot%\\System32\\netmsg.dll", 
+                            AP_REGKEY_EXPAND, p);
         
-        RegSetValueEx(hk, "TypesSupported", 0, REG_DWORD,
-                          (LPBYTE) &dwData, sizeof(dwData));
-        RegCloseKey(hk);
+        ap_regkey_value_raw_set(regkey, "TypesSupported", &dwData, 
+                                sizeof(dwData), REG_DWORD, p);
+        ap_regkey_close(regkey);
     }
 
-    hEventSource = RegisterEventSource(NULL, "Apache Service");
+    hEventSource = RegisterEventSourceW(NULL, L"Apache Service");
 
     SetEvent(stderr_ready);
 
@@ -145,6 +153,7 @@ static DWORD WINAPI service_stderr_thread(LPVOID hPipe)
     DeregisterEventSource(hEventSource);
     CloseHandle(stderr_thread);
     stderr_thread = NULL;
+    apr_pool_destroy(p);
     return 0;
 }
 
index 01ec697b16dc63c040e24bf3778a76f7ff3f1cb4..b0de8fc50c81e002c7b65db5fd8cc40dab24b0eb 100644 (file)
@@ -513,12 +513,12 @@ static void set_service_description(void)
                      "SYSTEM\\CurrentControlSet\\Services\\%s", 
                      mpm_service_name);
         rv = ap_regkey_open(&svckey, AP_REGKEY_LOCAL_MACHINE, szPath,
-                            APR_WRITE, pconf);
+                            APR_READ | APR_WRITE, pconf);
         if (rv != APR_SUCCESS) {
             return;
         }
         /* Attempt to set the Description value for our service */
-        ap_regkey_value_set(svckey, "Description", full_description, pconf);
+        ap_regkey_value_set(svckey, "Description", full_description, 0, pconf);
         ap_regkey_close(svckey);
     }
 }
@@ -933,9 +933,10 @@ apr_status_t mpm_service_install(apr_pool_t *ptemp, int argc,
         launch_cmd = apr_psprintf(ptemp, "\"%s\" -n %s -k runservice", 
                                  exe_path, mpm_service_name);
         rv = ap_regkey_open(&key, AP_REGKEY_LOCAL_MACHINE, SERVICECONFIG9X, 
-                            APR_READ, pconf);
+                            APR_READ | APR_WRITE | APR_CREATE, pconf);
         if (rv == APR_SUCCESS) {
-            rv = ap_regkey_value_set(key, mpm_service_name, launch_cmd, pconf);
+            rv = ap_regkey_value_set(key, mpm_service_name, 
+                                     launch_cmd, 0, pconf);
             ap_regkey_close(key);
         }
         if (rv != APR_SUCCESS) {
@@ -947,14 +948,14 @@ apr_status_t mpm_service_install(apr_pool_t *ptemp, int argc,
 
         apr_snprintf(key_name, sizeof(key_name), SERVICECONFIG, mpm_service_name);
         rv = ap_regkey_open(&key, AP_REGKEY_LOCAL_MACHINE, key_name, 
-                            APR_READ, pconf);
+                            APR_READ | APR_WRITE | APR_CREATE, 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);
+        rv = ap_regkey_value_set(key, "ImagePath", launch_cmd, 0, pconf);
         if (rv != APR_SUCCESS) {
             ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL, 
                          "%s: Failed to store ImagePath in the registry.", 
@@ -962,7 +963,8 @@ apr_status_t mpm_service_install(apr_pool_t *ptemp, int argc,
             ap_regkey_close(key);
             return (rv);
         }
-        rv = ap_regkey_value_set(key, "DisplayName", mpm_display_name, pconf);
+        rv = ap_regkey_value_set(key, "DisplayName", 
+                                 mpm_display_name, 0, pconf);
         ap_regkey_close(key);
         if (rv != APR_SUCCESS) {
             ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL, 
@@ -978,7 +980,7 @@ apr_status_t mpm_service_install(apr_pool_t *ptemp, int argc,
      */
     apr_snprintf(key_name, sizeof(key_name), SERVICEPARAMS, mpm_service_name);
     rv = ap_regkey_open(&key, AP_REGKEY_LOCAL_MACHINE, key_name, 
-                        APR_READ, pconf);
+                        APR_READ | APR_WRITE | APR_CREATE, pconf);
     if (rv == APR_SUCCESS) {
         rv = ap_regkey_value_array_set(key, "ConfigArgs", argc, argv, pconf);
         ap_regkey_close(key);
@@ -1055,7 +1057,7 @@ apr_status_t mpm_service_uninstall(void)
         /* TODO: assure the service is stopped before continuing */
 
         rv = ap_regkey_open(&key, AP_REGKEY_LOCAL_MACHINE, SERVICECONFIG9X, 
-                            APR_WRITE, pconf);
+                            APR_READ | APR_WRITE | APR_CREATE, pconf);
         if (rv == APR_SUCCESS) {
             rv = ap_regkey_value_remove(key, mpm_service_name, pconf);
             ap_regkey_close(key);