Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
058c7272
Commit
058c7272
authored
Apr 30, 2020
by
antirez
Browse files
MIGRATE AUTH2 for ACL support.
parent
cec388f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/cluster.c
View file @
058c7272
...
@@ -5101,15 +5101,17 @@ void migrateCloseTimedoutSockets(void) {
...
@@ -5101,15 +5101,17 @@ void migrateCloseTimedoutSockets(void) {
dictReleaseIterator
(
di
);
dictReleaseIterator
(
di
);
}
}
/* MIGRATE host port key dbid timeout [COPY | REPLACE | AUTH password]
/* MIGRATE host port key dbid timeout [COPY | REPLACE | AUTH password |
* AUTH2 username password]
*
*
* On in the multiple keys form:
* On in the multiple keys form:
*
*
* MIGRATE host port "" dbid timeout [COPY | REPLACE | AUTH password
] KEYS key1
* MIGRATE host port "" dbid timeout [COPY | REPLACE | AUTH password
|
* key2 ... keyN */
*
AUTH2 username password] KEYS key1
key2 ... keyN */
void
migrateCommand
(
client
*
c
)
{
void
migrateCommand
(
client
*
c
)
{
migrateCachedSocket
*
cs
;
migrateCachedSocket
*
cs
;
int
copy
=
0
,
replace
=
0
,
j
;
int
copy
=
0
,
replace
=
0
,
j
;
char
*
username
=
NULL
;
char
*
password
=
NULL
;
char
*
password
=
NULL
;
long
timeout
;
long
timeout
;
long
dbid
;
long
dbid
;
...
@@ -5127,7 +5129,7 @@ void migrateCommand(client *c) {
...
@@ -5127,7 +5129,7 @@ void migrateCommand(client *c) {
/* Parse additional options */
/* Parse additional options */
for
(
j
=
6
;
j
<
c
->
argc
;
j
++
)
{
for
(
j
=
6
;
j
<
c
->
argc
;
j
++
)
{
int moreargs =
j <
c->argc-1;
int
moreargs
=
(
c
->
argc
-
1
)
-
j
;
if
(
!
strcasecmp
(
c
->
argv
[
j
]
->
ptr
,
"copy"
))
{
if
(
!
strcasecmp
(
c
->
argv
[
j
]
->
ptr
,
"copy"
))
{
copy
=
1
;
copy
=
1
;
}
else
if
(
!
strcasecmp
(
c
->
argv
[
j
]
->
ptr
,
"replace"
))
{
}
else
if
(
!
strcasecmp
(
c
->
argv
[
j
]
->
ptr
,
"replace"
))
{
...
@@ -5139,6 +5141,13 @@ void migrateCommand(client *c) {
...
@@ -5139,6 +5141,13 @@ void migrateCommand(client *c) {
}
}
j
++
;
j
++
;
password
=
c
->
argv
[
j
]
->
ptr
;
password
=
c
->
argv
[
j
]
->
ptr
;
}
else
if
(
!
strcasecmp
(
c
->
argv
[
j
]
->
ptr
,
"auth2"
))
{
if
(
moreargs
<
2
)
{
addReply
(
c
,
shared
.
syntaxerr
);
return
;
}
username
=
c
->
argv
[
++
j
]
->
ptr
;
password
=
c
->
argv
[
++
j
]
->
ptr
;
}
else
if
(
!
strcasecmp
(
c
->
argv
[
j
]
->
ptr
,
"keys"
))
{
}
else
if
(
!
strcasecmp
(
c
->
argv
[
j
]
->
ptr
,
"keys"
))
{
if
(
sdslen
(
c
->
argv
[
3
]
->
ptr
)
!=
0
)
{
if
(
sdslen
(
c
->
argv
[
3
]
->
ptr
)
!=
0
)
{
addReplyError
(
c
,
addReplyError
(
c
,
...
@@ -5199,8 +5208,13 @@ try_again:
...
@@ -5199,8 +5208,13 @@ try_again:
/* Authentication */
/* Authentication */
if
(
password
)
{
if
(
password
)
{
serverAssertWithInfo(c,NULL,rioWriteBulkCount(&cmd,'*',2));
int
arity
=
username
?
3
:
2
;
serverAssertWithInfo
(
c
,
NULL
,
rioWriteBulkCount
(
&
cmd
,
'*'
,
arity
));
serverAssertWithInfo
(
c
,
NULL
,
rioWriteBulkString
(
&
cmd
,
"AUTH"
,
4
));
serverAssertWithInfo
(
c
,
NULL
,
rioWriteBulkString
(
&
cmd
,
"AUTH"
,
4
));
if
(
username
)
{
serverAssertWithInfo
(
c
,
NULL
,
rioWriteBulkString
(
&
cmd
,
username
,
sdslen
(
username
)));
}
serverAssertWithInfo
(
c
,
NULL
,
rioWriteBulkString
(
&
cmd
,
password
,
serverAssertWithInfo
(
c
,
NULL
,
rioWriteBulkString
(
&
cmd
,
password
,
sdslen
(
password
)));
sdslen
(
password
)));
}
}
...
...
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