From: Markus Valentin Date: Thu, 29 Feb 2024 16:12:19 +0000 (+0100) Subject: auth: db-lua: Introduce auth_lua_settings X-Git-Tag: 2.4.1~934 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58e2fe4289dedf0276bcb5b29fd4fdf75ae47153;p=thirdparty%2Fdovecot%2Fcore.git auth: db-lua: Introduce auth_lua_settings --- diff --git a/src/auth/db-lua.c b/src/auth/db-lua.c index d6962391e9..cba551e1e2 100644 --- a/src/auth/db-lua.c +++ b/src/auth/db-lua.c @@ -17,6 +17,7 @@ #include "passdb-template.h" #include "password-scheme.h" #include "auth-request-var-expand.h" +#include "settings.h" #define AUTH_LUA_PASSDB_INIT "auth_passdb_init" #define AUTH_LUA_PASSDB_LOOKUP "auth_passdb_lookup" @@ -37,6 +38,41 @@ struct auth_lua_userdb_iterate_context { ARRAY_TYPE(const_string) users; }; +#undef DEF +#define DEF(type, name) \ + SETTING_DEFINE_STRUCT_##type(#name, name, struct auth_lua_settings) + +static const struct setting_define auth_lua_setting_defines[] = { + { .type = SET_FILTER_NAME, .key = "passdb_lua", }, + { .type = SET_FILTER_NAME, .key = "userdb_lua", }, + DEF(STRLIST, auth_lua_config), + DEF(STR, auth_lua_file), + + SETTING_DEFINE_LIST_END +}; + +static const struct auth_lua_settings auth_lua_default_settings = { + .auth_lua_file = "", + .auth_lua_config = ARRAY_INIT, +}; + +static const struct setting_keyvalue auth_lua_default_settings_keyvalue[] = { + { "passdb_lua/passdb_use_worker", "yes"}, + { "userdb_lua/userdb_use_worker", "yes"}, + { NULL, NULL } +}; + +const struct setting_parser_info auth_lua_setting_parser_info = { + .name = "auth_lua", + + .defines = auth_lua_setting_defines, + .defaults = &auth_lua_default_settings, + .default_settings = auth_lua_default_settings_keyvalue, + + .struct_size = sizeof(struct auth_lua_settings), + .pool_offset1 = 1 + offsetof(struct auth_lua_settings, pool), +}; + static struct auth_request * auth_lua_check_auth_request(lua_State *L, int arg); diff --git a/src/auth/db-lua.h b/src/auth/db-lua.h index 30993aacdb..277f7e5c6d 100644 --- a/src/auth/db-lua.h +++ b/src/auth/db-lua.h @@ -9,6 +9,14 @@ struct dlua_script; +struct auth_lua_settings { + pool_t pool; + const char *auth_lua_file; + ARRAY_TYPE(const_string) auth_lua_config; +}; + +extern const struct setting_parser_info auth_lua_setting_parser_info; + enum auth_lua_script_type { AUTH_LUA_SCRIPT_TYPE_PASSDB, AUTH_LUA_SCRIPT_TYPE_USERDB,