diff options
author | Chris Wilson <chris+github@qwirx.com> | 2015-06-28 19:36:37 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2015-06-28 19:36:37 +0000 |
commit | 0c41e85dbbaccf0ed07c0277d64d37f0af380be2 (patch) | |
tree | 828cde6ff3d3e62d734d1dd18fca2825ace6e50a /bin | |
parent | 66031e625d512b82a2d9d1546773b9fc0f8645bd (diff) |
Refactor to allow non-bbstored store configurations.
Make some keys not required in BackupDaemonConfigVerify, and verify them
afterwards instead, when the rest of the configuration file has been read
(and in future, the store type would be known.)
Diffstat (limited to 'bin')
-rw-r--r-- | bin/bbackupd/BackupDaemon.cpp | 33 | ||||
-rw-r--r-- | bin/bbackupd/BackupDaemon.h | 2 | ||||
-rw-r--r-- | bin/bbackupd/ClientException.txt | 11 | ||||
-rw-r--r-- | bin/bbackupd/Makefile.extra | 7 |
4 files changed, 31 insertions, 22 deletions
diff --git a/bin/bbackupd/BackupDaemon.cpp b/bin/bbackupd/BackupDaemon.cpp index edd059af..fa55cdad 100644 --- a/bin/bbackupd/BackupDaemon.cpp +++ b/bin/bbackupd/BackupDaemon.cpp @@ -321,7 +321,6 @@ const ConfigurationVerify *BackupDaemon::GetConfigVerify() const return &BackupDaemonConfigVerify; } -#ifdef PLATFORM_CANNOT_FIND_PEER_UID_OF_UNIX_SOCKET // -------------------------------------------------------------------------- // // Function @@ -334,6 +333,36 @@ const ConfigurationVerify *BackupDaemon::GetConfigVerify() const // -------------------------------------------------------------------------- void BackupDaemon::SetupInInitialProcess() { + const Configuration& config(GetConfiguration()); + + // These keys may or may not be required, depending on the configured + // store type (e.g. not when using Amazon S3 stores), so they can't be + // verified by BackupDaemonConfigVerify. + std::vector<std::string> requiredKeys; + requiredKeys.push_back("StoreHostname"); + requiredKeys.push_back("CertificateFile"); + requiredKeys.push_back("PrivateKeyFile"); + requiredKeys.push_back("TrustedCAsFile"); + bool missingRequiredKeys = false; + + for(std::vector<std::string>::const_iterator i = requiredKeys.begin(); + i != requiredKeys.end(); i++) + { + if(!config.KeyExists(*i)) + { + BOX_ERROR("Missing required configuration key: " << *i); + missingRequiredKeys = true; + } + } + + if(missingRequiredKeys) + { + THROW_EXCEPTION_MESSAGE(ClientException, InvalidConfiguration, + "Some required configuration keys are missing in " << + GetConfigFileName()); + } + +#ifdef PLATFORM_CANNOT_FIND_PEER_UID_OF_UNIX_SOCKET // Print a warning on this platform if the CommandSocket is used. if(GetConfiguration().KeyExists("CommandSocket")) { @@ -346,8 +375,8 @@ void BackupDaemon::SetupInInitialProcess() "==============================================================================\n" ); } -} #endif +} // -------------------------------------------------------------------------- diff --git a/bin/bbackupd/BackupDaemon.h b/bin/bbackupd/BackupDaemon.h index ba46dec2..ffe31247 100644 --- a/bin/bbackupd/BackupDaemon.h +++ b/bin/bbackupd/BackupDaemon.h @@ -187,10 +187,8 @@ private: void DeleteUnusedRootDirEntries(BackupClientContext &rContext); -#ifdef PLATFORM_CANNOT_FIND_PEER_UID_OF_UNIX_SOCKET // For warning user about potential security hole virtual void SetupInInitialProcess(); -#endif int UseScriptToSeeIfSyncAllowed(); diff --git a/bin/bbackupd/ClientException.txt b/bin/bbackupd/ClientException.txt deleted file mode 100644 index 04f88620..00000000 --- a/bin/bbackupd/ClientException.txt +++ /dev/null @@ -1,11 +0,0 @@ - -# NOTE: Exception descriptions are for public distributions of Box Backup only -- do not rely for other applications. - - -EXCEPTION Client 13 - -Internal 0 -AssertFailed 1 -ClockWentBackwards 2 Invalid (negative) sync period: perhaps your clock is going backwards? -FailedToDeleteStoreObjectInfoFile 3 Failed to delete the StoreObjectInfoFile, backup cannot continue safely. -CorruptStoreObjectInfoFile 4 The store object info file contained an invalid value and is probably corrupt. Try deleting it. diff --git a/bin/bbackupd/Makefile.extra b/bin/bbackupd/Makefile.extra deleted file mode 100644 index 25ceb1e7..00000000 --- a/bin/bbackupd/Makefile.extra +++ /dev/null @@ -1,7 +0,0 @@ - -MAKEEXCEPTION = ../../lib/common/makeexception.pl - -# AUTOGEN SEEDING -autogen_ClientException.h autogen_ClientException.cpp: $(MAKEEXCEPTION) ClientException.txt - $(_PERL) $(MAKEEXCEPTION) ClientException.txt - |