From: Timo Sirainen Date: Mon, 27 Mar 2023 10:10:01 +0000 (+0300) Subject: auth: Stop reading settings multiple times X-Git-Tag: 2.4.0~2215 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4cf420005d0bbb4bfcd72365ee806fc31f88d5f2;p=thirdparty%2Fdovecot%2Fcore.git auth: Stop reading settings multiple times --- diff --git a/src/auth/auth-settings.c b/src/auth/auth-settings.c index ffb883b7bd..82a598ccf8 100644 --- a/src/auth/auth-settings.c +++ b/src/auth/auth-settings.c @@ -544,20 +544,20 @@ auth_userdb_settings_check(void *_set, pool_t pool ATTR_UNUSED, const struct auth_settings *global_auth_settings; -const struct auth_settings * -auth_settings_read(const char *service, - struct master_service_settings_output *output_r) +void auth_settings_read(struct master_service_settings_output *output_r) { struct master_service_settings_input input; const char *error; i_zero(&input); - input.service = service; input.disable_check_settings = TRUE; if (master_service_settings_read(master_service, &input, output_r, &error) < 0) i_fatal("%s", error); +} +const struct auth_settings *auth_settings_get(const char *service) +{ struct event *event = event_create(NULL); event_add_str(event, "protocol", service); const struct auth_settings *set = diff --git a/src/auth/auth-settings.h b/src/auth/auth-settings.h index 6c921205c6..df1a94df5c 100644 --- a/src/auth/auth-settings.h +++ b/src/auth/auth-settings.h @@ -101,9 +101,7 @@ struct auth_settings { extern const struct setting_parser_info auth_setting_parser_info; extern const struct auth_settings *global_auth_settings; -const struct auth_settings * -auth_settings_read(const char *service, - struct master_service_settings_output *output_r) - ATTR_NULL(1); +void auth_settings_read(struct master_service_settings_output *output_r); +const struct auth_settings *auth_settings_get(const char *service); #endif diff --git a/src/auth/auth.c b/src/auth/auth.c index 7785906ef2..72784daf2c 100644 --- a/src/auth/auth.c +++ b/src/auth/auth.c @@ -407,7 +407,6 @@ void auths_preinit(const struct auth_settings *set, const struct mechanisms_register *reg, const char *const *services) { - struct master_service_settings_output set_output; const struct auth_settings *service_set; struct auth *auth; unsigned int i; @@ -431,7 +430,7 @@ void auths_preinit(const struct auth_settings *set, } not_service = services[i]; } - service_set = auth_settings_read(services[i], &set_output); + service_set = auth_settings_get(services[i]); auth = auth_preinit(service_set, services[i], reg); array_push_back(&auths, &auth); } diff --git a/src/auth/main.c b/src/auth/main.c index 79f6f70b00..7455d318f3 100644 --- a/src/auth/main.c +++ b/src/auth/main.c @@ -89,7 +89,8 @@ static const char *const *read_global_settings(void) { struct master_service_settings_output set_output; - global_auth_settings = auth_settings_read(NULL, &set_output); + auth_settings_read(&set_output); + global_auth_settings = auth_settings_get(NULL); if (set_output.specific_services == NULL) return t_new(const char *, 1); return set_output.specific_services;