------------------------------------------------------------ revno: 12586 revision-id: squidadm@squid-cache.org-20130705030600-eqo6vu8vymjl420n parent: squid3@treenet.co.nz-20130704044207-g88vxd85lzwmn93h committer: Automatic source maintenance branch nick: 3.3 timestamp: Thu 2013-07-04 21:06:00 -0600 message: SourceFormat Enforcement ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squidadm@squid-cache.org-20130705030600-\ # eqo6vu8vymjl420n # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.3 # testament_sha1: 70f129ec017323f8d4f3948be36ed25e04a91c20 # timestamp: 2013-07-05 03:56:17 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.3 # base_revision_id: squid3@treenet.co.nz-20130704044207-\ # g88vxd85lzwmn93h # # Begin patch === modified file 'src/ssl/certificate_db.cc' --- src/ssl/certificate_db.cc 2013-07-04 04:42:07 +0000 +++ src/ssl/certificate_db.cc 2013-07-05 03:06:00 +0000 @@ -184,8 +184,7 @@ } #define countof(arr) (sizeof(arr)/sizeof(*arr)) -void Ssl::CertificateDb::sq_TXT_DB_delete_row(TXT_DB *db, int idx) -{ +void Ssl::CertificateDb::sq_TXT_DB_delete_row(TXT_DB *db, int idx) { char **rrow; #if SQUID_SSLTXTDB_PSTRINGDATA rrow = (char **)sk_OPENSSL_PSTRING_delete(db->data, idx); @@ -213,29 +212,25 @@ } } -unsigned long Ssl::CertificateDb::index_serial_hash(const char **a) -{ +unsigned long Ssl::CertificateDb::index_serial_hash(const char **a) { const char *n = a[Ssl::CertificateDb::cnlSerial]; while (*n == '0') ++n; return lh_strhash(n); } -int Ssl::CertificateDb::index_serial_cmp(const char **a, const char **b) -{ +int Ssl::CertificateDb::index_serial_cmp(const char **a, const char **b) { const char *aa, *bb; for (aa = a[Ssl::CertificateDb::cnlSerial]; *aa == '0'; ++aa); for (bb = b[Ssl::CertificateDb::cnlSerial]; *bb == '0'; ++bb); return strcmp(aa, bb); } -unsigned long Ssl::CertificateDb::index_name_hash(const char **a) -{ +unsigned long Ssl::CertificateDb::index_name_hash(const char **a) { return(lh_strhash(a[Ssl::CertificateDb::cnlName])); } -int Ssl::CertificateDb::index_name_cmp(const char **a, const char **b) -{ +int Ssl::CertificateDb::index_name_cmp(const char **a, const char **b) { return(strcmp(a[Ssl::CertificateDb::cnlName], b[CertificateDb::cnlName])); } @@ -252,23 +247,20 @@ max_db_size(aMax_db_size), fs_block_size(aFs_block_size), dbLock(db_full), - enabled_disk_store(true) -{ + enabled_disk_store(true) { if (db_path.empty() && !max_db_size) enabled_disk_store = false; else if ((db_path.empty() && max_db_size) || (!db_path.empty() && !max_db_size)) throw std::runtime_error("ssl_crtd is missing the required parameter. There should be -s and -M parameters together."); } -bool Ssl::CertificateDb::find(std::string const & host_name, Ssl::X509_Pointer & cert, Ssl::EVP_PKEY_Pointer & pkey) -{ +bool Ssl::CertificateDb::find(std::string const & host_name, Ssl::X509_Pointer & cert, Ssl::EVP_PKEY_Pointer & pkey) { const Locker locker(dbLock, Here); load(); return pure_find(host_name, cert, pkey); } -bool Ssl::CertificateDb::purgeCert(std::string const & key) -{ +bool Ssl::CertificateDb::purgeCert(std::string const & key) { const Locker locker(dbLock, Here); load(); if (!db) @@ -281,8 +273,7 @@ return true; } -bool Ssl::CertificateDb::addCertAndPrivateKey(Ssl::X509_Pointer & cert, Ssl::EVP_PKEY_Pointer & pkey, std::string const & useName) -{ +bool Ssl::CertificateDb::addCertAndPrivateKey(Ssl::X509_Pointer & cert, Ssl::EVP_PKEY_Pointer & pkey, std::string const & useName) { const Locker locker(dbLock, Here); load(); if (!db || !cert || !pkey) @@ -367,8 +358,7 @@ return true; } -void Ssl::CertificateDb::create(std::string const & db_path) -{ +void Ssl::CertificateDb::create(std::string const & db_path) { if (db_path == "") throw std::runtime_error("Path to db is empty"); std::string db_full(db_path + "/" + db_file); @@ -391,14 +381,12 @@ throw std::runtime_error("Cannot open " + db_full + " to open"); } -void Ssl::CertificateDb::check(std::string const & db_path, size_t max_db_size) -{ +void Ssl::CertificateDb::check(std::string const & db_path, size_t max_db_size) { CertificateDb db(db_path, max_db_size, 0); db.load(); } -bool Ssl::CertificateDb::pure_find(std::string const & host_name, Ssl::X509_Pointer & cert, Ssl::EVP_PKEY_Pointer & pkey) -{ +bool Ssl::CertificateDb::pure_find(std::string const & host_name, Ssl::X509_Pointer & cert, Ssl::EVP_PKEY_Pointer & pkey) { if (!db) return false; @@ -420,23 +408,19 @@ return true; } -size_t Ssl::CertificateDb::size() const -{ +size_t Ssl::CertificateDb::size() const { return readSize(); } -void Ssl::CertificateDb::addSize(std::string const & filename) -{ +void Ssl::CertificateDb::addSize(std::string const & filename) { writeSize(readSize() + getFileSize(filename)); } -void Ssl::CertificateDb::subSize(std::string const & filename) -{ +void Ssl::CertificateDb::subSize(std::string const & filename) { writeSize(readSize() - getFileSize(filename)); } -size_t Ssl::CertificateDb::readSize() const -{ +size_t Ssl::CertificateDb::readSize() const { std::ifstream size_file(size_full.c_str()); if (!size_file && enabled_disk_store) throw std::runtime_error("cannot open for reading: " + size_full); @@ -446,24 +430,21 @@ return db_size; } -void Ssl::CertificateDb::writeSize(size_t db_size) -{ +void Ssl::CertificateDb::writeSize(size_t db_size) { std::ofstream size_file(size_full.c_str()); if (!size_file && enabled_disk_store) throw std::runtime_error("cannot write \"" + size_full + "\" file"); size_file << db_size; } -size_t Ssl::CertificateDb::getFileSize(std::string const & filename) -{ +size_t Ssl::CertificateDb::getFileSize(std::string const & filename) { std::ifstream file(filename.c_str(), std::ios::binary); file.seekg(0, std::ios_base::end); size_t file_size = file.tellg(); return ((file_size + fs_block_size - 1) / fs_block_size) * fs_block_size; } -void Ssl::CertificateDb::load() -{ +void Ssl::CertificateDb::load() { // Load db from file. Ssl::BIO_Pointer in(BIO_new(BIO_s_file())); if (!in || BIO_read_filename(in.get(), db_full.c_str()) <= 0) @@ -487,8 +468,7 @@ db.reset(temp_db.release()); } -void Ssl::CertificateDb::save() -{ +void Ssl::CertificateDb::save() { if (!db) throw std::runtime_error("The certificates database is not loaded");; @@ -502,8 +482,7 @@ } // Normally defined in defines.h file -void Ssl::CertificateDb::deleteRow(const char **row, int rowIndex) -{ +void Ssl::CertificateDb::deleteRow(const char **row, int rowIndex) { const std::string filename(cert_full + "/" + row[cnlSerial] + ".pem"); sq_TXT_DB_delete_row(db.get(), rowIndex); @@ -513,8 +492,7 @@ throw std::runtime_error("Failed to remove certficate file " + filename + " from db"); } -bool Ssl::CertificateDb::deleteInvalidCertificate() -{ +bool Ssl::CertificateDb::deleteInvalidCertificate() { if (!db) return false; @@ -543,8 +521,7 @@ return true; } -bool Ssl::CertificateDb::deleteOldestCertificate() -{ +bool Ssl::CertificateDb::deleteOldestCertificate() { if (!db) return false; @@ -570,8 +547,7 @@ return true; } -bool Ssl::CertificateDb::deleteByHostname(std::string const & host) -{ +bool Ssl::CertificateDb::deleteByHostname(std::string const & host) { if (!db) return false; @@ -594,7 +570,6 @@ return false; } -bool Ssl::CertificateDb::IsEnabledDiskStore() const -{ +bool Ssl::CertificateDb::IsEnabledDiskStore() const { return enabled_disk_store; }