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
288799e0
Commit
288799e0
authored
Mar 18, 2010
by
antirez
Browse files
Fixed redis-cli auth code
parent
2a1198b4
Changes
2
Show whitespace changes
Inline
Side-by-side
redis-cli.c
View file @
288799e0
...
...
@@ -52,7 +52,7 @@ static struct config {
long
repeat
;
int
dbnum
;
int
interactive
;
char
*
auth
pw
;
char
*
auth
;
}
config
;
struct
redisCommand
{
...
...
@@ -307,27 +307,6 @@ static int selectDb(int fd) {
return
0
;
}
static
int
cliLogin
(
int
fd
)
{
int
retval
=
1
;
sds
cmd
;
char
type
;
if
(
config
.
authpw
[
0
]
!=
'\0'
)
{
cmd
=
sdsempty
();
cmd
=
sdscatprintf
(
cmd
,
"AUTH %s
\r\n
"
,
config
.
authpw
);
anetWrite
(
fd
,
cmd
,
sdslen
(
cmd
));
anetRead
(
fd
,
&
type
,
1
);
if
(
type
==
'+'
)
retval
=
0
;
int
ret2
=
cliReadSingleLineReply
(
fd
,
1
);
if
(
ret2
)
close
(
fd
);
}
else
{
retval
=
0
;
}
return
retval
;
}
static
int
cliSendCommand
(
int
argc
,
char
**
argv
)
{
struct
redisCommand
*
rc
=
lookupCommand
(
argv
[
0
]);
int
fd
,
j
,
retval
=
0
;
...
...
@@ -354,13 +333,6 @@ static int cliSendCommand(int argc, char **argv) {
return
1
;
}
/* Login if necessary */
retval
=
cliLogin
(
fd
);
if
(
retval
)
{
fprintf
(
stderr
,
"Authentication failed
\n
"
);
return
1
;
}
while
(
config
.
repeat
--
)
{
/* Build the command to send */
cmd
=
sdsempty
();
...
...
@@ -429,7 +401,7 @@ static int parseOptions(int argc, char **argv) {
config
.
dbnum
=
atoi
(
argv
[
i
+
1
]);
i
++
;
}
else
if
(
!
strcmp
(
argv
[
i
],
"-a"
)
&&
!
lastarg
)
{
config
.
auth
pw
=
argv
[
i
+
1
];
config
.
auth
=
argv
[
i
+
1
];
i
++
;
}
else
if
(
!
strcmp
(
argv
[
i
],
"-i"
))
{
config
.
interactive
=
1
;
...
...
@@ -497,6 +469,14 @@ static void repl() {
char
*
line
=
buffer
;
char
**
ap
,
*
args
[
max
];
if
(
config
.
auth
!=
NULL
)
{
char
*
authargv
[
2
];
authargv
[
0
]
=
"AUTH"
;
authargv
[
1
]
=
config
.
auth
;
cliSendCommand
(
2
,
convertToSds
(
2
,
authargv
));
}
while
(
prompt
(
line
,
size
))
{
argc
=
0
;
...
...
@@ -528,6 +508,7 @@ int main(int argc, char **argv) {
config
.
repeat
=
1
;
config
.
dbnum
=
0
;
config
.
interactive
=
0
;
config
.
auth
=
NULL
;
firstarg
=
parseOptions
(
argc
,
argv
);
argc
-=
firstarg
;
...
...
test-redis.tcl
View file @
288799e0
...
...
@@ -1763,6 +1763,7 @@ proc main {server port} {
set rank
[
$r
zrank myzset $ele
]
if
{
$rank
!= $index
}
{
set err
"
$ele
RANK is wrong! (
$rank
!=
$index
)"
exit
break
}
}
...
...
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