mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
It is now possible to use authentication and DB selection options at the same time in redis-cli (Issue 298)
This commit is contained in:
parent
e0e1c19520
commit
93b2a7718e
@ -478,10 +478,16 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
if (config.auth != NULL) {
|
if (config.auth != NULL) {
|
||||||
char *authargv[2];
|
char *authargv[2];
|
||||||
|
int dbnum = config.dbnum;
|
||||||
|
|
||||||
|
/* We need to save the real configured database number and set it to
|
||||||
|
* zero here, otherwise cliSendCommand() will try to perform the
|
||||||
|
* SELECT command before the authentication, and it will fail. */
|
||||||
|
config.dbnum = 0;
|
||||||
authargv[0] = "AUTH";
|
authargv[0] = "AUTH";
|
||||||
authargv[1] = config.auth;
|
authargv[1] = config.auth;
|
||||||
cliSendCommand(2, convertToSds(2, authargv), 1);
|
cliSendCommand(2, convertToSds(2, authargv), 1);
|
||||||
|
config.dbnum = dbnum; /* restore the right DB number */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start interactive mode when no command is provided */
|
/* Start interactive mode when no command is provided */
|
||||||
|
Loading…
Reference in New Issue
Block a user