Allow requirepass config to clear the password (#7899)
This is a compatibility issue with redis 5.0 that was introduced by ACL. Before this commit, setting requirepass to an empty string will result in a server that needs an empty AUTH, unlike redis 5.0 which would accept connections without an AUTH.
This commit is contained in:
parent
37fd3d40ae
commit
19418b6b28
26
src/config.c
26
src/config.c
@ -495,11 +495,16 @@ void loadServerConfigFromString(char *config) {
|
|||||||
* additionally is to remember the cleartext password in this
|
* additionally is to remember the cleartext password in this
|
||||||
* case, for backward compatibility with Redis <= 5. */
|
* case, for backward compatibility with Redis <= 5. */
|
||||||
ACLSetUser(DefaultUser,"resetpass",-1);
|
ACLSetUser(DefaultUser,"resetpass",-1);
|
||||||
sds aclop = sdscatprintf(sdsempty(),">%s",argv[1]);
|
|
||||||
ACLSetUser(DefaultUser,aclop,sdslen(aclop));
|
|
||||||
sdsfree(aclop);
|
|
||||||
sdsfree(server.requirepass);
|
sdsfree(server.requirepass);
|
||||||
server.requirepass = sdsnew(argv[1]);
|
server.requirepass = NULL;
|
||||||
|
if (sdslen(argv[1])) {
|
||||||
|
sds aclop = sdscatprintf(sdsempty(),">%s",argv[1]);
|
||||||
|
ACLSetUser(DefaultUser,aclop,sdslen(aclop));
|
||||||
|
sdsfree(aclop);
|
||||||
|
server.requirepass = sdsnew(argv[1]);
|
||||||
|
} else {
|
||||||
|
ACLSetUser(DefaultUser,"nopass",-1);
|
||||||
|
}
|
||||||
} else if (!strcasecmp(argv[0],"list-max-ziplist-entries") && argc == 2){
|
} else if (!strcasecmp(argv[0],"list-max-ziplist-entries") && argc == 2){
|
||||||
/* DEAD OPTION */
|
/* DEAD OPTION */
|
||||||
} else if (!strcasecmp(argv[0],"list-max-ziplist-value") && argc == 2) {
|
} else if (!strcasecmp(argv[0],"list-max-ziplist-value") && argc == 2) {
|
||||||
@ -717,11 +722,16 @@ void configSetCommand(client *c) {
|
|||||||
* additionally is to remember the cleartext password in this
|
* additionally is to remember the cleartext password in this
|
||||||
* case, for backward compatibility with Redis <= 5. */
|
* case, for backward compatibility with Redis <= 5. */
|
||||||
ACLSetUser(DefaultUser,"resetpass",-1);
|
ACLSetUser(DefaultUser,"resetpass",-1);
|
||||||
sds aclop = sdscatprintf(sdsempty(),">%s",(char*)o->ptr);
|
|
||||||
ACLSetUser(DefaultUser,aclop,sdslen(aclop));
|
|
||||||
sdsfree(aclop);
|
|
||||||
sdsfree(server.requirepass);
|
sdsfree(server.requirepass);
|
||||||
server.requirepass = sdsnew(o->ptr);
|
server.requirepass = NULL;
|
||||||
|
if (sdslen(o->ptr)) {
|
||||||
|
sds aclop = sdscatprintf(sdsempty(),">%s",(char*)o->ptr);
|
||||||
|
ACLSetUser(DefaultUser,aclop,sdslen(aclop));
|
||||||
|
sdsfree(aclop);
|
||||||
|
server.requirepass = sdsnew(o->ptr);
|
||||||
|
} else {
|
||||||
|
ACLSetUser(DefaultUser,"nopass",-1);
|
||||||
|
}
|
||||||
} config_set_special_field("save") {
|
} config_set_special_field("save") {
|
||||||
int vlen, j;
|
int vlen, j;
|
||||||
sds *v = sdssplitlen(o->ptr,sdslen(o->ptr)," ",1,&vlen);
|
sds *v = sdssplitlen(o->ptr,sdslen(o->ptr)," ",1,&vlen);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user