Commit dc24a6b1 authored by antirez's avatar antirez
Browse files

Return a specific NOAUTH error if authentication is required.

parent 24f25836
......@@ -1083,6 +1083,8 @@ void createSharedObjects(void) {
"-MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.\r\n"));
shared.roslaveerr = createObject(REDIS_STRING,sdsnew(
"-READONLY You can't write against a read only slave.\r\n"));
shared.noautherr = createObject(REDIS_STRING,sdsnew(
"-NOAUTH Authentication required.\r\n"));
shared.oomerr = createObject(REDIS_STRING,sdsnew(
"-OOM command not allowed when used memory > 'maxmemory'.\r\n"));
shared.execaborterr = createObject(REDIS_STRING,sdsnew(
......@@ -1650,7 +1652,7 @@ int processCommand(redisClient *c) {
if (server.requirepass && !c->authenticated && c->cmd->proc != authCommand)
{
flagTransaction(c);
addReplyError(c,"operation not permitted");
addReply(c,shared.noautherr);
return REDIS_OK;
}
......
......@@ -448,7 +448,7 @@ struct sharedObjectsStruct {
*colon, *nullbulk, *nullmultibulk, *queued,
*emptymultibulk, *wrongtypeerr, *nokeyerr, *syntaxerr, *sameobjecterr,
*outofrangeerr, *noscripterr, *loadingerr, *slowscripterr, *bgsaveerr,
*masterdownerr, *roslaveerr, *execaborterr,
*masterdownerr, *roslaveerr, *execaborterr, *noautherr,
*oomerr, *plus, *messagebulk, *pmessagebulk, *subscribebulk,
*unsubscribebulk, *psubscribebulk, *punsubscribebulk, *del, *rpop, *lpop,
*lpush,
......
......@@ -84,8 +84,8 @@ proc ping_server {host port} {
puts $fd "PING\r\n"
flush $fd
set reply [gets $fd]
if {[string range $reply 0 4] eq {+PONG} ||
[string range $reply 0 3] eq {-ERR}} {
if {[string range $reply 0 0] eq {+} ||
[string range $reply 0 0] eq {-}} {
set retval 1
}
close $fd
......
......@@ -14,7 +14,7 @@ start_server {tags {"auth"} overrides {requirepass foobar}} {
test {Arbitrary command gives an error when AUTH is required} {
catch {r set foo bar} err
set _ $err
} {ERR*operation not permitted}
} {NOAUTH*}
test {AUTH succeeds when the right password is given} {
r auth foobar
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment