Module: kamailio Branch: master Commit: 7f55064f3a2eeee16b9659d3c5c29e531bc92e62 URL: https://github.com/kamailio/kamailio/commit/7f55064f3a2eeee16b9659d3c5c29e53...
Author: Vicente Hernando vhernando@systemonenoc.com Committer: Vicente Hernando vhernando@systemonenoc.com Date: 2015-03-13T14:10:48+01:00
ndb_redis: enable authentication when reconnecting.
---
Modified: modules/ndb_redis/redis_client.c
---
Diff: https://github.com/kamailio/kamailio/commit/7f55064f3a2eeee16b9659d3c5c29e53... Patch: https://github.com/kamailio/kamailio/commit/7f55064f3a2eeee16b9659d3c5c29e53...
---
diff --git a/modules/ndb_redis/redis_client.c b/modules/ndb_redis/redis_client.c index 23cb2cb..0476ed2 100644 --- a/modules/ndb_redis/redis_client.c +++ b/modules/ndb_redis/redis_client.c @@ -249,7 +249,7 @@ redisc_server_t *redisc_get_server(str *name) */ int redisc_reconnect_server(redisc_server_t *rsrv) { - char *addr, *unix_sock_path = NULL; + char *addr, *pass, *unix_sock_path = NULL; unsigned int port, db; param_t *pit = NULL; struct timeval tv; @@ -259,6 +259,7 @@ int redisc_reconnect_server(redisc_server_t *rsrv) addr = "127.0.0.1"; port = 6379; db = 0; + pass = NULL; for (pit = rsrv->attrs; pit; pit=pit->next) { if(pit->name.len==4 && strncmp(pit->name.s, "unix", 4)==0) { @@ -273,6 +274,9 @@ int redisc_reconnect_server(redisc_server_t *rsrv) } else if(pit->name.len==2 && strncmp(pit->name.s, "db", 2)==0) { if(str2int(&pit->body, &db) < 0) db = 0; + } else if(pit->name.len==4 && strncmp(pit->name.s, "pass", 4)==0) { + pass = pit->body.s; + pass[pit->body.len] = '\0'; } } if(rsrv->ctxRedis!=NULL) { @@ -289,6 +293,8 @@ int redisc_reconnect_server(redisc_server_t *rsrv) goto err; if (rsrv->ctxRedis->err) goto err2; + if ((pass != NULL) && redisc_check_auth(rsrv, pass)) + goto err2; if (redisCommandNR(rsrv->ctxRedis, "PING")) goto err2; if (redisCommandNR(rsrv->ctxRedis, "SELECT %i", db))