From: Markus Valentin Date: Mon, 11 Mar 2024 08:11:46 +0000 (+0100) Subject: auth: auth_userdb_preinit() - Lookup settings again after SETTINGS_EVENT_FILTER_NAME... X-Git-Tag: 2.4.1~927 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14cbae89782004e85df65512e05a26bb332a13b1;p=thirdparty%2Fdovecot%2Fcore.git auth: auth_userdb_preinit() - Lookup settings again after SETTINGS_EVENT_FILTER_NAME is set This makes sure defaults which are set specifically for this userdb driver are applied correctly. --- diff --git a/src/auth/auth-settings.h b/src/auth/auth-settings.h index 2b4b7ecbb3..cbaed35460 100644 --- a/src/auth/auth-settings.h +++ b/src/auth/auth-settings.h @@ -128,6 +128,7 @@ struct auth_settings { extern const struct setting_parser_info auth_setting_parser_info; extern const struct setting_parser_info auth_passdb_pre_setting_parser_info; extern const struct setting_parser_info auth_passdb_post_setting_parser_info; +extern const struct setting_parser_info auth_userdb_setting_parser_info; extern const struct setting_parser_info auth_userdb_pre_setting_parser_info; extern const struct setting_parser_info auth_userdb_post_setting_parser_info; extern const struct auth_settings *global_auth_settings; diff --git a/src/auth/auth.c b/src/auth/auth.c index 3c4cb00d2d..b779189be5 100644 --- a/src/auth/auth.c +++ b/src/auth/auth.c @@ -147,17 +147,25 @@ static void auth_passdb_deinit(struct auth_passdb *passdb) } static void -auth_userdb_preinit(struct auth *auth, const struct auth_userdb_settings *set) +auth_userdb_preinit(struct auth *auth, const struct auth_userdb_settings *_set) { - struct auth_userdb *auth_userdb, **dest; + struct auth_userdb *auth_userdb, **dest; + const struct auth_userdb_settings *set; /* Lookup userdb-specific auth_settings */ struct event *event = event_create(auth_event); event_add_str(event, "protocol", auth->protocol); - event_add_str(event, "userdb", set->name); + event_add_str(event, "userdb", _set->name); event_set_ptr(event, SETTINGS_EVENT_FILTER_NAME, p_strconcat(event_get_pool(event), "userdb_", - set->driver, NULL)); + _set->driver, NULL)); + if (_set == &userdb_dummy_set) { + /* If this is the dummy set do not try to lookup settings. */ + set = _set; + } else { + set = settings_get_or_fatal(event, + &auth_userdb_setting_parser_info); + } auth_userdb = p_new(auth->pool, struct auth_userdb, 1); auth_userdb->auth_set = @@ -200,6 +208,8 @@ auth_userdb_preinit(struct auth *auth, const struct auth_userdb_settings *set) static void auth_userdb_deinit(struct auth_userdb *userdb) { + if (userdb->set != &userdb_dummy_set) + settings_free(userdb->set); settings_free(userdb->auth_set); userdb_deinit(userdb->userdb); }