MIGRATE AUTH2 for ACL support.
This commit is contained in:
parent
4f61650c3c
commit
c3aa13a46a
@ -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) {
|
|||||||
|
|
||||||
/* 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) {
|
|||||||
}
|
}
|
||||||
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:
|
|||||||
|
|
||||||
/* 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)));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user