[Box Backup-commit] COMMIT r3582 - in box/trunk: bin/bbackupd lib/backupclient lib/server

subversion at boxbackup.org subversion at boxbackup.org
Sun Jun 28 20:36:37 BST 2015


Author: chris
Date: 2015-06-28 19:36:37 +0000 (Sun, 28 Jun 2015)
New Revision: 3582

Added:
   box/trunk/lib/backupclient/ClientException.txt
   box/trunk/lib/backupclient/Makefile.extra
Removed:
   box/trunk/bin/bbackupd/ClientException.txt
   box/trunk/bin/bbackupd/Makefile.extra
Modified:
   box/trunk/bin/bbackupd/BackupDaemon.cpp
   box/trunk/bin/bbackupd/BackupDaemon.h
   box/trunk/lib/backupclient/BackupDaemonConfigVerify.cpp
   box/trunk/lib/server/Daemon.cpp
Log:
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.)

Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp
===================================================================
--- box/trunk/bin/bbackupd/BackupDaemon.cpp	2015-06-10 19:46:22 UTC (rev 3581)
+++ box/trunk/bin/bbackupd/BackupDaemon.cpp	2015-06-28 19:36:37 UTC (rev 3582)
@@ -321,7 +321,6 @@
 	return &BackupDaemonConfigVerify;
 }
 
-#ifdef PLATFORM_CANNOT_FIND_PEER_UID_OF_UNIX_SOCKET
 // --------------------------------------------------------------------------
 //
 // Function
@@ -334,6 +333,36 @@
 // --------------------------------------------------------------------------
 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 @@
 			"==============================================================================\n"
 			);
 	}
+#endif
 }
-#endif
 
 
 // --------------------------------------------------------------------------

Modified: box/trunk/bin/bbackupd/BackupDaemon.h
===================================================================
--- box/trunk/bin/bbackupd/BackupDaemon.h	2015-06-10 19:46:22 UTC (rev 3581)
+++ box/trunk/bin/bbackupd/BackupDaemon.h	2015-06-28 19:36:37 UTC (rev 3582)
@@ -187,10 +187,8 @@
 	
 	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();
 

Deleted: box/trunk/bin/bbackupd/ClientException.txt
===================================================================
--- box/trunk/bin/bbackupd/ClientException.txt	2015-06-10 19:46:22 UTC (rev 3581)
+++ box/trunk/bin/bbackupd/ClientException.txt	2015-06-28 19:36:37 UTC (rev 3582)
@@ -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.

Deleted: box/trunk/bin/bbackupd/Makefile.extra
===================================================================
--- box/trunk/bin/bbackupd/Makefile.extra	2015-06-10 19:46:22 UTC (rev 3581)
+++ box/trunk/bin/bbackupd/Makefile.extra	2015-06-28 19:36:37 UTC (rev 3582)
@@ -1,7 +0,0 @@
-
-MAKEEXCEPTION = ../../lib/common/makeexception.pl
-
-# AUTOGEN SEEDING
-autogen_ClientException.h autogen_ClientException.cpp:	$(MAKEEXCEPTION) ClientException.txt
-	$(_PERL) $(MAKEEXCEPTION) ClientException.txt
-

Modified: box/trunk/lib/backupclient/BackupDaemonConfigVerify.cpp
===================================================================
--- box/trunk/lib/backupclient/BackupDaemonConfigVerify.cpp	2015-06-10 19:46:22 UTC (rev 3581)
+++ box/trunk/lib/backupclient/BackupDaemonConfigVerify.cpp	2015-06-28 19:36:37 UTC (rev 3582)
@@ -16,7 +16,7 @@
 #include "MemLeakFindOn.h"
 
 
-static const ConfigurationVerifyKey backuplocationkeys[] = 
+static const ConfigurationVerifyKey backuplocationkeys[] =
 {
 	ConfigurationVerifyKey("ExcludeFile", ConfigTest_MultiValueAllowed),
 	ConfigurationVerifyKey("ExcludeFilesRegex", ConfigTest_MultiValueAllowed),
@@ -29,7 +29,7 @@
 	ConfigurationVerifyKey("Path", ConfigTest_Exists | ConfigTest_LastEntry)
 };
 
-static const ConfigurationVerify backuplocations[] = 
+static const ConfigurationVerify backuplocations[] =
 {
 	{
 		"*",
@@ -40,7 +40,7 @@
 	}
 };
 
-static const ConfigurationVerifyKey verifyserverkeys[] = 
+static const ConfigurationVerifyKey verifyserverkeys[] =
 {
 	DAEMON_VERIFY_SERVER_KEYS
 };
@@ -63,7 +63,7 @@
 	}
 };
 
-static const ConfigurationVerifyKey verifyrootkeys[] = 
+static const ConfigurationVerifyKey verifyrootkeys[] =
 {
 	ConfigurationVerifyKey("AccountNumber",
 		ConfigTest_Exists | ConfigTest_IsUint32),
@@ -92,9 +92,6 @@
 		ConfigTest_Exists | ConfigTest_IsInt),
 	ConfigurationVerifyKey("DiffingUploadSizeThreshold",
 		ConfigTest_Exists | ConfigTest_IsInt),
-	ConfigurationVerifyKey("StoreHostname", ConfigTest_Exists),
-	ConfigurationVerifyKey("StorePort", ConfigTest_IsInt,
-		BOX_PORT_BBSTORED),
 	ConfigurationVerifyKey("ExtendedLogging", ConfigTest_IsBool, false),
 	// extended log to syslog
 	ConfigurationVerifyKey("ExtendedLogFile", 0),
@@ -125,13 +122,16 @@
 	ConfigurationVerifyKey("TcpNice", ConfigTest_IsBool, false),
 	// optional enable of tcp nice/background mode
 
-	ConfigurationVerifyKey("CertificateFile", ConfigTest_Exists),
-	ConfigurationVerifyKey("PrivateKeyFile", ConfigTest_Exists),
-	ConfigurationVerifyKey("TrustedCAsFile", ConfigTest_Exists),
 	ConfigurationVerifyKey("KeysFile", ConfigTest_Exists),
-	ConfigurationVerifyKey("DataDirectory", 
-		ConfigTest_Exists | ConfigTest_LastEntry),
+	ConfigurationVerifyKey("DataDirectory", ConfigTest_Exists),
 
+	// These values are only required for bbstored stores:
+	ConfigurationVerifyKey("StoreHostname", 0),
+	ConfigurationVerifyKey("StorePort", ConfigTest_IsInt,
+		BOX_PORT_BBSTORED),
+	ConfigurationVerifyKey("CertificateFile", 0),
+	ConfigurationVerifyKey("PrivateKeyFile", 0),
+	ConfigurationVerifyKey("TrustedCAsFile", ConfigTest_LastEntry),
 };
 
 const ConfigurationVerify BackupDaemonConfigVerify =

Copied: box/trunk/lib/backupclient/ClientException.txt (from rev 3581, box/trunk/bin/bbackupd/ClientException.txt)
===================================================================
--- box/trunk/lib/backupclient/ClientException.txt	                        (rev 0)
+++ box/trunk/lib/backupclient/ClientException.txt	2015-06-28 19:36:37 UTC (rev 3582)
@@ -0,0 +1,12 @@
+
+# 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.
+InvalidConfiguration			5	Some required values are missing or incorrect in the configuration file.

Copied: box/trunk/lib/backupclient/Makefile.extra (from rev 3581, box/trunk/bin/bbackupd/Makefile.extra)
===================================================================
--- box/trunk/lib/backupclient/Makefile.extra	                        (rev 0)
+++ box/trunk/lib/backupclient/Makefile.extra	2015-06-28 19:36:37 UTC (rev 3582)
@@ -0,0 +1,7 @@
+
+MAKEEXCEPTION = ../../lib/common/makeexception.pl
+
+# AUTOGEN SEEDING
+autogen_ClientException.h autogen_ClientException.cpp:	$(MAKEEXCEPTION) ClientException.txt
+	$(_PERL) $(MAKEEXCEPTION) ClientException.txt
+

Modified: box/trunk/lib/server/Daemon.cpp
===================================================================
--- box/trunk/lib/server/Daemon.cpp	2015-06-10 19:46:22 UTC (rev 3581)
+++ box/trunk/lib/server/Daemon.cpp	2015-06-28 19:36:37 UTC (rev 3582)
@@ -376,17 +376,17 @@
 		BOX_ERROR("Failed to load or verify configuration file");
 		return false;
 	}
-	
+
 	if(!Configure(*apConfig))
 	{
 		BOX_ERROR("Failed to verify configuration file");
-		return false;		
+		return false;
 	}
-	
+
 	// Store configuration
 	mConfigFileName = rConfigFileName;
 	mLoadedConfigModifiedTime = GetConfigFileModifiedTime();
-		
+
 	return true;
 }
 
@@ -416,14 +416,14 @@
 		BOX_ERROR("Configuration errors: " << errors);
 		return false;
 	}
-	
+
 	// Store configuration
 	mapConfiguration = apConf;
-	
+
 	// Let the derived class have a go at setting up stuff
 	// in the initial process
 	SetupInInitialProcess();
-		
+
 	return true;
 }
 




More information about the Boxbackup-commit mailing list