diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2014-05-19 13:59:23 +0200 |
---|---|---|
committer | Peter Rajnoha <prajnoha@redhat.com> | 2014-05-19 15:39:55 +0200 |
commit | 9a324df3b329f1a28462f246219522da62a022ce (patch) | |
tree | 6dcc237f7f316015f82049567d7e9f77b0b55668 /tools/lvmcmdline.c | |
parent | c42f72867a653974f07e6e1db52f41691356e5b7 (diff) | |
download | lvm2-9a324df3b329f1a28462f246219522da62a022ce.tar.gz |
config: fix incorrect profile initialization on cmd context refresh
When cmd refresh is called, we need to move any already loaded profiles
to profiles_to_load list which will cause their reload on subsequent
use. In addition to that, we need to take into account any change
in config/profile configuration setting on cmd context refresh
since this setting could be overriden with --config.
Also, when running commands in the shell, we need to remove the
global profile used from the configuration cascade so the profile
is not incorrectly reused next time when the --profile option is
not specified anymore for the next command in the shell.
This bug only affected profile specified by --profile cmd line
arg, not profiles referenced from LVM metadata.
Diffstat (limited to 'tools/lvmcmdline.c')
-rw-r--r-- | tools/lvmcmdline.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c index 7e4d9a6a3..69e578147 100644 --- a/tools/lvmcmdline.c +++ b/tools/lvmcmdline.c @@ -1081,11 +1081,11 @@ static const char *_copy_command_line(struct cmd_context *cmd, int argc, char ** int lvm_run_command(struct cmd_context *cmd, int argc, char **argv) { + struct dm_config_tree *config_string_cft, *config_profile_cft; + struct profile *profile; int ret = 0; int locking_type; int monitoring; - struct dm_config_tree *old_cft; - struct profile *profile; init_error_message_produced(0); @@ -1124,9 +1124,8 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv) if (arg_count(cmd, config_ARG) || !cmd->config_initialized || config_files_changed(cmd)) { /* Reinitialise various settings inc. logging, filters */ if (!refresh_toolcontext(cmd)) { - old_cft = remove_config_tree_by_source(cmd, CONFIG_STRING); - if (old_cft) - dm_config_destroy(old_cft); + if ((config_string_cft = remove_config_tree_by_source(cmd, CONFIG_STRING))) + dm_config_destroy(config_string_cft); log_error("Updated config file invalid. Aborting."); return ECMD_FAILED; } @@ -1204,8 +1203,13 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv) lvmcache_destroy(cmd, 1, 0); } - if ((old_cft = remove_config_tree_by_source(cmd, CONFIG_STRING))) { - dm_config_destroy(old_cft); + if ((config_string_cft = remove_config_tree_by_source(cmd, CONFIG_STRING))) + dm_config_destroy(config_string_cft); + + config_profile_cft = remove_config_tree_by_source(cmd, CONFIG_PROFILE); + cmd->profile_params->global_profile = NULL; + + if (config_string_cft || config_profile_cft) { /* Move this? */ if (!refresh_toolcontext(cmd)) stack; |