[Rspamd-Users] Dynamic per user settings with redis as backend

Achim Lammerts ml-rspamd at syntaxys.de
Sun Nov 17 11:54:26 UTC 2024


Hey list members,

I'm trying to figure out how to manage dynamic user settings with the 
redis backend.

I have read the docs here
https://www.rspamd.com/doc/configuration/settings.html#redis-settings
but it does not work as expected and I could need a little help please.

My /etc/rspamd/rspamd.conf.override:

# Redis settings are configured in a "settings_redis" block
settings_redis {
   # Here we will define our Lua functions
   handlers = {
     # Everything in here is a Lua function with an arbitrary name
my_check_rcpt_domain = <<EOD
return function(task)
   local rcpt = task:get_recipients('smtp');
   if not (rcpt and rcpt[1] and rcpt[1]['domain']) then return end;
   local key = 'setting:' .. rcpt[1]['domain'];
   return key;
end;
EOD;
   }
}

For the test I've shortened the example from the docs, it caused an 
error as I saw in the log file. In the redis db I have set this:

192.168.123.5:6379[7]> get setting:syntaxys.de
"id = "syntaxys_test";apply{TEST = -1.0;}"
or I tried also this
{id = "syntaxys_test";apply{TEST = -1.0;}}

My /etc/rspamd/local.d/redis.conf contains this for the settings in redis:

settings {
     servers = "192.168.123.5:6379";
     timeout = 1s;
     db = "7";
     password = "...";
     }

Now, if I receive a mail I'd expect the symbol "TEST" applied, but it 
isn't. What did I wrong?

I have another static setting, which works well in 
/etc/rspamd/local.d/settings.conf which works as a charme:

authenticated {
     priority = high;
     authenticated = yes;
     apply {
         groups_disabled = ["rbl", "spf"];
         }
     }

2024-11-17 10:30:11 #505753(rspamd_proxy) <8EC118>; lua; 
settings.lua:391: <20241117093011.5097A60717 at debian11-vm.syntaxys.de> 
apply static settings authenticated (id = 1937017268);
authenticated matched; priority high

In the log I can't see anything about the dynamic setting, so I'm not 
sure if it will be matched. How can I debug this?

Many thanks for your help and kind regards
Achim


More information about the Users mailing list