From e63943a4502a8173d395ccd273eebf0787090d9c Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 26 Mar 2009 11:46:14 +0100 Subject: [PATCH] AUTH merged from Brian Hammond fork, reworked a bit to fix minor problems --- TODO | 2 +- redis.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index bb137a8d..6e5317ba 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,7 @@ - Protocol changes as discussed in the Redis group - keys expire - sunion ssub -- write integers in a special way on disk (and on memory?) +- write integers in a special way on disk, use the unused 11|.... length. - compact types for disk storing of short strings (no 4 bytes overhead!) - network layer stresser in test in demo - maxclients directive diff --git a/redis.c b/redis.c index fa62c54c..fb18e090 100644 --- a/redis.c +++ b/redis.c @@ -1099,10 +1099,6 @@ static int processCommand(redisClient *c) { addReplySds(c,sdsnew("-ERR wrong number of arguments\r\n")); resetClient(c); return 1; - } else if (server.requirepass && !c->authenticated && strcmp(c->argv[0]->ptr,"auth")) { - addReplySds(c,sdsnew("-ERR operation not permitted\r\n")); - resetClient(c); - return 1; } else if (cmd->flags & REDIS_CMD_BULK && c->bulklen == -1) { int bulklen = atoi(c->argv[c->argc-1]->ptr); @@ -1131,6 +1127,13 @@ static int processCommand(redisClient *c) { for(j = 1; j < c->argc; j++) c->argv[j] = tryObjectSharing(c->argv[j]); } + /* Check if the user is authenticated */ + if (server.requirepass && !c->authenticated && cmd->proc != authCommand) { + addReplySds(c,sdsnew("-ERR operation not permitted\r\n")); + resetClient(c); + return 1; + } + /* Exec the command */ dirty = server.dirty; cmd->proc(c); -- 2.45.2