]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: passdb/userdb-lua - Refactor to use t_split_key_value_eq()
authorAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 16 May 2023 06:06:01 +0000 (09:06 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 19 May 2023 09:25:44 +0000 (09:25 +0000)
src/auth/passdb-lua.c
src/auth/userdb-lua.c

index 5fbc5927e6dde318ad617cd497c23b1053527bcc..4c676aca25aef8b6a63cad2d81f67a60ec1a2cbc 100644 (file)
@@ -107,16 +107,19 @@ static struct passdb_module *
 passdb_lua_preinit(pool_t pool, const char *args)
 {
        const char *cache_key = DB_LUA_CACHE_KEY;
-       const char *value, *scheme = "PLAIN";
+       const char *scheme = "PLAIN";
        struct dlua_passdb_module *module;
        bool blocking = TRUE;
 
        module = p_new(pool, struct dlua_passdb_module, 1);
        const char *const *fields = t_strsplit_spaces(args, " ");
        while(*fields != NULL) {
-               if (str_begins(*fields, "file=", &value)) {
+               const char *key, *value;
+               if (!t_split_key_value_eq(*fields, &key, &value)) {
+                       i_fatal("Unsupported parameter %s", *fields);
+               } else if (strcmp(key, "file") == 0) {
                         module->file = p_strdup(pool, value);
-               } else if (str_begins(*fields, "blocking=", &value)) {
+               } else if (strcmp(key, "blocking") == 0) {
                        if (strcmp(value, "yes") == 0) {
                                blocking = TRUE;
                        } else if (strcmp(value, "no") == 0) {
@@ -126,12 +129,12 @@ passdb_lua_preinit(pool_t pool, const char *args)
                                        "Field blocking must be yes or no",
                                        value);
                        }
-                } else if (str_begins(*fields, "cache_key=", &value)) {
+                } else if (strcmp(key, "cache_key") == 0) {
                         if (value[0] != '\0')
                                 cache_key = value;
                         else /* explicitly disable auth caching for lua */
                                 cache_key = NULL;
-               } else if (str_begins(*fields, "scheme=", &value)) {
+               } else if (strcmp(key, "scheme") == 0) {
                        scheme = p_strdup(pool, value);
                } else {
                        i_fatal("Unsupported parameter %s", *fields);
index f08755b2cca6d81da01f2ba35369478652a11828..5546c94b66df14d9fa97516f05db0a73fa65232b 100644 (file)
@@ -33,15 +33,18 @@ static struct userdb_module *
 userdb_lua_preinit(pool_t pool, const char *args)
 {
        struct dlua_userdb_module *module;
-       const char *value, *cache_key = DB_LUA_CACHE_KEY;
+       const char *cache_key = DB_LUA_CACHE_KEY;
        bool blocking = TRUE;
 
        module = p_new(pool, struct dlua_userdb_module, 1);
        const char *const *fields = t_strsplit_spaces(args, " ");
        while(*fields != NULL) {
-               if (str_begins(*fields, "file=", &value))
-                       module->file = p_strdup(pool, value);
-               else if (str_begins(*fields, "blocking=", &value)) {
+               const char *key, *value;
+               if (!t_split_key_value_eq(*fields, &key, &value)) {
+                       i_fatal("Unsupported parameter %s", *fields);
+               } else if (strcmp(key, "file") == 0) {
+                        module->file = p_strdup(pool, value);
+               } else if (strcmp(key, "blocking") == 0) {
                        if (strcmp(value, "yes") == 0) {
                                blocking = TRUE;
                        } else if (strcmp(value, "no") == 0) {
@@ -51,11 +54,11 @@ userdb_lua_preinit(pool_t pool, const char *args)
                                        "Field blocking must be yes or no",
                                        value);
                        }
-               } else if (str_begins(*fields, "cache_key=", &value)) {
-                       if (value[0] != '\0')
-                               cache_key = value;
-                       else /* explicitly disable auth caching for lua */
-                               cache_key = NULL;
+                } else if (strcmp(key, "cache_key") == 0) {
+                        if (value[0] != '\0')
+                                cache_key = value;
+                        else /* explicitly disable auth caching for lua */
+                                cache_key = NULL;
                } else {
                        i_fatal("Unsupported parameter %s", *fields);
                }