summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2009-11-26 21:44:22 +0000
committerChris Wilson <chris+github@qwirx.com>2009-11-26 21:44:22 +0000
commit10d164b5b9ad7e5978df57365f7835a031205d1a (patch)
tree772ad2f136ca45fe86bca080e6ffe9abf1ec8f14
parent8201a0aedbe7a1cf3cbcd333ee0c8da57fab5c59 (diff)
Add location of config file as an additional parameter to the
SyncAllowScript and the NotifyScript, thanks to Achim J. Latz.
-rw-r--r--bin/bbackupd/BackupDaemon.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/bin/bbackupd/BackupDaemon.cpp b/bin/bbackupd/BackupDaemon.cpp
index 3615b848..0e51c3e2 100644
--- a/bin/bbackupd/BackupDaemon.cpp
+++ b/bin/bbackupd/BackupDaemon.cpp
@@ -1021,8 +1021,11 @@ int BackupDaemon::UseScriptToSeeIfSyncAllowed()
pid_t pid = 0;
try
{
+ std::string script("\"" + conf.GetKeyValue("SyncAllowScript") +
+ "\" \"" + GetConfigFileName() + "\"");
+
std::auto_ptr<IOStream> pscript(LocalProcessStream(
- conf.GetKeyValue("SyncAllowScript").c_str(), pid));
+ script.c_str(), pid));
// Read in the result
IOStreamGetLine getLine(*pscript);
@@ -1044,17 +1047,16 @@ int BackupDaemon::UseScriptToSeeIfSyncAllowed()
}
catch(ConversionException &e)
{
- BOX_ERROR("Invalid output "
- "from SyncAllowScript '"
- << conf.GetKeyValue("SyncAllowScript")
- << "': '" << line << "'");
+ BOX_ERROR("Invalid output from "
+ "SyncAllowScript " <<
+ script << ": '" << line << "'");
throw;
}
BOX_NOTICE("Delaying sync by " << waitInSeconds
- << " seconds (SyncAllowScript '"
+ << " seconds (SyncAllowScript "
<< conf.GetKeyValue("SyncAllowScript")
- << "')");
+ << ")");
}
}
@@ -2193,20 +2195,19 @@ void BackupDaemon::NotifySysadmin(SysadminNotifier::EventCode Event)
}
// Script to run
- std::string script(conf.GetKeyValue("NotifyScript") + ' ' +
- sEventNames[Event]);
+ std::string script("\"" + conf.GetKeyValue("NotifyScript") + "\" " +
+ sEventNames[Event] + " \"" + GetConfigFileName() + "\"");
// Log what we're about to do
BOX_INFO("About to notify administrator about event "
- << sEventNames[Event] << ", running script '"
- << script << "'");
+ << sEventNames[Event] << ", running script " << script);
// Then do it
int returnCode = ::system(script.c_str());
if(returnCode != 0)
{
BOX_WARNING("Notify script returned error code: " <<
- returnCode << " ('" << script << "')");
+ returnCode << " (" << script << ")");
}
else if(Event != SysadminNotifier::BackupStart &&
Event != SysadminNotifier::BackupFinish)