]> granicus.if.org Git - apache/commitdiff
Port the -k config option to Apache 2.0. This allows users to reconfigure
authorRyan Bloom <rbb@apache.org>
Fri, 22 Mar 2002 01:28:01 +0000 (01:28 +0000)
committerRyan Bloom <rbb@apache.org>
Fri, 22 Mar 2002 01:28:01 +0000 (01:28 +0000)
their service after it has been installed.

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

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

index 0f54e2c46b1ba8183aaf7ad3f828427638637d62..cf8f8af3655d63eb0d85f08b4f809eafe4a0979e 100644 (file)
@@ -2213,6 +2213,7 @@ static int winnt_post_config(apr_pool_t *pconf_, apr_pool_t *plog, apr_pool_t *p
     /* Handle the following SCM aspects in this phase:
      *
      *   -k install
+     *   -k config
      *   -k start
      *   -k restart
      *   -k runservice [Win95, only once - after we parsed the config]
@@ -2225,7 +2226,11 @@ static int winnt_post_config(apr_pool_t *pconf_, apr_pool_t *plog, apr_pool_t *p
      */
 
     if (!strcasecmp(signal_arg, "install")) {
-        rv = mpm_service_install(ptemp, inst_argc, inst_argv);
+        rv = mpm_service_install(ptemp, inst_argc, inst_argv, 0);
+        exit (rv);
+    }
+    if (!strcasecmp(signal_arg, "config")) {
+        rv = mpm_service_install(ptemp, inst_argc, inst_argv, 1);
         exit (rv);
     }
 
index 9fc45abc012e9b62b3c6e5be4688beafd001157e..26397db7ad3bfd0e0f276762fef4f5446143b472 100644 (file)
@@ -99,7 +99,7 @@ apr_status_t mpm_merge_service_args(apr_pool_t *p, apr_array_header_t *args,
 apr_status_t mpm_service_to_start(const char **display_name, apr_pool_t *p);
 apr_status_t mpm_service_started(void);
 apr_status_t mpm_service_install(apr_pool_t *ptemp, int argc, 
-                                char const* const* argv);
+                                char const* const* argv, int reconfig);
 apr_status_t mpm_service_uninstall(void);
 
 apr_status_t mpm_service_start(apr_pool_t *ptemp, int argc, 
index 0e6ca2947a8db4076c5a8193c7b3a9e86fb76118..0981d6ad05ce57663f27e4f58110227f3a89f9db 100644 (file)
@@ -775,14 +775,15 @@ void mpm_service_stopping(void)
 
 
 apr_status_t mpm_service_install(apr_pool_t *ptemp, int argc, 
-                                 const char * const * argv)
+                                 const char * const * argv, int reconfig)
 {
     char key_name[MAX_PATH];
     char exe_path[MAX_PATH];
     char *launch_cmd;
     apr_status_t(rv);
     
-    fprintf(stderr,"Installing the %s service\n", mpm_display_name);
+    fprintf(stderr,reconfig ? "Reconfiguring the %s service\n"
+                  : "Installing the %s service\n", mpm_display_name);
 
     if (GetModuleFileName(NULL, exe_path, sizeof(exe_path)) == 0)
     {
@@ -809,12 +810,37 @@ apr_status_t mpm_service_install(apr_pool_t *ptemp, int argc,
 
         launch_cmd = apr_psprintf(ptemp, "\"%s\" -k runservice", exe_path);
 
-        /* RPCSS is the Remote Procedure Call (RPC) Locator required for DCOM 
-         * communication pipes.  I am far from convinced we should add this to
-         * the default service dependencies, but be warned that future apache 
-         * modules or ISAPI dll's may depend on it.
-         */
-        schService = CreateService(schSCManager,         // SCManager database
+        if (reconfig) {
+            schService = OpenService(schSCManager, mpm_service_name, 
+                                     SERVICE_ALL_ACCESS);
+            if (!schService) {
+                ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_ERR, 
+                             apr_get_os_error(), NULL,
+                             "OpenService failed");
+            }
+            else if (!ChangeServiceConfig(schService, 
+                                          SERVICE_WIN32_OWN_PROCESS,
+                                          SERVICE_AUTO_START,
+                                          SERVICE_ERROR_NORMAL,
+                                          launch_cmd, NULL, NULL, 
+                                          "Tcpip\0Afd\0", NULL, NULL,
+                                          mpm_display_name)) {
+                ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_ERR, 
+                             apr_get_os_error(), NULL,
+                             "ChangeServiceConfig failed");
+               /* !schService aborts configuration below */
+               CloseServiceHandle(schService);
+               schService = NULL;
+           }
+        }
+        else {
+            /* RPCSS is the Remote Procedure Call (RPC) Locator required 
+             * for DCOM communication pipes.  I am far from convinced we 
+             * should add this to the default service dependencies, but 
+             * be warned that future apache modules or ISAPI dll's may 
+             * depend on it.
+             */
+            schService = CreateService(schSCManager,         // SCManager database
                                    mpm_service_name,     // name of service
                                    mpm_display_name,     // name to display
                                    SERVICE_ALL_ACCESS,   // access required
@@ -828,15 +854,16 @@ apr_status_t mpm_service_install(apr_pool_t *ptemp, int argc,
                                    NULL,                 // use SYSTEM account
                                    NULL);                // no password
 
-        if (!schService) 
-        {
-            rv = apr_get_os_error();
-            ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL, 
-                         "Failed to create WinNT Service Profile");
-            CloseServiceHandle(schSCManager);
-            return (rv);
+            if (!schService) 
+            {
+                rv = apr_get_os_error();
+                ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL, 
+                             "Failed to create WinNT Service Profile");
+                CloseServiceHandle(schSCManager);
+                return (rv);
+            }
         }
-
+       
         CloseServiceHandle(schService);
         CloseServiceHandle(schSCManager);
     }