From: Karl Fleischmann Date: Wed, 10 Jul 2024 12:03:02 +0000 (+0200) Subject: auth: passdb-bsdauth - Move settings from "args" to individual settings X-Git-Tag: 2.4.1~803 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f1073790a24d74ab5c6356a4b8ec1b11bbb2c6d7;p=thirdparty%2Fdovecot%2Fcore.git auth: passdb-bsdauth - Move settings from "args" to individual settings This commit enables bsdauth lookups caching by default while previously it was necessary to supply a specific argument. --- diff --git a/src/auth/passdb-bsdauth.c b/src/auth/passdb-bsdauth.c index 232cc5486a..ab4feca89c 100644 --- a/src/auth/passdb-bsdauth.c +++ b/src/auth/passdb-bsdauth.c @@ -14,6 +14,8 @@ #include #include +#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, };