aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorlaodc <github@laodc.com>2023-08-21 15:45:58 +0700
committerlaodc <github@laodc.com>2023-08-21 15:45:58 +0700
commit75fdc829bacbdc767b20d3f0e40b91215fce14fe (patch)
tree209d8d53e71cd5a92deb69fcb740bb2649bb66ee /src/lua
parent1931487b17059d6c63adf2245c9632384657f89e (diff)
downloadrspamd-75fdc829bacbdc767b20d3f0e40b91215fce14fe.tar.gz
rspamd-75fdc829bacbdc767b20d3f0e40b91215fce14fe.zip
Added support for Redis 6 ACL (username/password)
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_redis.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c
index 2ac5a47b7..1ad3b3d17 100644
--- a/src/lua/lua_redis.c
+++ b/src/lua/lua_redis.c
@@ -110,9 +110,9 @@ struct lua_redis_userdata {
};
#define msg_debug_lua_redis(...) rspamd_conditional_debug_fast(NULL, NULL, \
- rspamd_lua_redis_log_id, "lua_redis", ud->log_tag, \
- G_STRFUNC, \
- __VA_ARGS__)
+ rspamd_lua_redis_log_id, "lua_redis", ud->log_tag, \
+ G_STRFUNC, \
+ __VA_ARGS__)
INIT_LOG_MODULE(lua_redis)
#define LUA_REDIS_SPECIFIC_REPLIED (1 << 0)
@@ -875,7 +875,7 @@ rspamd_lua_redis_prepare_connection(lua_State *L, gint *pcbref, gboolean is_asyn
struct rspamd_lua_ip *addr = NULL;
struct rspamd_task *task = NULL;
const gchar *host = NULL;
- const gchar *password = NULL, *dbname = NULL, *log_tag = NULL;
+ const gchar *username = NULL, *password = NULL, *dbname = NULL, *log_tag = NULL;
gint cbref = -1;
struct rspamd_config *cfg = NULL;
struct rspamd_async_session *session = NULL;
@@ -970,6 +970,13 @@ rspamd_lua_redis_prepare_connection(lua_State *L, gint *pcbref, gboolean is_asyn
}
lua_pop(L, 1);
+ lua_pushstring(L, "username");
+ lua_gettable(L, -2);
+ if (lua_type(L, -1) == LUA_TSTRING) {
+ username = lua_tostring(L, -1);
+ }
+ lua_pop(L, 1);
+
lua_pushstring(L, "password");
lua_gettable(L, -2);
if (lua_type(L, -1) == LUA_TSTRING) {
@@ -1053,7 +1060,7 @@ rspamd_lua_redis_prepare_connection(lua_State *L, gint *pcbref, gboolean is_asyn
if (ret) {
ud->terminated = 0;
ud->ctx = rspamd_redis_pool_connect(ud->pool,
- dbname, password,
+ dbname, username, password,
rspamd_inet_address_to_string(addr->addr),
rspamd_inet_address_get_port(addr->addr));