From afae97d3c429b718f91c212da9695f2f4f328adb Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 8 Jan 2018 14:07:14 -0600 Subject: [PATCH] common/global_init: parse environment Signed-off-by: Sage Weil --- src/common/config.cc | 12 ++++++++++-- src/common/config.h | 2 +- src/global/global_init.cc | 6 ++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/common/config.cc b/src/common/config.cc index 8fa4d3d496b6a..8d00d752905c7 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -458,15 +458,23 @@ int md_config_t::parse_config_files(const char *conf_files_str, return 0; } -void md_config_t::parse_env() +void md_config_t::parse_env(const char *args_var) { - Mutex::Locker l(lock); if (safe_to_start_threads) return; + if (!args_var) { + args_var = "CEPH_ARGS"; + } if (getenv("CEPH_KEYRING")) { + Mutex::Locker l(lock); string k = getenv("CEPH_KEYRING"); values["keyring"][CONF_ENV] = Option::value_t(k); } + if (getenv(args_var)) { + vector env_args; + env_to_vec(env_args, args_var); + parse_argv(env_args, CONF_ENV); + } } void md_config_t::show_config(std::ostream& out) diff --git a/src/common/config.h b/src/common/config.h index 5cdc71e5eb219..bfa2bef2d5b41 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -141,7 +141,7 @@ public: std::ostream *warnings, int flags); // Absorb config settings from the environment - void parse_env(); + void parse_env(const char *env_var = "CEPH_ARGS"); // Absorb config settings from argv int parse_argv(std::vector& args, int level=CONF_CMDLINE); diff --git a/src/global/global_init.cc b/src/global/global_init.cc index ea454b11f1be5..e81023e50f36f 100644 --- a/src/global/global_init.cc +++ b/src/global/global_init.cc @@ -134,9 +134,11 @@ void global_pre_init( _exit(1); } - conf->parse_env(); // environment variables override + // environment variables override (CEPH_ARGS, CEPH_KEYRING) + conf->parse_env(); - conf->parse_argv(args); // argv override + // command line (as passed by caller) + conf->parse_argv(args); if (!iparams.no_mon_config) { MonClient mc_bootstrap(g_ceph_context); -- 2.39.5