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
ab52d1f4
Commit
ab52d1f4
authored
Oct 10, 2011
by
antirez
Browse files
Fix for issue #132. Now AUTH raises an error if no server password is configured.
parent
70cb03e1
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/redis.c
View file @
ab52d1f4
...
...
@@ -1249,7 +1249,9 @@ int prepareForShutdown() {
/*================================== Commands =============================== */
void
authCommand
(
redisClient
*
c
)
{
if
(
!
server
.
requirepass
||
!
strcmp
(
c
->
argv
[
1
]
->
ptr
,
server
.
requirepass
))
{
if
(
!
server
.
requirepass
)
{
addReplyError
(
c
,
"Client sent AUTH, but no password is set"
);
}
else
if
(
!
strcmp
(
c
->
argv
[
1
]
->
ptr
,
server
.
requirepass
))
{
c
->
authenticated
=
1
;
addReply
(
c
,
shared
.
ok
);
}
else
{
...
...
tests/unit/auth.tcl
View file @
ab52d1f4
start_server
{
tags
{
"auth"
}}
{
test
{
AUTH fails if there is no password configured server side
}
{
catch
{
r auth foo
}
err
set _ $err
}
{
ERR*no password*
}
}
start_server
{
tags
{
"auth"
}
overrides
{
requirepass foobar
}}
{
test
{
AUTH fails when a wrong password is given
}
{
catch
{
r auth wrong!
}
err
format
$err
set _
$err
}
{
ERR*invalid password
}
test
{
Arbitrary command gives an error when AUTH is required
}
{
catch
{
r set foo bar
}
err
format
$err
set _
$err
}
{
ERR*operation not permitted
}
test
{
AUTH succeeds when the right password is given
}
{
r auth foobar
}
{
OK
}
test
{
Once AUTH succeeded we can actually send commands to the server
}
{
r set foo 100
r incr foo
}
{
101
}
}
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