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) { ...@@ -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")); "-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( shared.roslaveerr = createObject(REDIS_STRING,sdsnew(
"-READONLY You can't write against a read only slave.\r\n")); "-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( shared.oomerr = createObject(REDIS_STRING,sdsnew(
"-OOM command not allowed when used memory > 'maxmemory'.\r\n")); "-OOM command not allowed when used memory > 'maxmemory'.\r\n"));
shared.execaborterr = createObject(REDIS_STRING,sdsnew( shared.execaborterr = createObject(REDIS_STRING,sdsnew(
...@@ -1650,7 +1652,7 @@ int processCommand(redisClient *c) { ...@@ -1650,7 +1652,7 @@ int processCommand(redisClient *c) {
if (server.requirepass && !c->authenticated && c->cmd->proc != authCommand) if (server.requirepass && !c->authenticated && c->cmd->proc != authCommand)
{ {
flagTransaction(c); flagTransaction(c);
addReplyError(c,"operation not permitted"); addReply(c,shared.noautherr);
return REDIS_OK; return REDIS_OK;
} }
......
...@@ -448,7 +448,7 @@ struct sharedObjectsStruct { ...@@ -448,7 +448,7 @@ struct sharedObjectsStruct {
*colon, *nullbulk, *nullmultibulk, *queued, *colon, *nullbulk, *nullmultibulk, *queued,
*emptymultibulk, *wrongtypeerr, *nokeyerr, *syntaxerr, *sameobjecterr, *emptymultibulk, *wrongtypeerr, *nokeyerr, *syntaxerr, *sameobjecterr,
*outofrangeerr, *noscripterr, *loadingerr, *slowscripterr, *bgsaveerr, *outofrangeerr, *noscripterr, *loadingerr, *slowscripterr, *bgsaveerr,
*masterdownerr, *roslaveerr, *execaborterr, *masterdownerr, *roslaveerr, *execaborterr, *noautherr,
*oomerr, *plus, *messagebulk, *pmessagebulk, *subscribebulk, *oomerr, *plus, *messagebulk, *pmessagebulk, *subscribebulk,
*unsubscribebulk, *psubscribebulk, *punsubscribebulk, *del, *rpop, *lpop, *unsubscribebulk, *psubscribebulk, *punsubscribebulk, *del, *rpop, *lpop,
*lpush, *lpush,
......
...@@ -84,8 +84,8 @@ proc ping_server {host port} { ...@@ -84,8 +84,8 @@ proc ping_server {host port} {
puts $fd "PING\r\n" puts $fd "PING\r\n"
flush $fd flush $fd
set reply [gets $fd] set reply [gets $fd]
if {[string range $reply 0 4] eq {+PONG} || if {[string range $reply 0 0] eq {+} ||
[string range $reply 0 3] eq {-ERR}} { [string range $reply 0 0] eq {-}} {
set retval 1 set retval 1
} }
close $fd close $fd
......
...@@ -14,7 +14,7 @@ start_server {tags {"auth"} overrides {requirepass foobar}} { ...@@ -14,7 +14,7 @@ start_server {tags {"auth"} overrides {requirepass foobar}} {
test {Arbitrary command gives an error when AUTH is required} { test {Arbitrary command gives an error when AUTH is required} {
catch {r set foo bar} err catch {r set foo bar} err
set _ $err set _ $err
} {ERR*operation not permitted} } {NOAUTH*}
test {AUTH succeeds when the right password is given} { test {AUTH succeeds when the right password is given} {
r auth foobar 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