11
11
#include "service-settings.h"
12
12
#include "master-service.h"
13
13
#include "master-service-settings.h"
14
#include "master-service-ssl-settings.h"
14
15
#include "all-settings.h"
15
16
#include "old-set-parser.h"
16
17
#include "config-request.h"
338
339
for (; p->root != NULL; p++) {
339
340
/* skip checking settings we don't care about */
340
if (*ctx->module != '\0' &&
341
!config_module_want_parser(ctx->root_parsers,
342
ctx->module, p->root))
341
if (!config_module_want_parser(ctx->root_parsers,
342
ctx->modules, p->root))
345
345
settings_parse_var_skip(p->parser);
400
400
global_ssl_set = get_str_setting(parsers[0], "ssl", "");
401
401
for (i = 0; i < count && ret == 0; i++) {
402
if (config_filter_parsers_get(new_filter, tmp_pool, "",
402
if (config_filter_parsers_get(new_filter, tmp_pool, NULL,
403
403
&parsers[i]->filter,
404
404
&tmp_parsers, &output,
687
689
new_filter = config_filter_init(ctx->pool);
688
(void)array_append_space(&ctx->all_parsers);
690
array_append_zero(&ctx->all_parsers);
689
691
config_filter_add_all(new_filter, array_idx(&ctx->all_parsers, 0));
691
693
if (ctx->hide_errors)
730
732
struct config_module_parser *l;
732
if (*ctx->module == '\0')
734
if (ctx->modules == NULL)
735
737
for (l = ctx->cur_section->parsers; l->root != NULL; l++) {
736
738
if (config_module_want_parser(ctx->root_parsers,
737
ctx->module, l->root) &&
739
ctx->modules, l->root) &&
738
740
settings_parse_is_valid_key(l->parser, key))
885
int config_parse_file(const char *path, bool expand_values, const char *module,
886
const char **error_r)
887
int config_parse_file(const char *path, bool expand_values,
888
const char *const *modules, const char **error_r)
888
890
struct input_stack root;
889
891
struct config_parser_context ctx;
925
927
root.path = path;
926
928
ctx.cur_input = &root;
927
929
ctx.expand_values = expand_values;
930
ctx.modules = modules;
930
932
p_array_init(&ctx.all_parsers, ctx.pool, 128);
931
933
ctx.cur_section = p_new(ctx.pool, struct config_section_stack, 1);
981
983
struct module_dir_load_settings mod_set;
982
984
struct module *m;
983
985
const struct setting_parser_info **roots;
984
ARRAY_DEFINE(new_roots, const struct setting_parser_info *);
986
ARRAY(const struct setting_parser_info *) new_roots;
985
987
ARRAY_TYPE(service_settings) new_services;
986
988
struct service_settings *const *services, *service_set;
987
989
unsigned int i, count;
989
991
memset(&mod_set, 0, sizeof(mod_set));
990
mod_set.version = master_service_get_version_string(master_service);
992
mod_set.abi_version = DOVECOT_ABI_VERSION;
991
993
modules = module_dir_load(CONFIG_MODULE_DIR, NULL, &mod_set);
992
994
module_dir_init(modules);
1001
1003
array_append(&new_roots, &roots[i], 1);
1004
service_set = module_get_symbol_quiet(m,
1005
t_strdup_printf("%s_service_settings", m->name));
1006
if (service_set != NULL)
1007
array_append(&new_services, &service_set, 1);
1006
services = module_get_symbol_quiet(m,
1007
t_strdup_printf("%s_service_settings_array", m->name));
1008
if (services != NULL) {
1009
for (count = 0; services[count] != NULL; count++) ;
1010
array_append(&new_services, services, count);
1012
service_set = module_get_symbol_quiet(m,
1013
t_strdup_printf("%s_service_settings", m->name));
1014
if (service_set != NULL)
1015
array_append(&new_services, &service_set, 1);
1009
1018
if (array_count(&new_roots) > 0) {
1010
1019
/* modules added new settings. add the defaults and start
1011
1020
using the new list. */
1012
1021
for (i = 0; all_roots[i] != NULL; i++)
1013
1022
array_append(&new_roots, &all_roots[i], 1);
1014
(void)array_append_space(&new_roots);
1023
array_append_zero(&new_roots);
1015
1024
all_roots = array_idx(&new_roots, 0);
1017
1026
if (array_count(&new_services) > 0) {
1048
1057
bool config_module_want_parser(struct config_module_parser *parsers,
1058
const char *const *modules,
1050
1059
const struct setting_parser_info *root)
1052
1061
struct config_module_parser *l;
1054
if (strcmp(root->module_name, module) == 0)
1063
if (modules == NULL)
1056
1065
if (root == &master_service_setting_parser_info) {
1057
1066
/* everyone wants master service settings */
1061
1070
for (l = parsers; l->root != NULL; l++) {
1062
if (strcmp(l->root->module_name, module) != 0)
1071
if (!str_array_find(modules, l->root->module_name))
1065
1074
/* see if we can find a way to get from the original parser