diff --git a/lib/config/config.c b/lib/config/config.c index 784c4b05b..a569444dd 100644 --- a/lib/config/config.c +++ b/lib/config/config.c @@ -2113,7 +2113,7 @@ bad: return NULL; } -static int _check_profile(struct cmd_context *cmd, struct profile *profile) +int config_force_check(struct cmd_context *cmd, config_source_t source, struct dm_config_tree *cft) { struct cft_check_handle *handle; int r; @@ -2124,9 +2124,8 @@ static int _check_profile(struct cmd_context *cmd, struct profile *profile) } handle->cmd = cmd; - handle->cft = profile->cft; - handle->source = profile->source; - /* the check is compulsory - allow only profilable items in a profile config! */ + handle->cft = cft; + handle->source = source; handle->force_check = 1; /* provide warning messages only if config/checks=1 */ handle->suppress_messages = !find_config_tree_bool(cmd, config_checks_CFG, NULL); @@ -2252,7 +2251,7 @@ int load_profile(struct cmd_context *cmd, struct profile *profile) { * messages to be suppressed, but the check itself is always done * for profiles! */ - if (!_check_profile(cmd, profile)) { + if (!config_force_check(cmd, profile->source, profile->cft)) { log_error("Ignoring invalid %s %s.", _config_source_names[profile->source], profile->name); config_destroy(profile->cft); diff --git a/lib/config/config.h b/lib/config/config.h index 157cfeb1c..659b8b00b 100644 --- a/lib/config/config.h +++ b/lib/config/config.h @@ -216,7 +216,10 @@ struct cft_check_handle { }; int config_def_get_path(char *buf, size_t buf_size, int id); +/* Checks config using given handle - the handle may be reused. */ int config_def_check(struct cft_check_handle *handle); +/* Forces config check and automatically creates a new handle inside with defaults and discards the handle after the check. */ +int config_force_check(struct cmd_context *cmd, config_source_t source, struct dm_config_tree *cft); int override_config_tree_from_string(struct cmd_context *cmd, const char *config_settings); int override_config_tree_from_profile(struct cmd_context *cmd, struct profile *profile);