summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2020-04-30 10:14:15 +0200
committerantirez <antirez@gmail.com>2020-04-30 10:14:15 +0200
commit058c727282312d641b935d0acdccc31a3591b245 (patch)
treef9d069b6196a088a8fdb3fd76dbc27551c220d4a
parentcec388f208c44c2f636da42258d14c6ba5411faa (diff)
downloadredis-058c727282312d641b935d0acdccc31a3591b245.tar.gz
MIGRATE AUTH2 for ACL support.
-rw-r--r--src/cluster.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/cluster.c b/src/cluster.c
index 49a410d54..d8f83f08d 100644
--- a/src/cluster.c
+++ b/src/cluster.c
@@ -5101,15 +5101,17 @@ void migrateCloseTimedoutSockets(void) {
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:
*
- * MIGRATE host port "" dbid timeout [COPY | REPLACE | AUTH password] KEYS key1
- * key2 ... keyN */
+ * MIGRATE host port "" dbid timeout [COPY | REPLACE | AUTH password |
+ * AUTH2 username password] KEYS key1 key2 ... keyN */
void migrateCommand(client *c) {
migrateCachedSocket *cs;
int copy = 0, replace = 0, j;
+ char *username = NULL;
char *password = NULL;
long timeout;
long dbid;
@@ -5127,7 +5129,7 @@ void migrateCommand(client *c) {
/* Parse additional options */
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")) {
copy = 1;
} else if (!strcasecmp(c->argv[j]->ptr,"replace")) {
@@ -5139,6 +5141,13 @@ void migrateCommand(client *c) {
}
j++;
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")) {
if (sdslen(c->argv[3]->ptr) != 0) {
addReplyError(c,
@@ -5199,8 +5208,13 @@ try_again:
/* Authentication */
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));
+ if (username) {
+ serverAssertWithInfo(c,NULL,rioWriteBulkString(&cmd,username,
+ sdslen(username)));
+ }
serverAssertWithInfo(c,NULL,rioWriteBulkString(&cmd,password,
sdslen(password)));
}