CernVM-FS
2.12.0
|
#include <options.h>
Classes | |
struct | ConfigValue |
Public Member Functions | |
OptionsManager (OptionsTemplateManager *opt_templ_mgr_param) | |
OptionsManager (const OptionsManager &opt_mgr) | |
virtual | ~OptionsManager () |
void | SwitchTemplateManager (OptionsTemplateManager *opt_templ_mgr_param) |
virtual void | ParsePath (const std::string &config_file, const bool external)=0 |
void | ParseDefault (const std::string &fqrn) |
void | ClearConfig () |
bool | IsDefined (const std::string &key) |
bool | GetValue (const std::string &key, std::string *value) const |
std::string | GetValueOrDie (const std::string &key) |
bool | GetSource (const std::string &key, std::string *value) |
bool | IsOn (const std::string ¶m_value) const |
bool | IsOff (const std::string ¶m_value) const |
std::vector< std::string > | GetAllKeys () |
std::vector< std::string > | GetEnvironmentSubset (const std::string &key_prefix, bool strip_prefix) |
std::string | Dump () |
bool | HasConfigRepository (const std::string &fqrn, std::string *config_path) |
void | ProtectParameter (const std::string ¶m) |
void | SetValue (const std::string &key, const std::string &value) |
void | SetValueFromTalk (const std::string &key, const std::string &value) |
void | UnsetValue (const std::string &key) |
void | set_taint_environment (bool value) |
Protected Member Functions | |
std::string | TrimParameter (const std::string ¶meter) |
std::string | SanitizeParameterAssignment (std::string *line, std::vector< std::string > *tokens) |
void | PopulateParameter (const std::string ¶m, const ConfigValue val) |
void | ParseValue (const std::string param, ConfigValue *val) |
void | UpdateEnvironment (const std::string ¶m, ConfigValue val) |
Protected Attributes | |
std::map< std::string, ConfigValue > | config_ |
std::map< std::string, std::string > | protected_parameters_ |
std::map< std::string, std::string > | templatable_values_ |
OptionsTemplateManager * | opt_templ_mgr_ |
bool | taint_environment_ |
Private Member Functions | |
OptionsManager & | operator= (const OptionsManager &) |
This is the abstract base class for the different option parsers. It parses and stores the information contained in different config files, keeping the last parsed file that changed each property. It stores the information in a key-value map so that for each variable name the value and last source are stored, and makes each property part of the program's environments
|
inlineexplicit |
|
inline |
void OptionsManager::ClearConfig | ( | ) |
Cleans all information about the variables
Definition at line 365 of file options.cc.
string OptionsManager::Dump | ( | ) |
Gets all stored key-values of the map in an string format. This format follows the following pattern:
"KEY=VALUE # from SOURCE"
Definition at line 454 of file options.cc.
Referenced by FileSystem::Create(), cvmcache_options_dump(), cvmfs_options_dump(), FuseMain(), TalkManager::MainResponder(), and publish::CmdEnter::WriteCvmfsConfig().
vector< string > OptionsManager::GetAllKeys | ( | ) |
Retrieves a vector containing all stored keys
Definition at line 423 of file options.cc.
Referenced by publish::SettingsBuilder::GetSessionEnvironment().
vector< string > OptionsManager::GetEnvironmentSubset | ( | const std::string & | key_prefix, |
bool | strip_prefix | ||
) |
Returns key=value strings from the options array for all keys that match key_prefix. Can be used to construct an environment pointer for execve.
Definition at line 434 of file options.cc.
Referenced by AuthzExternalFetcher::ExecHelper().
bool OptionsManager::GetSource | ( | const std::string & | key, |
std::string * | value | ||
) |
Gets the stored last source of a concrete variable
key | variable to be accessed in the map |
value | container of the received value, if it exists |
Definition at line 398 of file options.cc.
bool OptionsManager::GetValue | ( | const std::string & | key, |
std::string * | value | ||
) | const |
Gets the stored value for a concrete variable
key | variable to be accessed in the map |
value | container of the received value, if it exists |
Definition at line 376 of file options.cc.
Referenced by publish::SettingsBuilder::ApplyOptionsFromServerPath(), MountPoint::CheckBlacklists(), CheckProxy(), CheckStrictMount(), MountPoint::CreateAuthz(), MountPoint::CreateCatalogManager(), MountPoint::CreateDownloadManagers(), MountPoint::CreateResolvConfWatcher(), publish::SettingsBuilder::CreateSettingsPublisherFromSession(), publish::SettingsBuilder::CreateSettingsRepository(), MountPoint::CreateSignatureManager(), FileSystem::CreateStatistics(), MountPoint::CreateTables(), MountPoint::CreateTracer(), cvmcache_options_get(), cvmfs_attach_repo(), cvmfs_options_get(), FileSystem::DetermineNfsMode(), InstanceInfo::DeterminePaths(), FileSystem::DeterminePosixCacheSettings(), MountPoint::DetermineRootHash(), FileSystem::FileSystem(), FuseMain(), StatisticsDatabase::GcExtendedStats(), GetCacheDir(), GetCvmfsUser(), StatisticsDatabase::GetDBParams(), InstanceInfo::GetDefaultDomain(), receiver::GetParamsFromFile(), publish::SettingsBuilder::GetSessionEnvironment(), GetWorkspace(), anonymous_namespace{cmd_sub.cc}::SwissknifeSubscriber::Init(), Init(), LibGlobals::Initialize(), publish::CmdInfo::Main(), main(), TalkManager::MainResponder(), MkFqrn(), upload::S3Uploader::ParseSpoolerDefinition(), MountPoint::SetupBehavior(), FileSystem::SetupCacheMgr(), MountPoint::SetupDnsTuning(), FileSystem::SetupExternalCacheMgr(), MountPoint::SetupExternalDownloadMgr(), MountPoint::SetupHttpTuning(), MountPoint::SetupInodeAnnotation(), FileSystem::SetupLoggingStandalone(), FileSystem::SetupNfsMaps(), MountPoint::SetupOwnerMaps(), FileSystem::SetupRamCacheMgr(), FileSystem::SetupTieredCacheMgr(), FileSystem::SetupWorkspace(), perf::TelemetryAggregatorInflux::TelemetryAggregatorInflux(), FileSystem::TriageCacheMgr(), and WaitForReload().
std::string OptionsManager::GetValueOrDie | ( | const std::string & | key | ) |
Gets the stored value for a concrete variable. Panics if the value is missing.
key | variable to be accessed in the map |
value | container of the received value, if it exists |
Definition at line 387 of file options.cc.
Referenced by publish::SettingsBuilder::CreateSettingsPublisher(), and publish::SettingsBuilder::GetSessionEnvironment().
bool OptionsManager::HasConfigRepository | ( | const std::string & | fqrn, |
std::string * | config_path | ||
) |
Definition at line 256 of file options.cc.
Referenced by MountPoint::CheckBlacklists().
bool OptionsManager::IsDefined | ( | const std::string & | key | ) |
Checks if a concrete key (variable) is defined
key | variable to be checked in the map |
Definition at line 370 of file options.cc.
Referenced by MountPoint::CreateResolvConfWatcher(), cvmfs_options_clone_legacy(), MountPoint::DetermineRootHash(), receiver::GetParamsFromFile(), Init(), main(), FileSystem::MkCacheParm(), upload::S3Uploader::ParseSpoolerDefinition(), and FileSystem::SetupWorkspace().
bool OptionsManager::IsOff | ( | const std::string & | param_value | ) | const |
Checks if a variable contains a boolean value
param_value | variable to be accessed in the map |
Definition at line 416 of file options.cc.
Referenced by FileSystem::DeterminePosixCacheSettings(), and MountPoint::SetupBehavior().
bool OptionsManager::IsOn | ( | const std::string & | param_value | ) | const |
Checks if a variable contains a boolean value
param_value | variable to be accessed in the map |
Definition at line 409 of file options.cc.
Referenced by publish::SettingsBuilder::ApplyOptionsFromServerPath(), CheckStrictMount(), MountPoint::CreateCatalogManager(), MountPoint::CreateDownloadManagers(), MountPoint::CreateResolvConfWatcher(), FileSystem::CreateStatistics(), FileSystem::DetermineNfsMode(), InstanceInfo::DeterminePaths(), FileSystem::DeterminePosixCacheSettings(), FileSystem::FileSystem(), FuseMain(), StatisticsDatabase::GcExtendedStats(), GetCacheDir(), receiver::GetParamsFromFile(), upload::S3Uploader::ParseSpoolerDefinition(), MountPoint::SetupBehavior(), MountPoint::SetupHttpTuning(), MountPoint::SetupOwnerMaps(), FileSystem::SetupTieredCacheMgr(), FileSystem::SetupWorkspace(), and FileSystem::TriageCacheMgr().
|
inlineprivate |
void OptionsManager::ParseDefault | ( | const std::string & | fqrn | ) |
Parses the default config files for cvmfs
Definition at line 282 of file options.cc.
Referenced by cvmfs_options_parse_default(), InstanceInfo::DeterminePaths(), FuseMain(), InstanceInfo::GetDefaultDomain(), InitOptionsMgr(), main(), and publish::CmdEnter::WriteCvmfsConfig().
|
pure virtual |
Opens the config_file and extracts all contained variables and their corresponding values. The new variables are set (and overwritten in case they were previously defined) as environment variables
config_file | absolute path to the configuration file |
external | if true it indicates the configuration file is in the repository. If false the configuration file is in /etc |
Implemented in BashOptionsManager.
Referenced by publish::SettingsBuilder::CreateSettingsPublisher(), publish::SettingsBuilder::CreateSettingsRepository(), FuseMain(), and InitOptionsMgr().
|
protected |
Definition at line 347 of file options.cc.
|
protected |
void OptionsManager::ProtectParameter | ( | const std::string & | param | ) |
Similar to a bash "read-only" parameter: the current value will be locked and cannot be changed anymore by succeeding parsings of config files.
Definition at line 356 of file options.cc.
|
protected |
|
inline |
Definition at line 199 of file options.h.
Referenced by publish::SettingsBuilder::CreateSettingsPublisher(), publish::SettingsBuilder::CreateSettingsPublisherFromSession(), publish::SettingsBuilder::CreateSettingsRepository(), cvmcache_options_init(), cvmfs_options_init_v2(), and publish::SettingsBuilder::GetSessionEnvironment().
void OptionsManager::SetValue | ( | const std::string & | key, |
const std::string & | value | ||
) |
Artificially inject values in the option manager.
Definition at line 479 of file options.cc.
Referenced by cvmcache_options_init(), cvmcache_options_set(), cvmfs_options_clone_legacy(), cvmfs_options_init_legacy(), cvmfs_options_init_v2(), cvmfs_options_set(), and publish::CmdEnter::WriteCvmfsConfig().
void OptionsManager::SetValueFromTalk | ( | const std::string & | key, |
const std::string & | value | ||
) |
Artificially inject values in the option manager, marking cvmfs_talk as the source.
Definition at line 472 of file options.cc.
Referenced by TalkManager::MainResponder().
void OptionsManager::SwitchTemplateManager | ( | OptionsTemplateManager * | opt_templ_mgr_param | ) |
Switches the Options Templating Manager and reparses the set options
Definition at line 92 of file options.cc.
Referenced by cvmfs_attach_repo_v2(), cvmfs_options_clone_legacy(), and main().
|
protected |
void OptionsManager::UnsetValue | ( | const std::string & | key | ) |
Purge a value from the parameter map. Used in unit tests.
Definition at line 487 of file options.cc.
Referenced by cvmcache_options_unset(), and cvmfs_options_unset().
|
protected |
|
protected |
Definition at line 218 of file options.h.
Referenced by OptionsManager().
|
protected |
Definition at line 222 of file options.h.
Referenced by OptionsManager().
|
protected |
Definition at line 219 of file options.h.
Referenced by OptionsManager().
|
protected |
Whether to add environment variables to the process' environment or not. In libcvmfs, we don't want a tainted environment.
Definition at line 227 of file options.h.
Referenced by OptionsManager().
|
protected |
Definition at line 220 of file options.h.
Referenced by OptionsManager().