[SENTINEL] reset sentinel-user/pass to NULL when user config with empty string (#8958)

This commit is contained in:
Wen Hui 2021-05-23 07:31:01 -04:00 committed by GitHub
parent a319327ffb
commit ae6f58690b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3161,11 +3161,13 @@ void sentinelConfigSetCommand(client *c) {
sentinel.announce_port = numval;
} else if (!strcasecmp(o->ptr, "sentinel-user")) {
sdsfree(sentinel.sentinel_auth_user);
sentinel.sentinel_auth_user = sdsnew(val->ptr);
sentinel.sentinel_auth_user = sdslen(val->ptr) == 0 ?
sdsdup(val->ptr) : NULL;
drop_conns = 1;
} else if (!strcasecmp(o->ptr, "sentinel-pass")) {
sdsfree(sentinel.sentinel_auth_pass);
sentinel.sentinel_auth_pass = sdsnew(val->ptr);
sentinel.sentinel_auth_pass = sdslen(val->ptr) == 0 ?
sdsdup(val->ptr) : NULL;
drop_conns = 1;
} else {
addReplyErrorFormat(c, "Invalid argument '%s' to SENTINEL CONFIG SET",