diff options
author | sfan5 <sfan5@live.de> | 2017-03-11 21:39:32 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2017-03-11 21:39:32 +0100 |
commit | f83d8687a7cd15dac61fd257d358eb42337d48e0 (patch) | |
tree | f6c2deb91fdd826b79100389d6b43d099b768cfc /src | |
parent | d34f149bdc4f72db904d948413fa6b3f649dca7b (diff) | |
download | minetest-f83d8687a7cd15dac61fd257d358eb42337d48e0.tar.gz minetest-f83d8687a7cd15dac61fd257d358eb42337d48e0.tar.bz2 minetest-f83d8687a7cd15dac61fd257d358eb42337d48e0.zip |
database-redis: Support password authentication
Diffstat (limited to 'src')
-rw-r--r-- | src/database-redis.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/database-redis.cpp b/src/database-redis.cpp index 3df186944..93e6717fa 100644 --- a/src/database-redis.cpp +++ b/src/database-redis.cpp @@ -53,6 +53,18 @@ Database_Redis::Database_Redis(Settings &conf) redisFree(ctx); throw DatabaseException(err); } + if (conf.exists("redis_password")) { + tmp = conf.get("redis_password"); + redisReply *reply = static_cast<redisReply *>(redisCommand(ctx, "AUTH %s", tmp.c_str())); + if (!reply) + throw DatabaseException("Redis authentication failed"); + if (reply->type == REDIS_REPLY_ERROR) { + std::string err = "Redis authentication failed: " + std::string(reply->str, reply->len); + freeReplyObject(reply); + throw DatabaseException(err); + } + freeReplyObject(reply); + } } Database_Redis::~Database_Redis() |