From: Howard Chu Date: Mon, 3 Mar 2003 06:42:16 +0000 (+0000) Subject: Add explicit "service" argument, only change cwd if running as a service. X-Git-Tag: NO_SLAP_OP_BLOCKS~210 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d9dbbeb87f7d40d8236602568aceaba58c9952ee;p=openldap Add explicit "service" argument, only change cwd if running as a service. --- diff --git a/servers/slapd/nt_svc.c b/servers/slapd/nt_svc.c index 6eaa84e881..6a003567e1 100644 --- a/servers/slapd/nt_svc.c +++ b/servers/slapd/nt_svc.c @@ -47,8 +47,6 @@ int main( int argc, LPTSTR *argv ) */ GetModuleFileName( NULL, filename, sizeof( filename ) ); fname_start = strrchr( filename, *LDAP_DIRSEP ); - *fname_start = '\0'; - SetCurrentDirectory( filename ); if ( argc > 1 ) { if ( _stricmp( "install", argv[1] ) == 0 ) @@ -66,11 +64,7 @@ int main( int argc, LPTSTR *argv ) if ( argc > 4 && stricmp(argv[4], "auto") == 0) auto_start = TRUE; - if ( (length = GetModuleFileName(NULL, filename, sizeof( filename ))) == 0 ) - { - fputs( "unable to retrieve file name for the service.\n", stderr ); - return EXIT_FAILURE; - } + strcat(filename, " service"); if ( !srv_install(svcName, displayName, filename, auto_start) ) { fputs( "service failed installation ...\n", stderr ); @@ -85,11 +79,6 @@ int main( int argc, LPTSTR *argv ) char *svcName = SERVICE_NAME; if ( (argc > 2) && (argv[2] != NULL) ) svcName = argv[2]; - if ( (length = GetModuleFileName(NULL, filename, sizeof( filename ))) == 0 ) - { - fputs( "unable to retrieve file name for the service.\n", stderr ); - return EXIT_FAILURE; - } if ( !srv_remove(svcName, filename) ) { fputs( "failed to remove the service ...\n", stderr ); @@ -98,14 +87,19 @@ int main( int argc, LPTSTR *argv ) fputs( "service has been removed ...\n", stderr ); return EXIT_SUCCESS; } + if ( _stricmp( "service", argv[1] ) == 0 ) + { + is_NT_Service = 1; + *fname_start = '\0'; + SetCurrentDirectory( filename ); + } } - puts( "starting slapd..." ); - if (svc_installed(SERVICE_NAME, NULL) != 0 - || svc_running(SERVICE_NAME) == 1 - || StartServiceCtrlDispatcher(DispatchTable) == 0 ) + if (is_NT_Service) + { + StartServiceCtrlDispatcher(DispatchTable); + } else { - is_NT_Service = 0; ServiceMain( argc, argv ); }