]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: passdb-bsdauth - Move settings from "args" to individual settings
authorKarl Fleischmann <karl.fleischmann@open-xchange.com>
Wed, 10 Jul 2024 12:03:02 +0000 (14:03 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:13 +0000 (12:34 +0200)
This commit enables bsdauth lookups caching by default while previously
it was necessary to supply a specific argument.

src/auth/passdb-bsdauth.c

index 232cc5486a069c1c7a646c237c10a131c66a5d72..ab4feca89cb0f96ec86d1291c78f6e474e948555 100644 (file)
@@ -14,6 +14,8 @@
 #include <login_cap.h>
 #include <bsd_auth.h>
 
+#define BSDAUTH_CACHE_KEY "%u"
+
 struct passdb_bsdauth_settings {
        pool_t pool;
 };
@@ -24,10 +26,16 @@ static const struct setting_define passdb_bsdauth_setting_defines[] = {
        SETTING_DEFINE_LIST_END,
 };
 
+static const struct setting_keyvalue passdb_bsdauth_settings_keyvalue[] = {
+       { "passdb_bsdauth/passdb_use_worker", "yes"},
+       { NULL, NULL }
+};
+
 const struct setting_parser_info passdb_bsdauth_setting_parser_info = {
        .name = "auth_bsdauth",
 
        .defines = passdb_bsdauth_setting_defines,
+       .default_settings = passdb_bsdauth_settings_keyvalue,
 
        .struct_size = sizeof(struct passdb_bsdauth_settings),
        .pool_offset1 = 1 + offsetof(struct passdb_bsdauth_settings, pool),
@@ -81,23 +89,26 @@ bsdauth_verify_plain(struct auth_request *request, const char *password,
        callback(PASSDB_RESULT_OK, request);
 }
 
-static struct passdb_module *
-bsdauth_preinit(pool_t pool, const char *args)
+static int
+bsdauth_preinit(pool_t pool, struct event *event,
+               struct passdb_module **module_r,
+               const char **error_r)
 {
+       const struct auth_passdb_post_settings *post_set;
        struct passdb_module *module;
-       const char *value;
 
        module = p_new(pool, struct passdb_module, 1);
-       module->default_pass_scheme = "PLAIN"; /* same reason as PAM */
-       module->blocking = TRUE;
-
-       if (strcmp(args, "blocking=no") == 0)
-               module->blocking = FALSE;
-       else if (str_begins(args, "cache_key=", &value))
-               module->default_cache_key = auth_cache_parse_key(pool, value);
-       else if (*args != '\0')
-               i_fatal("passdb bsdauth: Unknown setting: %s", args);
-       return module;
+       if (settings_get(event, &auth_passdb_post_setting_parser_info,
+                        SETTINGS_GET_FLAG_NO_CHECK |
+                        SETTINGS_GET_FLAG_NO_EXPAND,
+                        &post_set, error_r) < 0)
+               return -1;
+       module->default_cache_key = auth_cache_parse_key_and_fields(
+               pool, BSDAUTH_CACHE_KEY, &post_set->fields, "bsdauth");
+
+       settings_free(post_set);
+       *module_r = module;
+       return 0;
 }
 
 static void bsdauth_deinit(struct passdb_module *module ATTR_UNUSED)
@@ -109,7 +120,7 @@ struct passdb_module_interface passdb_bsdauth = {
        .name = "bsdauth",
 
        .fields_supported = TRUE,
-       .preinit_legacy = bsdauth_preinit,
+       .preinit = bsdauth_preinit,
        .deinit = bsdauth_deinit,
        .verify_plain = bsdauth_verify_plain,
 };