|
|
b4b3ce |
From 6303448af77d2ed64c7436a84b30cf7fa4941e19 Mon Sep 17 00:00:00 2001
|
|
|
b4b3ce |
From: Michele Baldessari <michele@acksyn.org>
|
|
|
b4b3ce |
Date: Wed, 30 Jan 2019 21:36:17 +0100
|
|
|
b4b3ce |
Subject: [PATCH] redis: Filter warning from stderr when calling 'redis-cli -a'
|
|
|
b4b3ce |
|
|
|
b4b3ce |
In some versions of redis (starting with 4.0.10) we have commits [1] and
|
|
|
b4b3ce |
[2] which add a warning on stderr which will be printed out every single
|
|
|
b4b3ce |
time a monitor operation takes place:
|
|
|
b4b3ce |
|
|
|
b4b3ce |
foo pacemaker-remoted[57563]: notice: redis_monitor_20000:1930:stderr
|
|
|
b4b3ce |
[ Warning: Using a password with '-a' option on the command line interface may not be safe. ]
|
|
|
b4b3ce |
|
|
|
b4b3ce |
Later on commit [3] (merged with 5.0rc4) was merged which added the option
|
|
|
b4b3ce |
'--no-auth-warning' to disable said warning since it broke a bunch of
|
|
|
b4b3ce |
scripts [4]. I tried to forcibly either try the command twice (first
|
|
|
b4b3ce |
with --no-auth-warning and then without in case of errors) but it is
|
|
|
b4b3ce |
impossible to distinguish between error due to missing param and other
|
|
|
b4b3ce |
errors.
|
|
|
b4b3ce |
|
|
|
b4b3ce |
So instead of inspecting the version of the redis-cli tool and do the following:
|
|
|
b4b3ce |
- >= 5.0.0 use --no-auth-warning all the time
|
|
|
b4b3ce |
- >= 4.0.10 & < 5.0.0 filter the problematic line from stderr only
|
|
|
b4b3ce |
- else do it like before
|
|
|
b4b3ce |
|
|
|
b4b3ce |
We simply filter out from stderr the 'Using a password' message
|
|
|
b4b3ce |
unconditionally while making sure we keep stdout just the same.
|
|
|
b4b3ce |
|
|
|
b4b3ce |
Tested on a redis 4.0.10 cluster and confirmed that it is working as
|
|
|
b4b3ce |
intended.
|
|
|
b4b3ce |
|
|
|
b4b3ce |
All this horror and pain is due to the fact that redis does not support
|
|
|
b4b3ce |
any other means to pass a password (we could in theory first connect to
|
|
|
b4b3ce |
the server and then issue an AUTH command, but that seems even more
|
|
|
b4b3ce |
complex and error prone). See [5] for more info (or [6] for extra fun)
|
|
|
b4b3ce |
|
|
|
b4b3ce |
[1] https://github.com/antirez/redis/commit/c082221aefbb2a472c7193dbdbb90900256ce1a2
|
|
|
b4b3ce |
[2] https://github.com/antirez/redis/commit/ef931ef93e909b4f504e8c6fbed350ed70c1c67c
|
|
|
b4b3ce |
[3] https://github.com/antirez/redis/commit/a4ef94d2f71a32f73ce4ebf154580307a144b48f
|
|
|
b4b3ce |
[4] https://github.com/antirez/redis/issues/5073
|
|
|
b4b3ce |
[5] https://github.com/antirez/redis/issues/3483
|
|
|
b4b3ce |
[6] https://github.com/antirez/redis/pull/2413
|
|
|
b4b3ce |
|
|
|
b4b3ce |
Signed-off-by: Michele Baldessari <michele@acksyn.org>
|
|
|
b4b3ce |
---
|
|
|
b4b3ce |
heartbeat/redis.in | 4 +++-
|
|
|
b4b3ce |
1 file changed, 3 insertions(+), 1 deletion(-)
|
|
|
b4b3ce |
|
|
|
b4b3ce |
diff --git a/heartbeat/redis.in b/heartbeat/redis.in
|
|
|
b4b3ce |
index 1dff067e9..e257bcc5e 100644
|
|
|
b4b3ce |
--- a/heartbeat/redis.in
|
|
|
b4b3ce |
+++ b/heartbeat/redis.in
|
|
|
b4b3ce |
@@ -302,7 +302,9 @@ set_score()
|
|
|
b4b3ce |
redis_client() {
|
|
|
b4b3ce |
ocf_log debug "redis_client: '$REDIS_CLIENT' -s '$REDIS_SOCKET' $*"
|
|
|
b4b3ce |
if [ -n "$clientpasswd" ]; then
|
|
|
b4b3ce |
- "$REDIS_CLIENT" -s "$REDIS_SOCKET" -a "$clientpasswd" "$@" | sed 's/\r//'
|
|
|
b4b3ce |
+ # Starting with 4.0.10 there is a warning on stderr when using a pass
|
|
|
b4b3ce |
+ # Once we stop supporting versions < 5.0.0 we can add --no-auth-warning here
|
|
|
b4b3ce |
+ ("$REDIS_CLIENT" -s "$REDIS_SOCKET" -a "$clientpasswd" "$@" 2>&1 >&3 3>&- | grep -v "Using a password" >&2 3>&-) 3>&1 | sed 's/\r//'
|
|
|
b4b3ce |
else
|
|
|
b4b3ce |
"$REDIS_CLIENT" -s "$REDIS_SOCKET" "$@" | sed 's/\r//'
|
|
|
b4b3ce |
fi
|