From: William A. Rowe Jr Date: Fri, 27 Jul 2001 03:48:11 +0000 (+0000) Subject: Something useful. Update the server description string. X-Git-Tag: 2.0.22~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5812f6c62af458bbd02de200792381b39432ae62;p=thirdparty%2Fapache%2Fhttpd.git Something useful. Update the server description string. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89744 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/mpm/winnt/service.c b/server/mpm/winnt/service.c index 523bf92970b..38c0fa83c25 100644 --- a/server/mpm/winnt/service.c +++ b/server/mpm/winnt/service.c @@ -406,6 +406,77 @@ static int ReportStatusToSCMgr(int currentState, int exitCode, int waitHint) return(rv); } +/* Set the service description regardless of platform. + * We revert to set_service_description on NT/9x, the + * very long way so any Apache management program can grab the + * description. This would be bad on Win2000, since it wouldn't + * notify the service control manager of the name change. + */ + +/* ChangeServiceConfig2() prototype: + */ +typedef WINADVAPI BOOL (WINAPI *CSD_T)(SC_HANDLE, DWORD, LPCVOID); + +/* 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. + */ +static void set_service_description(void) +{ + const char *full_description; + SC_HANDLE schSCManager; + CSD_T ChangeServiceDescription = NULL; + HANDLE hwin2000scm; + BOOL ret = 0; + + /* Nothing to do if we are a console + */ + if (!mpm_service_name) + return; + + /* Time to fix up the description, upon each successful restart + */ + full_description = ap_get_server_version(); + + if ((osver.dwPlatformId == VER_PLATFORM_WIN32_NT) + && (hwin2000scm = GetModuleHandle("ADVAPI32.DLL")) + && (ChangeServiceDescription = (CSD_T) GetProcAddress(hwin2000scm, + "ChangeServiceConfig2A")) + && (schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS))) + { + SC_HANDLE schService = OpenService(schSCManager, mpm_service_name, + SERVICE_ALL_ACCESS); + if (schService) { + if (ChangeServiceDescription(schService, + SERVICE_CONFIG_DESCRIPTION, + &full_description)) + full_description = NULL; + CloseServiceHandle(schService); + } + CloseServiceHandle(schSCManager); + } + + if (full_description) + { + char szPath[MAX_PATH]; + HKEY hkey; + + /* Create/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) { + 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); + } +} /* handle the SCM's ControlService() callbacks to our service */ @@ -793,6 +864,7 @@ apr_status_t mpm_service_to_start(const char **display_name) apr_status_t mpm_service_started(void) { + set_service_description(); if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT) { ReportStatusToSCMgr(SERVICE_RUNNING, // service state @@ -901,6 +973,8 @@ apr_status_t mpm_service_install(apr_pool_t *ptemp, int argc, } } + set_service_description(); + /* For both WinNT & Win9x store the service ConfigArgs in the registry... */ apr_snprintf(key_name, sizeof(key_name), SERVICEPARAMS, mpm_service_name);