]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: auth_userdb_preinit() - Lookup settings again after SETTINGS_EVENT_FILTER_NAME...
authorMarkus Valentin <markus.valentin@open-xchange.com>
Mon, 11 Mar 2024 08:11:46 +0000 (09:11 +0100)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:12 +0000 (12:34 +0200)
This makes sure defaults which are set specifically for this userdb
driver are applied correctly.

src/auth/auth-settings.h
src/auth/auth.c

index 2b4b7ecbb341573551c972ef94ca7c0e8e460926..cbaed3546091a5e475c35ea33260f4e87f5d930a 100644 (file)
@@ -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;
index 3c4cb00d2da9e0c4463e6c0224d397027ad396c1..b779189be5caa0cceb75a56100bb2e056c182134 100644 (file)
@@ -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);
 }