diff options
author | Ryan Bloom <rbb@apache.org> | 2002-03-22 02:28:01 +0100 |
---|---|---|
committer | Ryan Bloom <rbb@apache.org> | 2002-03-22 02:28:01 +0100 |
commit | ba4014adbad0c8dfb0395d7fe269834d5db8e98a (patch) | |
tree | 3248f66eb24d3d2df2c9b43f20a0d04ab588e9b6 /server/mpm/winnt/service.c | |
parent | remove some unnecessary, commented-out code; add a comment (diff) | |
download | apache2-ba4014adbad0c8dfb0395d7fe269834d5db8e98a.tar.xz apache2-ba4014adbad0c8dfb0395d7fe269834d5db8e98a.zip |
Port the -k config option to Apache 2.0. This allows users to reconfigure
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
Diffstat (limited to 'server/mpm/winnt/service.c')
-rw-r--r-- | server/mpm/winnt/service.c | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/server/mpm/winnt/service.c b/server/mpm/winnt/service.c index 0e6ca2947a..0981d6ad05 100644 --- a/server/mpm/winnt/service.c +++ b/server/mpm/winnt/service.c @@ -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); } |