[Box Backup-commit] COMMIT r1856 - box/chris/general/bin/bbackupd
boxbackup-dev at fluffy.co.uk
boxbackup-dev at fluffy.co.uk
Sun Sep 23 10:18:20 BST 2007
Author: chris
Date: 2007-09-23 10:18:20 +0100 (Sun, 23 Sep 2007)
New Revision: 1856
Modified:
box/chris/general/bin/bbackupd/BackupDaemon.cpp
box/chris/general/bin/bbackupd/Win32ServiceFunctions.cpp
box/chris/general/bin/bbackupd/Win32ServiceFunctions.h
Log:
Use the specified service name when installing and removing the service.
Pass the service name on the service command line, and use it for event
log messages.
Modified: box/chris/general/bin/bbackupd/BackupDaemon.cpp
===================================================================
--- box/chris/general/bin/bbackupd/BackupDaemon.cpp 2007-09-21 23:52:08 UTC (rev 1855)
+++ box/chris/general/bin/bbackupd/BackupDaemon.cpp 2007-09-23 09:18:20 UTC (rev 1856)
@@ -128,7 +128,8 @@
#ifdef WIN32
, mInstallService(false),
mRemoveService(false),
- mRunAsService(false)
+ mRunAsService(false),
+ mServiceName("bbackupd")
#endif
{
// Only ever one instance of a daemon
@@ -347,14 +348,16 @@
{
if (mInstallService)
{
- return InstallService(rConfigFileName.c_str());
+ return InstallService(rConfigFileName.c_str(), mServiceName);
}
if (mRemoveService)
{
- return RemoveService();
+ return RemoveService(mServiceName);
}
+ Logging::SetProgramName("Box Backup (" + mServiceName + ")");
+
int returnCode;
if (mRunAsService)
Modified: box/chris/general/bin/bbackupd/Win32ServiceFunctions.cpp
===================================================================
--- box/chris/general/bin/bbackupd/Win32ServiceFunctions.cpp 2007-09-21 23:52:08 UTC (rev 1855)
+++ box/chris/general/bin/bbackupd/Win32ServiceFunctions.cpp 2007-09-23 09:18:20 UTC (rev 1856)
@@ -199,7 +199,7 @@
return 0;
}
-int InstallService(const char* pConfigFileName)
+int InstallService(const char* pConfigFileName, const std::string& rServiceName)
{
if (pConfigFileName != NULL)
{
@@ -235,7 +235,7 @@
cmd[sizeof(cmd)-1] = 0;
std::string cmdWithArgs(cmd);
- cmdWithArgs += " -s";
+ cmdWithArgs += " -s -S \"" + rServiceName + "\"";
if (pConfigFileName != NULL)
{
@@ -244,10 +244,12 @@
cmdWithArgs += "\"";
}
+ std::string serviceDesc = "Box Backup (" + rServiceName + ")";
+
SC_HANDLE newService = CreateService(
scm,
- SERVICE_NAME,
- "Box Backup",
+ rServiceName.c_str(),
+ serviceDesc.c_str(),
SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START,
@@ -312,7 +314,7 @@
return 0;
}
-int RemoveService(void)
+int RemoveService(const std::string& rServiceName)
{
SC_HANDLE scm = OpenSCManager(0,0,SC_MANAGER_CREATE_SERVICE);
@@ -323,7 +325,7 @@
return 1;
}
- SC_HANDLE service = OpenService(scm, SERVICE_NAME,
+ SC_HANDLE service = OpenService(scm, rServiceName.c_str(),
SERVICE_ALL_ACCESS|DELETE);
DWORD err = GetLastError();
CloseServiceHandle(scm);
Modified: box/chris/general/bin/bbackupd/Win32ServiceFunctions.h
===================================================================
--- box/chris/general/bin/bbackupd/Win32ServiceFunctions.h 2007-09-21 23:52:08 UTC (rev 1855)
+++ box/chris/general/bin/bbackupd/Win32ServiceFunctions.h 2007-09-23 09:18:20 UTC (rev 1856)
@@ -12,8 +12,8 @@
#ifndef WIN32SERVICEFUNCTIONS_H
#define WIN32SERVICEFUNCTIONS_H
-int RemoveService (void);
-int InstallService (const char* pConfigFilePath);
+int RemoveService (const std::string& rServiceName);
+int InstallService (const char* pConfigFilePath, const std::string& rServiceName);
int OurService (const char* pConfigFileName);
#endif
More information about the Boxbackup-commit
mailing list