in common/util.hpp [224:274]
static std::string retrieve_variable_from_ecs_config( std::string ecs_variable_name )
{
const char* ecs_config_file_name = "/etc/ecs/ecs.config";
std::ifstream config_file( ecs_config_file_name );
std::string line;
std::vector<std::string> results;
while ( std::getline( config_file, line ) )
{
results = Util::split_string( line, '=' );
if ( results.empty() || results.size() != 2 )
{
std::cerr << Util::getCurrentTime() << '\t' << "invalid configuration format"
<< std::endl;
return "";
}
std::string key = results[0];
std::string value = results[1];
Util::rtrim( key );
Util::ltrim( value );
if ( key.compare( ENV_CF_GMSA_OU ) == 0 && ecs_variable_name.compare( key ) == 0 )
{
return value;
}
if ( key.compare( ENV_CF_GMSA_SECRET_NAME ) == 0 &&
ecs_variable_name.compare( key ) == 0 )
{
return value;
}
if ( key.compare( ENV_CF_DOMAIN_CONTROLLER ) == 0 &&
ecs_variable_name.compare( key ) == 0 )
{
return value;
}
if ( key.compare( ENV_CF_DISTINGUISHED_NAME ) == 0 &&
ecs_variable_name.compare( key ) == 0 )
{
return value;
}
}
return "";
}