Skip to content

Commit

Permalink
db_redis: Fixing global variables
Browse files Browse the repository at this point in the history
Adding module name prefix to global variables to reduce possible conflicts.
  • Loading branch information
joelbax authored and miconda committed Jun 20, 2023
1 parent 52d1959 commit 89c9e4e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/modules/db_redis/db_redis_mod.c
Expand Up @@ -31,9 +31,9 @@

#ifdef WITH_SSL
int db_redis_opt_tls = 0;
char *ca_path = 0;
char *db_redis_ca_path = 0;
#endif
char *db_pass = 0;
char *db_redis_db_pass = 0;

MODULE_VERSION

Expand All @@ -60,9 +60,9 @@ static param_export_t params[] = {
{"verbosity", PARAM_INT, &db_redis_verbosity},
#ifdef WITH_SSL
{"opt_tls", PARAM_INT, &db_redis_opt_tls},
{"ca_path", PARAM_STRING, &ca_path},
{"ca_path", PARAM_STRING, &db_redis_ca_path},
#endif
{"db_pass", PARAM_STRING, &db_pass}, {0, 0, 0}};
{"db_pass", PARAM_STRING, &db_redis_db_pass}, {0, 0, 0}};


struct module_exports exports = {
Expand Down
10 changes: 5 additions & 5 deletions src/modules/db_redis/redis_connection.c
Expand Up @@ -37,9 +37,9 @@ static unsigned int MAX_URL_LENGTH = 1023;
extern int db_redis_verbosity;
#ifdef WITH_SSL
extern int db_redis_opt_tls;
extern char *ca_path;
extern char *db_redis_ca_path;
#endif
extern char *db_pass;
extern char *db_redis_db_pass;

static void print_query(redis_key_t *query)
{
Expand Down Expand Up @@ -164,7 +164,7 @@ int db_redis_connect(km_redis_con_t *con)
if(db_redis_opt_tls != 0) {
/* Create SSL context*/
redisInitOpenSSL();
ssl = redisCreateSSLContext(NULL, ca_path, NULL, NULL, NULL, NULL);
ssl = redisCreateSSLContext(NULL, db_redis_ca_path, NULL, NULL, NULL, NULL);
if(ssl == NULL) {
LM_ERR("Unable to create Redis SSL Context.\n");
goto err;
Expand Down Expand Up @@ -208,7 +208,7 @@ int db_redis_connect(km_redis_con_t *con)
if(db_redis_opt_tls != 0) {
/* Create SSL context*/
redisInitOpenSSL();
ssl = redisCreateSSLContext(NULL, ca_path, NULL, NULL, NULL, NULL);
ssl = redisCreateSSLContext(NULL, db_redis_ca_path, NULL, NULL, NULL, NULL);
if(ssl == NULL) {
LM_ERR("Unable to create Redis SSL Context.\n");
goto err;
Expand Down Expand Up @@ -236,7 +236,7 @@ int db_redis_connect(km_redis_con_t *con)

password = con->id->password;
if(!password) {
password = db_pass;
password = db_redis_db_pass;
}
if(password) {
reply = redisCommand(con->con, "AUTH %s", password);
Expand Down

0 comments on commit 89c9e4e

Please sign in to comment.