summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSalvatore Sanfilippo <antirez@gmail.com>2018-06-29 13:32:58 +0200
committerGitHub <noreply@github.com>2018-06-29 13:32:58 +0200
commita4ef94d2f71a32f73ce4ebf154580307a144b48f (patch)
treefa66c39cb16016266117f5078d62a9874ff47ddf
parent5baf50d850e1c58967fe3d2601ea61ee0d7b4ecd (diff)
parent9f1856268c9dfb8ef56f1778aa4ef99f9d504bff (diff)
downloadredis-a4ef94d2f71a32f73ce4ebf154580307a144b48f.tar.gz
Merge pull request #5076 from 0xtonyxia/add-no-auth-warning-option
Add no auth warning option
-rw-r--r--src/redis-cli.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/redis-cli.c b/src/redis-cli.c
index b1ece6250..3e44d2c7c 100644
--- a/src/redis-cli.c
+++ b/src/redis-cli.c
@@ -220,6 +220,7 @@ static struct config {
int last_cmd_type;
int verbose;
clusterManagerCommand cluster_manager_command;
+ int no_auth_warning;
} config;
/* User preferences. */
@@ -1235,8 +1236,9 @@ static int parseOptions(int argc, char **argv) {
config.interval = seconds*1000000;
} else if (!strcmp(argv[i],"-n") && !lastarg) {
config.dbnum = atoi(argv[++i]);
+ } else if (!strcmp(argv[i], "--no-auth-warning")) {
+ config.no_auth_warning = 1;
} else if (!strcmp(argv[i],"-a") && !lastarg) {
- fputs("Warning: Using a password with '-a' option on the command line interface may not be safe.\n", stderr);
config.auth = argv[++i];
} else if (!strcmp(argv[i],"-u") && !lastarg) {
parseRedisUri(argv[++i]);
@@ -1387,6 +1389,12 @@ static int parseOptions(int argc, char **argv) {
fprintf(stderr,"Try %s --help for more information.\n", argv[0]);
exit(1);
}
+
+ if (!config.no_auth_warning && config.auth != NULL) {
+ fputs("Warning: Using a password with '-a' or '-u' option on the command"
+ " line interface may not be safe.\n", stderr);
+ }
+
return i;
}
@@ -1463,9 +1471,14 @@ static void usage(void) {
" --cluster <command> [args...] [opts...]\n"
" Cluster Manager command and arguments (see below).\n"
" --verbose Verbose mode.\n"
+" --no-auth-warning Don't show warning message when using password on command\n"
+" line interface.\n"
" --help Output this help and exit.\n"
" --version Output version and exit.\n"
-"\n"
+"\n",
+ version, REDIS_CLI_DEFAULT_PIPE_TIMEOUT);
+ /* Using another fprintf call to avoid -Woverlength-strings compile warning */
+ fprintf(stderr,
"Cluster Manager Commands:\n"
" Use --cluster help to list all available cluster manager commands.\n"
"\n"
@@ -1482,8 +1495,7 @@ static void usage(void) {
"When no command is given, redis-cli starts in interactive mode.\n"
"Type \"help\" in interactive mode for information on available commands\n"
"and settings.\n"
-"\n",
- version, REDIS_CLI_DEFAULT_PIPE_TIMEOUT);
+"\n");
sdsfree(version);
exit(1);
}
@@ -4855,7 +4867,7 @@ static int clusterManagerCommandRebalance(int argc, char **argv) {
}
/* Calculate the slots balance for each node. It's the number of
* slots the node should lose (if positive) or gain (if negative)
- * in order to be balanced. */
+ * in order to be balanced. */
int threshold_reached = 0, total_balance = 0;
float threshold = config.cluster_manager_command.threshold;
i = 0;
@@ -4867,9 +4879,9 @@ static int clusterManagerCommandRebalance(int argc, char **argv) {
n->weight);
n->balance = n->slots_count - expected;
total_balance += n->balance;
- /* Compute the percentage of difference between the
- * expected number of slots and the real one, to see
- * if it's over the threshold specified by the user. */
+ /* Compute the percentage of difference between the
+ * expected number of slots and the real one, to see
+ * if it's over the threshold specified by the user. */
int over_threshold = 0;
if (threshold > 0) {
if (n->slots_count > 0) {
@@ -6551,6 +6563,7 @@ int main(int argc, char **argv) {
config.enable_ldb_on_eval = 0;
config.last_cmd_type = -1;
config.verbose = 0;
+ config.no_auth_warning = 0;
config.cluster_manager_command.name = NULL;
config.cluster_manager_command.argc = 0;
config.cluster_manager_command.argv = NULL;