mirror of
http://github.com/valkey-io/valkey
synced 2024-11-22 09:17:20 +00:00
Fix authentication for redis-cli on non-interactive mode.
This commit is contained in:
parent
d36c4e97e5
commit
aab055ae1f
25
redis-cli.c
25
redis-cli.c
@ -307,7 +307,7 @@ static int selectDb(int fd) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cliSendCommand(int argc, char **argv) {
|
static int cliSendCommand(int argc, char **argv, int repeat) {
|
||||||
struct redisCommand *rc = lookupCommand(argv[0]);
|
struct redisCommand *rc = lookupCommand(argv[0]);
|
||||||
int fd, j, retval = 0;
|
int fd, j, retval = 0;
|
||||||
int read_forever = 0;
|
int read_forever = 0;
|
||||||
@ -333,7 +333,7 @@ static int cliSendCommand(int argc, char **argv) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(config.repeat--) {
|
while(repeat--) {
|
||||||
/* Build the command to send */
|
/* Build the command to send */
|
||||||
cmd = sdsempty();
|
cmd = sdsempty();
|
||||||
if (rc->flags & REDIS_CMD_MULTIBULK) {
|
if (rc->flags & REDIS_CMD_MULTIBULK) {
|
||||||
@ -469,14 +469,6 @@ static void repl() {
|
|||||||
char *line = buffer;
|
char *line = buffer;
|
||||||
char **ap, *args[max];
|
char **ap, *args[max];
|
||||||
|
|
||||||
if (config.auth != NULL) {
|
|
||||||
char *authargv[2];
|
|
||||||
|
|
||||||
authargv[0] = "AUTH";
|
|
||||||
authargv[1] = config.auth;
|
|
||||||
cliSendCommand(2, convertToSds(2, authargv));
|
|
||||||
}
|
|
||||||
|
|
||||||
while (prompt(line, size)) {
|
while (prompt(line, size)) {
|
||||||
argc = 0;
|
argc = 0;
|
||||||
|
|
||||||
@ -490,8 +482,7 @@ static void repl() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config.repeat = 1;
|
cliSendCommand(argc, convertToSds(argc, args), 1);
|
||||||
cliSendCommand(argc, convertToSds(argc, args));
|
|
||||||
line = buffer;
|
line = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -514,6 +505,14 @@ int main(int argc, char **argv) {
|
|||||||
argc -= firstarg;
|
argc -= firstarg;
|
||||||
argv += firstarg;
|
argv += firstarg;
|
||||||
|
|
||||||
|
if (config.auth != NULL) {
|
||||||
|
char *authargv[2];
|
||||||
|
|
||||||
|
authargv[0] = "AUTH";
|
||||||
|
authargv[1] = config.auth;
|
||||||
|
cliSendCommand(2, convertToSds(2, authargv), 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (argc == 0 || config.interactive == 1) repl();
|
if (argc == 0 || config.interactive == 1) repl();
|
||||||
|
|
||||||
argvcopy = convertToSds(argc, argv);
|
argvcopy = convertToSds(argc, argv);
|
||||||
@ -527,5 +526,5 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cliSendCommand(argc, argvcopy);
|
return cliSendCommand(argc, argvcopy, config.repeat);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user