From e4c467af04a82309dc1d54eabfecf670d379bd88 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20D=C3=B6rre?= Date: Sat, 30 May 2015 15:26:58 +0200 Subject: [PATCH] add: load CAs based on prefixes --- src/config.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index ce78f41..ad3c137 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -91,26 +91,26 @@ int parseProfiles() { std::string cas = map->at( "ca" ); - for( size_t pos = 0; pos != std::string::npos; ) { - size_t end = cas.find( ",", pos ); - std::string sub; - - if( end == std::string::npos ) { - sub = cas.substr( pos ); - } else { - sub = cas.substr( pos, end - pos ); - end++; + DIR *dir; + struct dirent *ent; + if ((dir = opendir ("ca")) != NULL) { + while ((ent = readdir (dir)) != NULL) { + std::string caName = std::string(ent->d_name); + if( caName.find( cas ) != 0 ){ + continue; + } + + if( CAs.find( caName ) == CAs.end() ) { + std::shared_ptr ca( new CAConfig( caName ) ); + CAs.emplace( caName, ca ); + } + + prof.ca.push_back( CAs.at( caName ) ); + std::cout << "Adding CA: " << caName << std::endl; } - - pos = end; - - if( CAs.find( sub ) == CAs.end() ) { - std::shared_ptr ca( new CAConfig( sub ) ); - CAs.emplace( sub, ca ); - } - - prof.ca.push_back( CAs.at( sub ) ); - + closedir (dir); + } else { + throw "Directory with CAConfigs not found"; } profiles.emplace( profileName, prof ); -- 2.39.2