From 1fc8bbff9cefd243725c04890426a28204d7b0d2 Mon Sep 17 00:00:00 2001 From: rl1987 Date: Wed, 6 Feb 2019 10:20:11 +0200 Subject: [PATCH 1/4] Fix two instances of SC2004 in nagios-check-tor-authority --- contrib/dirauth-tools/nagios-check-tor-authority-cert | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/dirauth-tools/nagios-check-tor-authority-cert b/contrib/dirauth-tools/nagios-check-tor-authority-cert index 46dc7284b7..7a60da16f0 100755 --- a/contrib/dirauth-tools/nagios-check-tor-authority-cert +++ b/contrib/dirauth-tools/nagios-check-tor-authority-cert @@ -74,10 +74,10 @@ now=$(date +%s) if [ "$now" -ge "$expiryunix" ]; then echo "CRITICAL: Certificate expired $expirydate (authority $identity)." exit 2 -elif [ "$(( $now + 7*24*60*60 ))" -ge "$expiryunix" ]; then +elif [ "$(( now + 7*24*60*60 ))" -ge "$expiryunix" ]; then echo "CRITICAL: Certificate expires $expirydate (authority $identity)." exit 2 -elif [ "$(( $now + 30*24*60*60 ))" -ge "$expiryunix" ]; then +elif [ "$(( now + 30*24*60*60 ))" -ge "$expiryunix" ]; then echo "WARNING: Certificate expires $expirydate (authority $identity)." exit 1 else From 2649239c620b57cc11c2499ed35fa571af996d18 Mon Sep 17 00:00:00 2001 From: rl1987 Date: Wed, 6 Feb 2019 10:27:16 +0200 Subject: [PATCH 2/4] Use mktemp to fix SC2186; also, fix SC2006. --- contrib/dirauth-tools/nagios-check-tor-authority-cert | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/dirauth-tools/nagios-check-tor-authority-cert b/contrib/dirauth-tools/nagios-check-tor-authority-cert index 7a60da16f0..932a780618 100755 --- a/contrib/dirauth-tools/nagios-check-tor-authority-cert +++ b/contrib/dirauth-tools/nagios-check-tor-authority-cert @@ -49,7 +49,7 @@ DIRSERVERS="$DIRSERVERS 80.190.246.100:80" # gabelmoo DIRSERVERS="$DIRSERVERS 194.109.206.212:80" # dizum DIRSERVERS="$DIRSERVERS 213.73.91.31:80" # dannenberg -TMPFILE="`tempfile`" +TMPFILE=$(mktemp) trap 'rm -f "$TMPFILE"' 0 for dirserver in $DIRSERVERS; do From 7e415ec05a1bb1cf5cda7088f2c27e9202b3b3f1 Mon Sep 17 00:00:00 2001 From: rl1987 Date: Wed, 6 Feb 2019 10:51:54 +0200 Subject: [PATCH 3/4] Fix SC2181 --- contrib/dirauth-tools/nagios-check-tor-authority-cert | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/dirauth-tools/nagios-check-tor-authority-cert b/contrib/dirauth-tools/nagios-check-tor-authority-cert index 932a780618..75ff479a53 100755 --- a/contrib/dirauth-tools/nagios-check-tor-authority-cert +++ b/contrib/dirauth-tools/nagios-check-tor-authority-cert @@ -53,8 +53,8 @@ TMPFILE=$(mktemp) trap 'rm -f "$TMPFILE"' 0 for dirserver in $DIRSERVERS; do - wget -q -O "$TMPFILE" "http://$dirserver/tor/keys/fp/$identity" - if [ "$?" = 0 ]; then + if wget -q -O "$TMPFILE" "http://$dirserver/tor/keys/fp/$identity" + then break else cat /dev/null > "$TMPFILE" From 4e3880607ad2f09711e18429afda1514a2cb7e28 Mon Sep 17 00:00:00 2001 From: rl1987 Date: Wed, 6 Feb 2019 10:53:12 +0200 Subject: [PATCH 4/4] Add changes file --- changes/ticket29071 | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changes/ticket29071 diff --git a/changes/ticket29071 b/changes/ticket29071 new file mode 100644 index 0000000000..0997a8d22f --- /dev/null +++ b/changes/ticket29071 @@ -0,0 +1,3 @@ + o Code simplification and refactoring (shell scripts): + - Fix shellcheck warnings in nagios-check-tor-authority-cert script. + Resolves issue 29071.