]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix parsing of the per-user script
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 20 Nov 2017 07:36:23 +0000 (07:36 +0000)
committerAndrew Lewis <nerf@judo.za.org>
Wed, 24 Jan 2018 10:02:47 +0000 (12:02 +0200)
Issue: #1843
MFH: rspamd-1.6

src/libstat/backends/redis_backend.c

index d634d44481b15381e8079aa5254b54c718a96cbe..b01c2d3d2c70fe383de9409ed75a0f27b6f213af 100644 (file)
@@ -1105,8 +1105,7 @@ rspamd_redis_try_ucl (struct redis_stat_ctx *backend,
                struct rspamd_config *cfg,
                const gchar *symbol)
 {
-       const ucl_object_t *elt, *relt, *users_enabled;
-       const gchar *lua_script;
+       const ucl_object_t *elt, *relt;
 
        elt = ucl_object_lookup_any (obj, "read_servers", "servers", NULL);
 
@@ -1147,6 +1146,33 @@ rspamd_redis_try_ucl (struct redis_stat_ctx *backend,
                }
        }
 
+       elt = ucl_object_lookup_any (obj, "db", "database", "dbname", NULL);
+       if (elt) {
+               backend->dbname = ucl_object_tostring (elt);
+       }
+       else {
+               backend->dbname = NULL;
+       }
+
+       elt = ucl_object_lookup (obj, "password");
+       if (elt) {
+               backend->password = ucl_object_tostring (elt);
+       }
+       else {
+               backend->password = NULL;
+       }
+
+       return TRUE;
+}
+
+static void
+rspamd_redis_parse_classifier_opts (struct redis_stat_ctx *backend,
+               const ucl_object_t *obj,
+               struct rspamd_config *cfg)
+{
+       const gchar *lua_script;
+       const ucl_object_t *elt, *users_enabled;
+
        users_enabled = ucl_object_lookup_any (obj, "per_user",
                        "users_enabled", NULL);
 
@@ -1204,14 +1230,6 @@ rspamd_redis_try_ucl (struct redis_stat_ctx *backend,
                backend->timeout = REDIS_DEFAULT_TIMEOUT;
        }
 
-       elt = ucl_object_lookup (obj, "password");
-       if (elt) {
-               backend->password = ucl_object_tostring (elt);
-       }
-       else {
-               backend->password = NULL;
-       }
-
        elt = ucl_object_lookup (obj, "store_tokens");
        if (elt) {
                backend->store_tokens = ucl_object_toboolean (elt);
@@ -1235,16 +1253,6 @@ rspamd_redis_try_ucl (struct redis_stat_ctx *backend,
        else {
                backend->expiry = 0;
        }
-
-       elt = ucl_object_lookup_any (obj, "db", "database", "dbname", NULL);
-       if (elt) {
-               backend->dbname = ucl_object_tostring (elt);
-       }
-       else {
-               backend->dbname = NULL;
-       }
-
-       return TRUE;
 }
 
 gpointer
@@ -1302,6 +1310,7 @@ rspamd_redis_init (struct rspamd_stat_ctx *ctx,
                return NULL;
        }
 
+       rspamd_redis_parse_classifier_opts (backend, st->classifier->cfg->opts, cfg);
        stf->clcf->flags |= RSPAMD_FLAG_CLASSIFIER_INCREMENTING_BACKEND;
        backend->stcf = stf;