diff options
author | yaworsky <yaworsky> | 2005-12-02 09:09:37 +0000 |
---|---|---|
committer | yaworsky <yaworsky> | 2005-12-02 09:09:37 +0000 |
commit | e459f29dff80f46b7a725e77bb82d9f4df186868 (patch) | |
tree | e9ec560da839a4d500ec98a5b5fc174e34ec8fae /daemon/main.c | |
parent | 26439bd634d99da300bef9e1df100cfd3d3cde50 (diff) | |
download | syslog-win32-e459f29dff80f46b7a725e77bb82d9f4df186868.tar.gz syslog-win32-e459f29dff80f46b7a725e77bb82d9f4df186868.tar.xz syslog-win32-e459f29dff80f46b7a725e77bb82d9f4df186868.zip |
Fixed winNT service control from command line.
Fixed service installation: added instance name.
Service name and event name is made more distinguished.
Diffstat (limited to 'daemon/main.c')
-rw-r--r-- | daemon/main.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/daemon/main.c b/daemon/main.c index 9b5aa29..1a691ab 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -35,15 +35,19 @@ struct string *line_feed; int verbosity_level = 0; -static char *service_name = "syslogd"; +static char *service_name = "syslogd-win32"; static char *service_display_name = "syslogd"; -static char *service_stop_event_name = "syslogd-stop"; +static char *service_stop_event_name = "syslogd-win32-stop"; static OSVERSIONINFO vi; static SERVICE_STATUS_HANDLE hss; static SERVICE_STATUS sstatus; +/* options */ +static char *instance_name = NULL; +static char *priority = NULL; + /****************************************************************************** * display message */ @@ -119,12 +123,23 @@ static void WINAPI ServiceControlHandler( DWORD Control ) */ static void WINAPI winnt_ServiceMain( DWORD Argc, LPTSTR* Argv ) { + char security_descriptor[ SECURITY_DESCRIPTOR_MIN_LENGTH ]; + SECURITY_ATTRIBUTES security_attributes; + + InitializeSecurityDescriptor( (PSECURITY_DESCRIPTOR) security_descriptor, + SECURITY_DESCRIPTOR_REVISION ); + SetSecurityDescriptorDacl( (PSECURITY_DESCRIPTOR) security_descriptor, + TRUE, (PACL) NULL, FALSE ); + security_attributes.nLength = sizeof(SECURITY_ATTRIBUTES); + security_attributes.lpSecurityDescriptor = (PSECURITY_DESCRIPTOR) security_descriptor; + security_attributes.bInheritHandle = FALSE; + hss = RegisterServiceCtrlHandler( PACKAGE_NAME, (LPHANDLER_FUNCTION)ServiceControlHandler ); if( !hss ) return; - service_stop_event = CreateEvent( NULL, TRUE, FALSE, NULL ); + service_stop_event = CreateEvent( &security_attributes, TRUE, FALSE, service_stop_event_name ); if( !service_stop_event ) return; @@ -337,10 +352,10 @@ static BOOL winnt_InstallService( char* command_line ) return ret; } -static BOOL install_service( char* priority ) +static BOOL install_service() { BOOL ret; - char command_line[ MAX_PATH + 64 ]; + char command_line[ MAX_PATH ]; TRACE_ENTER( "\n" ); if( __argv[0][1] == ':' ) @@ -358,6 +373,11 @@ static BOOL install_service( char* priority ) strcat( command_line, " --priority " ); strcat( command_line, priority ); } + if( instance_name ) + { + strcat( command_line, " --instance " ); + strcat( command_line, instance_name ); + } if( VER_PLATFORM_WIN32_NT == vi.dwPlatformId ) ret = winnt_InstallService( command_line ); @@ -545,8 +565,6 @@ int main( int argc, char* argv[] ) static int start_flag = 0; static int shutdown_flag = 0; static int restart_flag = 0; - char *instance_name = NULL; - char *priority = NULL; int getopt_failure = 0; WSADATA wsd; char name_buf[ MAX_COMPUTERNAME_LENGTH + 1 ]; |