Changeset 2116

Show
Ignore:
Timestamp:
28/03/2008 22:59:28 (2 years ago)
Author:
chris
Message:

Allow configuration of the server port that the client will connect to
(bbackupd and bbackupquery).

Redesign ConfigurationVerify? to use classes instead of structs.

Use port 22011 instead of 2201 during tests, to reduce the chances of
conflicting with a running bbstored or other process.

Ignore autogen_* in svn:ignore everywhere instead of individual per-file
ignores.

Location:
box/trunk
Files:
1 added
32 modified

Legend:

Unmodified
Added
Removed
  • box/trunk

    • Property svn:ignore
      •  

        old new  
        1111release 
        1212runtest.pl 
         13.hg 
  • box/trunk/bin/bbackupd

    • Property svn:ignore
      •  

        old new  
        11Makefile 
        22bbackupd-config 
         3autogen_* 
  • box/trunk/bin/bbackupd/BackupClientContext.cpp

    r2115 r2116  
    4545        TLSContext &rTLSContext,  
    4646        const std::string &rHostname, 
     47        int Port, 
    4748        int32_t AccountNumber,  
    4849        bool ExtendedLogging, 
     
    5354          mrTLSContext(rTLSContext), 
    5455          mHostname(rHostname), 
     56          mPort(Port), 
    5557          mAccountNumber(AccountNumber), 
    5658          mpSocket(0), 
     
    130132 
    131133                // Connect! 
    132                 mpSocket->Open(mrTLSContext, Socket::TypeINET, mHostname.c_str(), BOX_PORT_BBSTORED); 
     134                mpSocket->Open(mrTLSContext, Socket::TypeINET, 
     135                        mHostname.c_str(), mPort); 
    133136                 
    134137                // And create a procotol object 
  • box/trunk/bin/bbackupd/BackupClientContext.h

    r1191 r2116  
    4242                TLSContext &rTLSContext,  
    4343                const std::string &rHostname, 
     44                int32_t Port, 
    4445                int32_t AccountNumber,  
    4546                bool ExtendedLogging, 
     
    202203        TLSContext &mrTLSContext; 
    203204        std::string mHostname; 
     205        int mPort; 
    204206        int32_t mAccountNumber; 
    205207        SocketStreamTLS *mpSocket; 
  • box/trunk/bin/bbackupd/BackupDaemon.cpp

    r2115 r2116  
    959959                                        tlsContext,  
    960960                                        conf.GetKeyValue("StoreHostname"), 
     961                                        conf.GetKeyValueInt("StorePort"), 
    961962                                        conf.GetKeyValueInt("AccountNumber"),  
    962963                                        conf.GetKeyValueBool("ExtendedLogging"), 
  • box/trunk/bin/bbackupquery

    • Property svn:ignore
      •  

        old new  
        1 autogen_Documentation.cpp 
         1autogen_* 
        22Makefile 
        33makedocumentation.pl 
  • box/trunk/bin/bbackupquery/bbackupquery.cpp

    r2115 r2116  
    261261        if(!quiet) BOX_INFO("Connecting to store..."); 
    262262        SocketStreamTLS socket; 
    263         socket.Open(tlsContext, Socket::TypeINET, conf.GetKeyValue("StoreHostname").c_str(), BOX_PORT_BBSTORED); 
     263        socket.Open(tlsContext, Socket::TypeINET, 
     264                conf.GetKeyValue("StoreHostname").c_str(), 
     265                conf.GetKeyValueInt("StorePort")); 
    264266         
    265267        // 3. Make a protocol, and handshake 
  • box/trunk/bin/bbstored

    • Property svn:ignore
      •  

        old new  
        1 autogen_BackupProtocolServer.cpp 
        2 autogen_BackupProtocolServer.h 
         1autogen_* 
        32Makefile 
        43bbstored-certs 
  • box/trunk/infrastructure

    • Property svn:ignore
      •  

        old new  
        22makebuildenv.pl 
        33makeparcels.pl 
         4makedistribution.pl 
  • box/trunk/lib/backupclient

    • Property svn:ignore
      •  

        old new  
        1 autogen_BackupProtocolClient.cpp 
        2 autogen_BackupProtocolClient.h 
        3 autogen_BackupStoreException.cpp 
        4 autogen_BackupStoreException.h 
         1autogen_* 
        52Makefile 
  • box/trunk/lib/backupclient/BackupDaemonConfigVerify.cpp

    r1863 r2116  
    1818static const ConfigurationVerifyKey backuplocationkeys[] =  
    1919{ 
    20         {"ExcludeFile", 0, ConfigTest_MultiValueAllowed, 0}, 
    21         {"ExcludeFilesRegex", 0, ConfigTest_MultiValueAllowed, 0}, 
    22         {"ExcludeDir", 0, ConfigTest_MultiValueAllowed, 0}, 
    23         {"ExcludeDirsRegex", 0, ConfigTest_MultiValueAllowed, 0}, 
    24         {"AlwaysIncludeFile", 0, ConfigTest_MultiValueAllowed, 0}, 
    25         {"AlwaysIncludeFilesRegex", 0, ConfigTest_MultiValueAllowed, 0}, 
    26         {"AlwaysIncludeDir", 0, ConfigTest_MultiValueAllowed, 0}, 
    27         {"AlwaysIncludeDirsRegex", 0, ConfigTest_MultiValueAllowed, 0}, 
    28         {"Path", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0} 
     20        ConfigurationVerifyKey("ExcludeFile", ConfigTest_MultiValueAllowed), 
     21        ConfigurationVerifyKey("ExcludeFilesRegex", ConfigTest_MultiValueAllowed), 
     22        ConfigurationVerifyKey("ExcludeDir", ConfigTest_MultiValueAllowed), 
     23        ConfigurationVerifyKey("ExcludeDirsRegex", ConfigTest_MultiValueAllowed), 
     24        ConfigurationVerifyKey("AlwaysIncludeFile", ConfigTest_MultiValueAllowed), 
     25        ConfigurationVerifyKey("AlwaysIncludeFilesRegex", ConfigTest_MultiValueAllowed), 
     26        ConfigurationVerifyKey("AlwaysIncludeDir", ConfigTest_MultiValueAllowed), 
     27        ConfigurationVerifyKey("AlwaysIncludeDirsRegex", ConfigTest_MultiValueAllowed), 
     28        ConfigurationVerifyKey("Path", ConfigTest_Exists | ConfigTest_LastEntry) 
    2929}; 
    3030 
     
    6565static const ConfigurationVerifyKey verifyrootkeys[] =  
    6666{ 
    67         {"AccountNumber", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, 
     67        ConfigurationVerifyKey("AccountNumber", 
     68                ConfigTest_Exists | ConfigTest_IsInt), 
     69        ConfigurationVerifyKey("UpdateStoreInterval", 
     70                ConfigTest_Exists | ConfigTest_IsInt), 
     71        ConfigurationVerifyKey("MinimumFileAge", 
     72                ConfigTest_Exists | ConfigTest_IsInt), 
     73        ConfigurationVerifyKey("MaxUploadWait", 
     74                ConfigTest_Exists | ConfigTest_IsInt), 
     75        ConfigurationVerifyKey("MaxFileTimeInFuture", ConfigTest_IsInt, 172800), 
     76        // file is uploaded if the file is this much in the future 
     77        // (2 days default) 
     78        ConfigurationVerifyKey("AutomaticBackup", ConfigTest_IsBool, true), 
     79         
     80        ConfigurationVerifyKey("SyncAllowScript", 0), 
     81        // script that returns "now" if backup is allowed now, or a number 
     82        // of seconds to wait before trying again if not 
    6883 
    69         {"UpdateStoreInterval", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, 
    70         {"MinimumFileAge", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, 
    71         {"MaxUploadWait", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, 
    72         {"MaxFileTimeInFuture", "172800", ConfigTest_IsInt, 0},         // file is uploaded if the file is this much in the future (2 days default) 
     84        ConfigurationVerifyKey("MaximumDiffingTime", ConfigTest_IsInt), 
     85        ConfigurationVerifyKey("DeleteRedundantLocationsAfter", 
     86                ConfigTest_IsInt, 172800), 
    7387 
    74         {"AutomaticBackup", "yes", ConfigTest_IsBool, 0}, 
     88        ConfigurationVerifyKey("FileTrackingSizeThreshold",  
     89                ConfigTest_Exists | ConfigTest_IsInt), 
     90        ConfigurationVerifyKey("DiffingUploadSizeThreshold", 
     91                ConfigTest_Exists | ConfigTest_IsInt), 
     92        ConfigurationVerifyKey("StoreHostname", ConfigTest_Exists), 
     93        ConfigurationVerifyKey("StorePort", ConfigTest_IsInt, 
     94                BOX_PORT_BBSTORED), 
     95        ConfigurationVerifyKey("ExtendedLogging", ConfigTest_IsBool, false), 
     96        // extended log to syslog 
     97        ConfigurationVerifyKey("ExtendedLogFile", 0), 
     98        // extended log to a file 
     99        ConfigurationVerifyKey("LogAllFileAccess", ConfigTest_IsBool, false), 
     100        ConfigurationVerifyKey("CommandSocket", 0), 
     101        // not compulsory to have this 
     102        ConfigurationVerifyKey("KeepAliveTime", ConfigTest_IsInt), 
     103        ConfigurationVerifyKey("StoreObjectInfoFile", 0), 
     104        // optional 
     105 
     106        ConfigurationVerifyKey("NotifyScript", 0), 
     107        // optional script to run when backup needs attention, eg store full 
    75108         
    76         {"SyncAllowScript", 0, 0, 0},                   // optional script to run to see if the sync should be started now 
    77                                 // return "now" if it's allowed, or a number of seconds if it's not 
    78  
    79         {"MaximumDiffingTime", 0, ConfigTest_IsInt, 0}, 
    80         {"DeleteRedundantLocationsAfter", "172800", ConfigTest_IsInt, 0}, 
    81  
    82         {"FileTrackingSizeThreshold", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, 
    83         {"DiffingUploadSizeThreshold", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, 
    84         {"StoreHostname", 0, ConfigTest_Exists, 0}, 
    85         {"ExtendedLogging",     "no", ConfigTest_IsBool, 0}, // extended log to syslog 
    86         {"ExtendedLogFile",     NULL, 0, 0}, // extended log to a file 
    87         {"LogAllFileAccess", "no", ConfigTest_IsBool, 0}, 
    88  
    89         {"CommandSocket", 0, 0, 0},                             // not compulsory to have this 
    90         {"KeepAliveTime", 0, ConfigTest_IsInt, 0},                              // optional 
    91         {"StoreObjectInfoFile", 0, 0, 0},                               // optional 
    92  
    93         {"NotifyScript", 0, 0, 0},                              // optional script to run when backup needs attention, eg store full 
    94          
    95         {"CertificateFile", 0, ConfigTest_Exists, 0}, 
    96         {"PrivateKeyFile", 0, ConfigTest_Exists, 0}, 
    97         {"TrustedCAsFile", 0, ConfigTest_Exists, 0}, 
    98         {"KeysFile", 0, ConfigTest_Exists, 0}, 
    99         {"DataDirectory", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0} 
     109        ConfigurationVerifyKey("CertificateFile", ConfigTest_Exists), 
     110        ConfigurationVerifyKey("PrivateKeyFile", ConfigTest_Exists), 
     111        ConfigurationVerifyKey("TrustedCAsFile", ConfigTest_Exists), 
     112        ConfigurationVerifyKey("KeysFile", ConfigTest_Exists), 
     113        ConfigurationVerifyKey("DataDirectory",  
     114                ConfigTest_Exists | ConfigTest_LastEntry), 
    100115}; 
    101116 
  • box/trunk/lib/backupstore/BackupStoreConfigVerify.cpp

    r1777 r2116  
    1717static const ConfigurationVerifyKey verifyserverkeys[] =  
    1818{ 
    19         SERVERTLS_VERIFY_SERVER_KEYS(0) // no default listen addresses 
     19        SERVERTLS_VERIFY_SERVER_KEYS(ConfigurationVerifyKey::NoDefaultValue) 
     20        // no default listen addresses 
    2021}; 
    2122 
     
    3334static const ConfigurationVerifyKey verifyrootkeys[] =  
    3435{ 
    35         {"AccountDatabase",     0, ConfigTest_Exists, 0}, 
    36         {"TimeBetweenHousekeeping",     0, ConfigTest_Exists | ConfigTest_IsInt, 0}, 
    37         {"ExtendedLogging",     "no", ConfigTest_IsBool, 0},                    // make value "yes" to enable in config file 
     36        ConfigurationVerifyKey("AccountDatabase", ConfigTest_Exists), 
     37        ConfigurationVerifyKey("TimeBetweenHousekeeping", 
     38                ConfigTest_Exists | ConfigTest_IsInt), 
     39        ConfigurationVerifyKey("ExtendedLogging", ConfigTest_IsBool, false), 
     40        // make value "yes" to enable in config file 
    3841 
    3942        #ifdef WIN32 
    40                 {"RaidFileConf", "", ConfigTest_LastEntry, 0} 
     43                ConfigurationVerifyKey("RaidFileConf", ConfigTest_LastEntry) 
    4144        #else 
    42                 {"RaidFileConf", BOX_FILE_RAIDFILE_DEFAULT_CONFIG, ConfigTest_LastEntry, 0} 
     45                ConfigurationVerifyKey("RaidFileConf", ConfigTest_LastEntry, 
     46                        BOX_FILE_RAIDFILE_DEFAULT_CONFIG) 
    4347        #endif 
    44  
    4548}; 
    4649 
  • box/trunk/lib/common

    • Property svn:ignore
      •  

        old new  
        1 autogen_CommonException.cpp 
        2 autogen_CommonException.h 
        3 autogen_ConversionException.cpp 
        4 autogen_ConversionException.h 
         1autogen_* 
        52BoxConfig.h 
        63BoxConfig.h.in 
        74Makefile 
        85makeexception.pl 
         6BoxPortsAndFiles.h 
  • box/trunk/lib/common/Configuration.cpp

    r1865 r2116  
    1212#include <stdlib.h> 
    1313#include <limits.h> 
     14 
     15#include <sstream> 
    1416 
    1517#include "Configuration.h" 
     
    3032static const bool sValueBooleanValue[] = {true, true, false, false}; 
    3133 
    32  
     34ConfigurationVerifyKey::ConfigurationVerifyKey 
     35( 
     36        std::string name, 
     37        int flags, 
     38        void *testFunction 
     39) 
     40: mName(name), 
     41  mHasDefaultValue(false), 
     42  mFlags(flags), 
     43  mTestFunction(testFunction) 
     44{ } 
     45 
     46// to allow passing NULL for default ListenAddresses 
     47 
     48ConfigurationVerifyKey::ConfigurationVerifyKey 
     49( 
     50        std::string name, 
     51        int flags, 
     52        NoDefaultValue_t t, 
     53        void *testFunction 
     54) 
     55: mName(name), 
     56  mHasDefaultValue(false), 
     57  mFlags(flags), 
     58  mTestFunction(testFunction) 
     59{ } 
     60 
     61ConfigurationVerifyKey::ConfigurationVerifyKey 
     62( 
     63        std::string name, 
     64        int flags, 
     65        std::string defaultValue, 
     66        void *testFunction 
     67) 
     68: mName(name), 
     69  mDefaultValue(defaultValue), 
     70  mHasDefaultValue(true), 
     71  mFlags(flags), 
     72  mTestFunction(testFunction) 
     73{ } 
     74 
     75ConfigurationVerifyKey::ConfigurationVerifyKey 
     76( 
     77        std::string name, 
     78        int flags, 
     79        const char *defaultValue, 
     80        void *testFunction 
     81) 
     82: mName(name), 
     83  mDefaultValue(defaultValue), 
     84  mHasDefaultValue(true), 
     85  mFlags(flags), 
     86  mTestFunction(testFunction) 
     87{ } 
     88 
     89ConfigurationVerifyKey::ConfigurationVerifyKey 
     90( 
     91        std::string name, 
     92        int flags, 
     93        int defaultValue, 
     94        void *testFunction 
     95) 
     96: mName(name), 
     97  mHasDefaultValue(true), 
     98  mFlags(flags), 
     99  mTestFunction(testFunction) 
     100{ 
     101        ASSERT(flags & ConfigTest_IsInt); 
     102        std::ostringstream val; 
     103        val << defaultValue; 
     104        mDefaultValue = val.str(); 
     105} 
     106 
     107ConfigurationVerifyKey::ConfigurationVerifyKey 
     108( 
     109        std::string name, 
     110        int flags, 
     111        bool defaultValue, 
     112        void *testFunction 
     113) 
     114: mName(name), 
     115  mHasDefaultValue(true), 
     116  mFlags(flags), 
     117  mTestFunction(testFunction) 
     118{ 
     119        ASSERT(flags & ConfigTest_IsBool); 
     120        mDefaultValue = defaultValue ? "yes" : "no"; 
     121} 
     122 
     123ConfigurationVerifyKey::ConfigurationVerifyKey 
     124( 
     125        const ConfigurationVerifyKey& rToCopy 
     126) 
     127: mName(rToCopy.mName), 
     128  mDefaultValue(rToCopy.mDefaultValue), 
     129  mHasDefaultValue(rToCopy.mHasDefaultValue), 
     130  mFlags(rToCopy.mFlags), 
     131  mTestFunction(rToCopy.mTestFunction) 
     132{ } 
    33133 
    34134// -------------------------------------------------------------------------- 
     
    121221                        if(!Verify(*pconfig, *pVerify, std::string(), rErrorMsg)) 
    122222                        { 
    123                                 //TRACE1("Error message from Verify: %s", rErrorMsg.c_str()); 
    124                                 TRACE0("Error at Configuration::Verify\n"); 
     223                                BOX_ERROR("Error verifying configuration: " << 
     224                                        rErrorMsg); 
    125225                                delete pconfig; 
    126226                                pconfig = 0; 
     
    190290                        else 
    191291                        { 
    192                                 rErrorMsg += "Unexpected start block in " + rConfig.mName + "\n"; 
     292                                rErrorMsg += "Unexpected start block in " + 
     293                                        rConfig.mName + "\n"; 
    193294                        } 
    194295                } 
     
    291392// 
    292393// Function 
    293 //              Name:    Configuration::KeyExists(const char *) 
     394//              Name:    Configuration::KeyExists(const std::string&) 
    294395//              Purpose: Checks to see if a key exists 
    295396//              Created: 2003/07/23 
    296397// 
    297398// -------------------------------------------------------------------------- 
    298 bool Configuration::KeyExists(const char *pKeyName) const 
    299 { 
    300         if(pKeyName == 0) {THROW_EXCEPTION(CommonException, BadArguments)} 
    301  
    302         return mKeys.find(pKeyName) != mKeys.end(); 
    303 } 
    304  
    305  
    306 // -------------------------------------------------------------------------- 
    307 // 
    308 // Function 
    309 //              Name:    Configuration::GetKeyValue(const char *) 
     399bool Configuration::KeyExists(const std::string& rKeyName) const 
     400{ 
     401        return mKeys.find(rKeyName) != mKeys.end(); 
     402} 
     403 
     404 
     405// -------------------------------------------------------------------------- 
     406// 
     407// Function 
     408//              Name:    Configuration::GetKeyValue(const std::string&) 
    310409//              Purpose: Returns the value of a configuration variable 
    311410//              Created: 2003/07/23 
    312411// 
    313412// -------------------------------------------------------------------------- 
    314 const std::string &Configuration::GetKeyValue(const char *pKeyName) const 
    315 { 
    316         if(pKeyName == 0) {THROW_EXCEPTION(CommonException, BadArguments)} 
    317  
    318         std::map<std::string, std::string>::const_iterator i(mKeys.find(pKeyName)); 
     413const std::string &Configuration::GetKeyValue(const std::string& rKeyName) const 
     414{ 
     415        std::map<std::string, std::string>::const_iterator i(mKeys.find(rKeyName)); 
    319416         
    320417        if(i == mKeys.end()) 
    321418        { 
    322                 BOX_ERROR("Missing configuration key: " << pKeyName); 
     419                BOX_ERROR("Missing configuration key: " << rKeyName); 
    323420                THROW_EXCEPTION(CommonException, ConfigNoKey) 
    324421        } 
     
    333430// 
    334431// Function 
    335 //              Name:    Configuration::GetKeyValueInt(const char *) 
     432//              Name:    Configuration::GetKeyValueInt(const std::string& rKeyName) 
    336433//              Purpose: Gets a key value as an integer 
    337434//              Created: 2003/07/23 
    338435// 
    339436// -------------------------------------------------------------------------- 
    340 int Configuration::GetKeyValueInt(const char *pKeyName) const 
    341 { 
    342         if(pKeyName == 0) {THROW_EXCEPTION(CommonException, BadArguments)} 
    343  
    344         std::map<std::string, std::string>::const_iterator i(mKeys.find(pKeyName)); 
     437int Configuration::GetKeyValueInt(const std::string& rKeyName) const 
     438{ 
     439        std::map<std::string, std::string>::const_iterator i(mKeys.find(rKeyName)); 
    345440         
    346441        if(i == mKeys.end()) 
     
    363458// 
    364459// Function 
    365 //              Name:    Configuration::GetKeyValueBool(const char *) const 
     460//              Name:    Configuration::GetKeyValueBool(const std::string&) 
    366461//              Purpose: Gets a key value as a boolean 
    367462//              Created: 17/2/04 
    368463// 
    369464// -------------------------------------------------------------------------- 
    370 bool Configuration::GetKeyValueBool(const char *pKeyName) const 
    371 { 
    372         if(pKeyName == 0) {THROW_EXCEPTION(CommonException, BadArguments)} 
    373  
    374         std::map<std::string, std::string>::const_iterator i(mKeys.find(pKeyName)); 
     465bool Configuration::GetKeyValueBool(const std::string& rKeyName) const 
     466{ 
     467        std::map<std::string, std::string>::const_iterator i(mKeys.find(rKeyName)); 
    375468         
    376469        if(i == mKeys.end()) 
     
    429522// 
    430523// Function 
    431 //              Name:    Configuration::SubConfigurationExists(const char *) 
     524//              Name:    Configuration::SubConfigurationExists(const 
     525//                       std::string&) 
    432526//              Purpose: Checks to see if a sub configuration exists 
    433527//              Created: 2003/07/23 
    434528// 
    435529// -------------------------------------------------------------------------- 
    436 bool Configuration::SubConfigurationExists(const char *pSubName) const 
    437 { 
    438         if(pSubName == 0) {THROW_EXCEPTION(CommonException, BadArguments)} 
    439  
     530bool Configuration::SubConfigurationExists(const std::string& rSubName) const 
     531{ 
    440532        // Attempt to find it... 
    441533        std::list<std::pair<std::string, Configuration> >::const_iterator i(mSubConfigurations.begin()); 
     
    444536        { 
    445537                // This the one? 
    446                 if(i->first == pSubName) 
     538                if(i->first == rSubName) 
    447539                { 
    448540                        // Yes. 
     
    459551// 
    460552// Function 
    461 //              Name:    Configuration::GetSubConfiguration(const char *) 
     553//              Name:    Configuration::GetSubConfiguration(const 
     554//                       std::string&) 
    462555//              Purpose: Gets a sub configuration 
    463556//              Created: 2003/07/23 
    464557// 
    465558// -------------------------------------------------------------------------- 
    466 const Configuration &Configuration::GetSubConfiguration(const char *pSubName) const 
    467 { 
    468         if(pSubName == 0) {THROW_EXCEPTION(CommonException, BadArguments)} 
    469  
     559const Configuration &Configuration::GetSubConfiguration(const std::string& 
     560        rSubName) const 
     561{ 
    470562        // Attempt to find it... 
    471563        std::list<std::pair<std::string, Configuration> >::const_iterator i(mSubConfigurations.begin()); 
     
    474566        { 
    475567                // This the one? 
    476                 if(i->first == pSubName) 
     568                if(i->first == rSubName) 
    477569                { 
    478570                        // Yes. 
     
    529621                { 
    530622                        // Can the key be found? 
    531                         ASSERT(pvkey->mpName); 
    532                         if(rConfig.KeyExists(pvkey->mpName)) 
     623                        if(rConfig.KeyExists(pvkey->Name())) 
    533624                        { 
    534625                                // Get value 
    535                                 const std::string &rval = rConfig.GetKeyValue(pvkey->mpName); 
     626                                const std::string &rval = rConfig.GetKeyValue(pvkey->Name()); 
    536627                                const char *val = rval.c_str(); 
    537628 
    538629                                // Check it's a number? 
    539                                 if((pvkey->Tests & ConfigTest_IsInt) == ConfigTest_IsInt) 
     630                                if((pvkey->Flags() & ConfigTest_IsInt) == ConfigTest_IsInt) 
    540631                                {                                        
    541632                                        // Test it... 
     
    546637                                                // not a good value 
    547638                                                ok = false; 
    548                                                 rErrorMsg += rLevel + rConfig.mName +"." + pvkey->mpName + " (key) is not a valid integer.\n"; 
     639                                                rErrorMsg += rLevel + rConfig.mName + "." + pvkey->Name() + " (key) is not a valid integer.\n"; 
    549640                                        } 
    550641                                } 
    551642                                 
    552643                                // Check it's a bool? 
    553                                 if((pvkey->Tests & ConfigTest_IsBool) == ConfigTest_IsBool) 
     644                                if((pvkey->Flags() & ConfigTest_IsBool) == ConfigTest_IsBool) 
    554645                                {                                
    555646                                        // See if it's one of the allowed strings. 
     
    569660                                        { 
    570661                                                ok = false; 
    571                                                 rErrorMsg += rLevel + rConfig.mName +"." + pvkey->mpName + " (key) is not a valid boolean value.\n"; 
     662                                                rErrorMsg += rLevel + rConfig.mName + "." + pvkey->Name() + " (key) is not a valid boolean value.\n"; 
    572663                                        } 
    573664                                } 
    574665                                 
    575666                                // Check for multi valued statments where they're not allowed 
    576                                 if((pvkey->Tests & ConfigTest_MultiValueAllowed) == 0) 
     667                                if((pvkey->Flags() & ConfigTest_MultiValueAllowed) == 0) 
    577668                                { 
    578669                                        // Check to see if this key is a multi-value -- it shouldn't be 
     
    580671                                        { 
    581672                                                ok = false; 
    582                                                 rErrorMsg += rLevel + rConfig.mName +"." + pvkey->mpName + " (key) multi value not allowed (duplicated key?).\n"; 
     673                                                rErrorMsg += rLevel + rConfig.mName +"." + pvkey->Name() + " (key) multi value not allowed (duplicated key?).\n"; 
    583674                                        } 
    584675                                }                                
     
    587678                        { 
    588679                                // Is it required to exist? 
    589                                 if((pvkey->Tests & ConfigTest_Exists) == ConfigTest_Exists) 
     680                                if((pvkey->Flags() & ConfigTest_Exists) == ConfigTest_Exists) 
    590681                                { 
    591682                                        // Should exist, but doesn't. 
    592683                                        ok = false; 
    593                                         rErrorMsg += rLevel + rConfig.mName + "." + pvkey->mpName + " (key) is missing.\n"; 
    594                                 } 
    595                                 else if(pvkey->mpDefaultValue) 
    596                                 { 
    597                                         rConfig.mKeys[std::string(pvkey->mpName)] = std::string(pvkey->mpDefaultValue); 
     684                                        rErrorMsg += rLevel + rConfig.mName + "." + pvkey->Name() + " (key) is missing.\n"; 
     685                                } 
     686                                else if(pvkey->HasDefaultValue()) 
     687                                { 
     688                                        rConfig.mKeys[pvkey->Name()] = 
     689                                                pvkey->DefaultValue(); 
    598690                                } 
    599691                        } 
    600692                 
    601                         if((pvkey->Tests & ConfigTest_LastEntry) == ConfigTest_LastEntry) 
     693                        if((pvkey->Flags() & ConfigTest_LastEntry) == ConfigTest_LastEntry) 
    602694                        { 
    603695                                // No more! 
     
    619711                        while(scan) 
    620712                        { 
    621                                 if(scan->mpName == i->first) 
     713                                if(scan->Name() == i->first) 
    622714                                { 
    623715                                        found = true; 
     
    626718                                 
    627719                                // Next? 
    628                                 if((scan->Tests & ConfigTest_LastEntry) == ConfigTest_LastEntry) 
     720                                if((scan->Flags() & ConfigTest_LastEntry) == ConfigTest_LastEntry) 
    629721                                { 
    630722                                        break; 
     
    651743                while(scan) 
    652744                { 
    653                         ASSERT(scan->mpName); 
    654                         if(scan->mpName[0] == '*') 
     745                        if(scan->mName.length() > 0 && scan->mName[0] == '*') 
    655746                        { 
    656747                                wildcardverify = scan; 
     
    660751                        if((scan->Tests & ConfigTest_Exists) == ConfigTest_Exists) 
    661752                        { 
    662                                 if(scan->mpName[0] == '*') 
     753                                if(scan->mName.length() > 0 && 
     754                                        scan->mName[0] == '*') 
    663755                                { 
    664756                                        // Check something exists 
     
    673765                                { 
    674766                                        // Check real thing exists 
    675                                         if(!rConfig.SubConfigurationExists(scan->mpName)) 
     767                                        if(!rConfig.SubConfigurationExists(scan->mName)) 
    676768                                        { 
    677769                                                // Should exist, but doesn't. 
    678770                                                ok = false; 
    679                                                 rErrorMsg += rLevel + rConfig.mName + "." + scan->mpName + " (block) is missing.\n"; 
     771                                                rErrorMsg += rLevel + rConfig.mName + "." + scan->mName + " (block) is missing.\n"; 
    680772                                        } 
    681773                                } 
     
    702794                        while(scan) 
    703795                        { 
    704                                 if(strcmp(scan->mpName, name) == 0) 
     796                                if(scan->mName == name) 
    705797                                { 
    706798                                        // found it! 
  • box/trunk/lib/common/Configuration.h

    r1776 r2116  
    3030{ 
    3131public: 
    32         const char *mpName;                     // "*" for all other keys (not implemented yet) 
    33         const char *mpDefaultValue;     // default for when it's not present 
    34         int Tests; 
    35         void *TestFunction;                     // set to zero for now, will implement later 
     32        typedef enum 
     33        { 
     34                NoDefaultValue = 1 
     35        } NoDefaultValue_t; 
     36 
     37        ConfigurationVerifyKey(std::string name, int flags, 
     38                void *testFunction = NULL); 
     39        // to allow passing ConfigurationVerifyKey::NoDefaultValue 
     40        // for default ListenAddresses 
     41        ConfigurationVerifyKey(std::string name, int flags, 
     42                NoDefaultValue_t t, void *testFunction = NULL); 
     43        ConfigurationVerifyKey(std::string name, int flags, 
     44                std::string defaultValue, void *testFunction = NULL); 
     45        ConfigurationVerifyKey(std::string name, int flags, 
     46                const char* defaultValue, void *testFunction = NULL); 
     47        ConfigurationVerifyKey(std::string name, int flags, 
     48                int defaultValue, void *testFunction = NULL); 
     49        ConfigurationVerifyKey(std::string name, int flags, 
     50                bool defaultValue, void *testFunction = NULL); 
     51        const std::string& Name() const { return mName; } 
     52        const std::string& DefaultValue() const { return mDefaultValue; } 
     53        const bool HasDefaultValue() const { return mHasDefaultValue; } 
     54        const int Flags() const { return mFlags; } 
     55        const void* TestFunction() const { return mTestFunction; } 
     56        ConfigurationVerifyKey(const ConfigurationVerifyKey& rToCopy); 
     57 
     58private: 
     59        ConfigurationVerifyKey& operator=(const ConfigurationVerifyKey& 
     60                noAssign); 
     61 
     62        std::string mName;         // "*" for all other keys (not implemented yet) 
     63        std::string mDefaultValue; // default for when it's not present 
     64        bool mHasDefaultValue; 
     65        int mFlags; 
     66        void *mTestFunction; // set to zero for now, will implement later 
    3667}; 
    3768 
     
    3970{ 
    4071public: 
    41         const char *mpName;                     // "*" for all other sub config names 
     72        std::string mName; // "*" for all other sub config names 
    4273        const ConfigurationVerify *mpSubConfigurations; 
    4374        const ConfigurationVerifyKey *mpKeys; 
    4475        int Tests;       
    45         void *TestFunction;                     // set to zero for now, will implement later 
     76        void *TestFunction; // set to zero for now, will implement later 
    4677}; 
    4778 
     
    80111        { return LoadAndVerify(rFilename, 0, rErrorMsg); } 
    81112         
    82         bool KeyExists(const char *pKeyName) const; 
    83         const std::string &GetKeyValue(const char *pKeyName) const; 
    84         int GetKeyValueInt(const char *pKeyName) const; 
    85         bool GetKeyValueBool(const char *pKeyName) const; 
     113        bool KeyExists(const std::string& rKeyName) const; 
     114        const std::string &GetKeyValue(const std::string& rKeyName) const; 
     115        int GetKeyValueInt(const std::string& rKeyName) const; 
     116        bool GetKeyValueBool(const std::string& rKeyName) const; 
    86117        std::vector<std::string> GetKeyNames() const; 
    87118         
    88         bool SubConfigurationExists(const char *pSubName) const; 
    89         const Configuration &GetSubConfiguration(const char *pSubName) const; 
     119        bool SubConfigurationExists(const std::string& rSubName) const; 
     120        const Configuration &GetSubConfiguration(const std::string& rSubName) const; 
    90121        std::vector<std::string> GetSubConfigurationNames() const; 
    91122         
  • box/trunk/lib/compress

    • Property svn:ignore
      •  

        old new  
        1 autogen_CompressException.cpp 
        2 autogen_CompressException.h 
         1autogen_* 
        32Makefile 
  • box/trunk/lib/crypto

    • Property svn:ignore
      •  

        old new  
        1 autogen_CipherException.cpp 
        2 autogen_CipherException.h 
         1autogen_* 
        32Makefile 
  • box/trunk/lib/intercept

    • Property svn:ignore set to
      Makefile
  • box/trunk/lib/raidfile

    • Property svn:ignore
      •  

        old new  
        1 autogen_RaidFileException.cpp 
        2 autogen_RaidFileException.h 
         1autogen_* 
        32Makefile 
        43raidfile-config 
  • box/trunk/lib/raidfile/RaidFileController.cpp

    r1789 r2116  
    7171        static const ConfigurationVerifyKey verifykeys[] = 
    7272        { 
    73                 {"SetNumber",   0,      ConfigTest_Exists | ConfigTest_IsInt, 0}, 
    74                 {"BlockSize",   0,      ConfigTest_Exists | ConfigTest_IsInt, 0}, 
    75                 {"Dir0",                0,      ConfigTest_Exists, 0}, 
    76                 {"Dir1",                0,      ConfigTest_Exists, 0}, 
    77                 {"Dir2",                0,      ConfigTest_Exists | ConfigTest_LastEntry, 0} 
     73                ConfigurationVerifyKey("SetNumber", 
     74                        ConfigTest_Exists | ConfigTest_IsInt), 
     75                ConfigurationVerifyKey("BlockSize", 
     76                        ConfigTest_Exists | ConfigTest_IsInt), 
     77                ConfigurationVerifyKey("Dir0", ConfigTest_Exists), 
     78                ConfigurationVerifyKey("Dir1", ConfigTest_Exists), 
     79                ConfigurationVerifyKey("Dir2", 
     80                        ConfigTest_Exists | ConfigTest_LastEntry) 
    7881        }; 
    7982         
  • box/trunk/lib/server

    • Property svn:ignore
      •  

        old new  
        1 autogen_ConnectionException.cpp 
        2 autogen_ConnectionException.h 
        3 autogen_ServerException.cpp 
        4 autogen_ServerException.h 
         1autogen_* 
        52Makefile 
        63makeprotocol.pl 
  • box/trunk/lib/server/Daemon.h

    r2099 r2116  
    9393}; 
    9494 
    95 #define DAEMON_VERIFY_SERVER_KEYS       {"PidFile", 0, ConfigTest_Exists, 0}, \ 
    96                                                                         {"User", 0, ConfigTest_LastEntry, 0} 
     95#define DAEMON_VERIFY_SERVER_KEYS \ 
     96        ConfigurationVerifyKey("PidFile", ConfigTest_Exists), \ 
     97        ConfigurationVerifyKey("User", ConfigTest_LastEntry) 
    9798 
    9899#endif // DAEMON__H 
  • box/trunk/lib/server/ServerStream.h

    r2114 r2116  
    366366 
    367367#define SERVERSTREAM_VERIFY_SERVER_KEYS(DEFAULT_ADDRESSES) \ 
    368                                                                                         {"ListenAddresses", DEFAULT_ADDRESSES, 0, 0}, \ 
    369                                                                                         DAEMON_VERIFY_SERVER_KEYS  
     368        ConfigurationVerifyKey("ListenAddresses", 0, DEFAULT_ADDRESSES), \ 
     369        DAEMON_VERIFY_SERVER_KEYS  
    370370 
    371371#include "MemLeakFindOff.h" 
  • box/trunk/lib/server/ServerTLS.h

    r217 r2116  
    7171 
    7272#define SERVERTLS_VERIFY_SERVER_KEYS(DEFAULT_ADDRESSES) \ 
    73                                                                                         {"CertificateFile", 0, ConfigTest_Exists, 0}, \ 
    74                                                                                         {"PrivateKeyFile", 0, ConfigTest_Exists, 0}, \ 
    75                                                                                         {"TrustedCAsFile", 0, ConfigTest_Exists, 0}, \ 
    76                                                                                         SERVERSTREAM_VERIFY_SERVER_KEYS(DEFAULT_ADDRESSES) 
    77  
     73        ConfigurationVerifyKey("CertificateFile", ConfigTest_Exists), \ 
     74        ConfigurationVerifyKey("PrivateKeyFile", ConfigTest_Exists), \ 
     75        ConfigurationVerifyKey("TrustedCAsFile", ConfigTest_Exists), \ 
     76        SERVERSTREAM_VERIFY_SERVER_KEYS(DEFAULT_ADDRESSES) 
    7877 
    7978#endif // SERVERTLS__H 
  • box/trunk/test/basicserver

    • Property svn:ignore
      •  

        old new  
        1 autogen_TestProtocolClient.cpp 
        2 autogen_TestProtocolClient.h 
        3 autogen_TestProtocolServer.cpp 
        4 autogen_TestProtocolServer.h 
         1autogen_* 
        52_main.cpp 
        63Makefile 
  • box/trunk/test/basicserver/testbasicserver.cpp

    r2014 r2116  
    186186        static ConfigurationVerifyKey verifyserverkeys[] =  
    187187        { 
    188                 SERVERSTREAM_VERIFY_SERVER_KEYS(0)      // no default addresses 
     188                SERVERSTREAM_VERIFY_SERVER_KEYS(ConfigurationVerifyKey::NoDefaultValue) // no default listen addresses 
    189189        }; 
    190190 
     
    259259        static ConfigurationVerifyKey verifyserverkeys[] =  
    260260        { 
    261                 SERVERTLS_VERIFY_SERVER_KEYS(0) // no default listen addresses 
     261                SERVERTLS_VERIFY_SERVER_KEYS(ConfigurationVerifyKey::NoDefaultValue) // no default listen addresses 
    262262        }; 
    263263 
  • box/trunk/test/bbackupd/testbbackupd.cpp

    r2107 r2116  
    515515                        // connect and log in 
    516516                        SocketStreamTLS conn; 
    517                         conn.Open(context, Socket::TypeINET, "localhost", BOX_PORT_BBSTORED); 
     517                        conn.Open(context, Socket::TypeINET, "localhost", 
     518                                22011); 
    518519                        BackupProtocolClient protocol(conn); 
    519520                        protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION); 
     
    608609{ 
    609610        sSocket.Open(rContext, Socket::TypeINET,  
    610                 "localhost", BOX_PORT_BBSTORED); 
     611                "localhost", 22011); 
    611612        std::auto_ptr<BackupProtocolClient> connection; 
    612613        connection.reset(new BackupProtocolClient(sSocket)); 
     
    25602561                                == Restore_TargetExists); 
    25612562                         
    2562                         // Make sure you can't restore to a nonexistant path 
    2563                         printf("Try to restore to a path that doesn't exist\n"); 
    2564                         TEST_THAT(BackupClientRestore(*client, restoredirid,  
    2565                                 "testfiles/no-such-path/subdir",  
    2566                                 true /* print progress dots */)  
    2567                                 == Restore_TargetPathNotFound); 
    2568                          
    25692563                        // Find ID of the deleted directory 
    25702564                        deldirid = GetDirID(*client, "x1", restoredirid); 
     
    25782572                                true /* deleted files */)  
    25792573                                == Restore_Complete); 
     2574 
     2575                        // Make sure you can't restore to a nonexistant path 
     2576                        printf("\n\n==== Try to restore to a path " 
     2577                                "that doesn't exist\n"); 
     2578                        fflush(stdout); 
     2579                        TEST_THAT(BackupClientRestore(*client, restoredirid,  
     2580                                "testfiles/no-such-path/subdir",  
     2581                                true /* print progress dots */)  
     2582                                == Restore_TargetPathNotFound); 
    25802583 
    25812584                        // Log out 
  • box/trunk/test/bbackupd/testfiles

    • Property svn:ignore
      •  

        old new  
        22extcheck2.pl 
        33notifyscript.pl 
         4bbackupd.conf 
         5syncallowscript.pl 
  • box/trunk/test/bbackupd/testfiles/bbackupd-temploc.conf

    r1867 r2116  
    99 
    1010StoreHostname = localhost 
     11StorePort = 22011 
    1112AccountNumber = 0x01234567 
    1213 
  • box/trunk/test/bbackupd/testfiles/bbackupd.conf.in

    r1867 r2116  
    99 
    1010StoreHostname = localhost 
     11StorePort = 22011 
    1112AccountNumber = 0x01234567 
    1213 
  • box/trunk/test/bbackupd/testfiles/bbstored.conf

    r217 r2116  
    1010{ 
    1111        PidFile = testfiles/bbstored.pid 
    12         ListenAddresses = inet:localhost 
     12        ListenAddresses = inet:localhost:22011 
    1313        CertificateFile = testfiles/serverCerts.pem 
    1414        PrivateKeyFile = testfiles/serverPrivKey.pem 
  • box/trunk/test/common/testcommon.cpp

    r1774 r2116  
    5858ConfigurationVerifyKey verifykeys1_1_1[] = 
    5959{ 
    60         {"bing", 0, ConfigTest_Exists, 0}, 
    61         {"carrots", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, 
    62         {"terrible", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0} 
     60        ConfigurationVerifyKey("bing", ConfigTest_Exists), 
     61        ConfigurationVerifyKey("carrots", ConfigTest_Exists | ConfigTest_IsInt), 
     62        ConfigurationVerifyKey("terrible", ConfigTest_Exists | ConfigTest_LastEntry) 
    6363}; 
    6464 
    6565ConfigurationVerifyKey verifykeys1_1_2[] = 
    6666{ 
    67         {"fish", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, 
    68         {"string", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0} 
     67        ConfigurationVerifyKey("fish", ConfigTest_Exists | ConfigTest_IsInt), 
     68        ConfigurationVerifyKey("string", ConfigTest_Exists | ConfigTest_LastEntry) 
    6969}; 
    7070 
     
    9090ConfigurationVerifyKey verifykeys1_1[] = 
    9191{ 
    92         {"value", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, 
    93         {"string1", 0, ConfigTest_Exists, 0}, 
    94         {"string2", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0} 
     92        ConfigurationVerifyKey("value", ConfigTest_Exists | ConfigTest_IsInt), 
     93        ConfigurationVerifyKey("string1", ConfigTest_Exists), 
     94        ConfigurationVerifyKey("string2", ConfigTest_Exists | ConfigTest_LastEntry) 
    9595}; 
    9696 
    9797ConfigurationVerifyKey verifykeys1_2[] =  
    9898{ 
    99         {"carrots", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, 
    100         {"string", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0} 
     99        ConfigurationVerifyKey("carrots", ConfigTest_Exists | ConfigTest_IsInt), 
     100        ConfigurationVerifyKey("string", ConfigTest_Exists | ConfigTest_LastEntry) 
    101101}; 
    102102 
     
    121121ConfigurationVerifyKey verifykeys1[] = 
    122122{ 
    123                 {"notExpected", 0, 0, 0}, 
    124                 {"HasDefaultValue", "Lovely default value", 0, 0}, 
    125                 {"MultiValue", 0, ConfigTest_MultiValueAllowed, 0}, 
    126                 {"BoolTrue1", 0, ConfigTest_IsBool, 0}, 
    127                 {"BoolTrue2", 0, ConfigTest_IsBool, 0}, 
    128                 {"BoolFalse1", 0, ConfigTest_IsBool, 0}, 
    129                 {"BoolFalse2", 0, ConfigTest_IsBool, 0}, 
    130                 {"TOPlevel", 0, ConfigTest_LastEntry | ConfigTest_Exists, 0} 
     123                ConfigurationVerifyKey("notExpected", 0), 
     124                ConfigurationVerifyKey("HasDefaultValue", 0, "Lovely default value"), 
     125                ConfigurationVerifyKey("MultiValue", ConfigTest_MultiValueAllowed), 
     126                ConfigurationVerifyKey("BoolTrue1", ConfigTest_IsBool), 
     127                ConfigurationVerifyKey("BoolTrue2", ConfigTest_IsBool), 
     128                ConfigurationVerifyKey("BoolFalse1", ConfigTest_IsBool), 
     129                ConfigurationVerifyKey("BoolFalse2", ConfigTest_IsBool), 
     130                ConfigurationVerifyKey("TOPlevel",  
     131                        ConfigTest_LastEntry | ConfigTest_Exists) 
    131132}; 
    132133