#define _CRT_SECURE_NO_DEPRECATE 1\r
\r
#include <shibsp/base.h>\r
+#include <string>\r
#include <windows.h>\r
\r
+using namespace std;\r
+\r
extern bool shibd_shutdown; // signals shutdown to Unix side\r
extern const char* shar_schemadir;\r
extern const char* shar_config;\r
+extern const char* shar_prefix;\r
extern bool shar_checkonly;\r
\r
// internal variables\r
if (argc > ++i)\r
shar_config = argv[i++];\r
}\r
+ else if (_stricmp( "prefix", argv[i]+1) == 0)\r
+ {\r
+ if (argc > ++i)\r
+ shar_prefix = argv[i++];\r
+ }\r
else if (_stricmp( "catalogs", argv[i]+1) == 0)\r
{\r
if (argc > ++i)\r
printf("%s -remove <name> to remove the named service\n", argv[0]);\r
printf("%s -console to run as a console app for debugging\n", argv[0]);\r
printf("%s -check to run as a console app and check configuration\n", argv[0]);\r
+ printf("\t-prefix <dir> to specify the installation directory\n");\r
printf("\t-config <file> to specify the config file to use\n");\r
- printf("\t-catalogs <dir> to specify schema catalogs\n");\r
+ printf("\t-catalogs <catalog1:catalog2> to specify schema catalogs\n");\r
printf("\nService starting.\nThis may take several seconds. Please wait.\n" );\r
\r
SERVICE_TABLE_ENTRY dispatchTable[] =\r
SC_HANDLE schSCManager;\r
\r
char szPath[256];\r
- char dispName[512];\r
- char realName[512];\r
- char cmd[2048];\r
\r
if ( GetModuleFileName( NULL, szPath, 256 ) == 0 )\r
{\r
return;\r
}\r
\r
- sprintf(dispName,"Shibboleth %s Daemon (%s)",PACKAGE_VERSION,name);\r
- sprintf(realName,"shibd_%s",name);\r
- if (shar_config && shar_schemadir)\r
- sprintf(cmd,"%s -config %s -schemadir %s",szPath,shar_config,shar_schemadir);\r
- else if (shar_config)\r
- sprintf(cmd,"%s -config %s",szPath,shar_config);\r
- else if (shar_schemadir)\r
- sprintf(cmd,"%s -schemadir %s",szPath,shar_schemadir);\r
- else\r
- sprintf(cmd,"%s",szPath);\r
+ string dispName = string("Shibboleth ") + PACKAGE_VERSION + " Daemon (" + name + ")";\r
+ string realName = string("shibd_") + name;\r
+ string cmd(szPath);\r
+ if (shar_prefix)\r
+ cmd = cmd + " -prefix " + shar_prefix;\r
+ if (shar_config)\r
+ cmd = cmd + " -config " + shar_config;\r
+ if (shar_schemadir)\r
+ cmd = cmd + " -schemadir " + shar_schemadir;\r
\r
schSCManager = OpenSCManager(\r
NULL, // machine (NULL == local)\r
{\r
schService = CreateService(\r
schSCManager, // SCManager database\r
- realName, // name of service\r
- dispName, // name to display\r
+ realName.c_str(), // name of service\r
+ dispName.c_str(), // name to display\r
SERVICE_ALL_ACCESS, // desired access\r
SERVICE_WIN32_OWN_PROCESS, // service type\r
SERVICE_AUTO_START, // start type\r
SERVICE_ERROR_NORMAL, // error control type\r
- cmd, // service's command line\r
+ cmd.c_str(), // service's command line\r
NULL, // no load ordering group\r
NULL, // no tag identifier\r
NULL, // dependencies\r
\r
if ( schService )\r
{\r
- printf("%s installed.\n",realName);\r
+ printf("%s installed.\n", realName.c_str());\r
CloseServiceHandle(schService);\r
}\r
else\r
SC_HANDLE schSCManager;\r
char realName[512];\r
\r
- sprintf(realName,"shibd_%s",name);\r
+ _snprintf(realName,sizeof(realName),"shibd_%s",name);\r
\r
schSCManager = OpenSCManager(\r
NULL, // machine (NULL == local)\r