From: Alexander Moisseev Date: Fri, 10 Apr 2026 11:02:09 +0000 (+0300) Subject: [Fix] Avoid mutating cached redis_params in greylist X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6f7f0158c61ef802ca178d0bea3deae1406f82ad;p=thirdparty%2Frspamd.git [Fix] Avoid mutating cached redis_params in greylist Pass a shallow copy of opts with redis_timeout set before calling parse_redis_server, so the corrected timeout is baked into the cached table. The previous post-assignment mutated the shared cached object, potentially affecting other modules reusing the same Redis config. --- diff --git a/src/plugins/lua/greylist.lua b/src/plugins/lua/greylist.lua index 22aa086f34..d9badcd502 100644 --- a/src/plugins/lua/greylist.lua +++ b/src/plugins/lua/greylist.lua @@ -568,14 +568,17 @@ if opts then whitelist_domains_map = lua_map.rspamd_map_add(N, 'whitelist_domains_url', 'map', 'Greylist whitelist domains map') - redis_params = lua_redis.parse_redis_server(N) + -- Pass opts with redis_timeout instead of the greylisting period (settings.timeout), + -- so lua_redis does not mistake the greylisting period for a Redis connection timeout. + -- redis.greylist.timeout or the global redis.timeout can still override this via + -- enrich_defaults since settings.redis_timeout equals lua_redis's default_timeout (1.0). + local redis_opts = lua_util.shallowcopy(opts) + redis_opts.timeout = settings.redis_timeout + redis_params = lua_redis.parse_redis_server(N, redis_opts) if not redis_params then rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module') rspamd_lua_utils.disable_module(N, "redis") else - -- settings.timeout is the greylisting period, not a Redis connection timeout; - -- override to prevent it from being misused as such by lua_redis - redis_params.timeout = settings.redis_timeout lua_redis.register_prefix(settings.key_prefix .. 'b[a-z0-9]{20}', N, 'Greylisting elements (body hashes)"', { type = 'string',