Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
dc24a6b1
Commit
dc24a6b1
authored
Feb 12, 2013
by
antirez
Browse files
Return a specific NOAUTH error if authentication is required.
parent
24f25836
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/redis.c
View file @
dc24a6b1
...
...
@@ -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
);
addReply
Error
(
c
,
"operation not permitted"
);
addReply
(
c
,
shared
.
noautherr
);
return
REDIS_OK
;
}
...
...
src/redis.h
View file @
dc24a6b1
...
...
@@ -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
,
...
...
tests/support/server.tcl
View file @
dc24a6b1
...
...
@@ -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
...
...
tests/unit/auth.tcl
View file @
dc24a6b1
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment