Module: check_mk
Branch: master
Commit: bd1e676262c429c68b1d853494881b648b1cf9a1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bd1e676262c429…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Thu Jul 26 08:13:48 2018 +0200
6384 FIX check_mk_agent.{linux,solaris,openwrt}: Quote command line in asynchronous MRPE
call to prevent globbing and word splitting
Change-Id: I1f2213f118637aa028436e87982dd9d1ef68865c
---
.werks/6384 | 10 ++++++++++
agents/check_mk_agent.linux | 2 +-
agents/check_mk_agent.openwrt | 2 +-
agents/check_mk_agent.solaris | 2 +-
4 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/.werks/6384 b/.werks/6384
new file mode 100644
index 0000000..5d08e2a
--- /dev/null
+++ b/.werks/6384
@@ -0,0 +1,10 @@
+Title: check_mk_agent.linux, check_mk_agent.solaris, check_mk_agent.openwrt: Quote
command line in asynchronous MRPE call to prevent globbing and word splitting
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1532585614
+Class: fix
+
+
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 8b7d8c4..a2ce491 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -264,7 +264,7 @@ function run_cached () {
if [ -z "$USE_CACHEFILE" ] && [ ! -e "$CACHEFILE.new" ] ;
then
# When the command fails, the output is throws away ignored
if [ $mrpe -eq 1 ] ; then
- echo "set -o noclobber ; exec > \"$CACHEFILE.new\" || exit
1 ; run_mrpe $NAME $CMDLINE && mv \"$CACHEFILE.new\"
\"$CACHEFILE\" || rm -f \"$CACHEFILE\"
\"$CACHEFILE.new\"" | nohup /bin/bash >/dev/null 2>&1 &
+ echo "set -o noclobber ; exec > \"$CACHEFILE.new\" || exit
1 ; run_mrpe $NAME \"$CMDLINE\" && mv \"$CACHEFILE.new\"
\"$CACHEFILE\" || rm -f \"$CACHEFILE\"
\"$CACHEFILE.new\"" | nohup /bin/bash >/dev/null 2>&1 &
else
echo "set -o noclobber ; exec > \"$CACHEFILE.new\" || exit
1 ; $CMDLINE && mv \"$CACHEFILE.new\" \"$CACHEFILE\" || rm -f
\"$CACHEFILE\" \"$CACHEFILE.new\"" | nohup /bin/bash
>/dev/null 2>&1 &
fi
diff --git a/agents/check_mk_agent.openwrt b/agents/check_mk_agent.openwrt
index 463e56a..082fab5 100755
--- a/agents/check_mk_agent.openwrt
+++ b/agents/check_mk_agent.openwrt
@@ -167,7 +167,7 @@ run_cached () {
# When the command fails, the output is throws away ignored
if [ $mrpe -eq 1 ] ; then
# TODO: This won't work: run_mrpe is not exported. And do we have bash at
all?
- echo "set -o noclobber ; exec > \"$CACHEFILE.new\" || exit
1 ; run_mrpe $NAME $CMDLINE && mv \"$CACHEFILE.new\"
\"$CACHEFILE\" || rm -f \"$CACHEFILE\"
\"$CACHEFILE.new\"" | nohup bash >/dev/null 2>&1 &
+ echo "set -o noclobber ; exec > \"$CACHEFILE.new\" || exit
1 ; run_mrpe $NAME \"$CMDLINE\" && mv \"$CACHEFILE.new\"
\"$CACHEFILE\" || rm -f \"$CACHEFILE\"
\"$CACHEFILE.new\"" | nohup bash >/dev/null 2>&1 &
else
echo "set -o noclobber ; exec > \"$CACHEFILE.new\" || exit
1 ; $CMDLINE && mv \"$CACHEFILE.new\" \"$CACHEFILE\" || rm -f
\"$CACHEFILE\" \"$CACHEFILE.new\"" | nohup bash >/dev/null
2>&1 &
fi
diff --git a/agents/check_mk_agent.solaris b/agents/check_mk_agent.solaris
index 7afe5b5..a038367 100755
--- a/agents/check_mk_agent.solaris
+++ b/agents/check_mk_agent.solaris
@@ -123,7 +123,7 @@ function run_cached () {
# Cache file outdated and new job not yet running? Start it
if [ -z "$USE_CACHEFILE" ] && [ ! -e "$CACHEFILE.new" ] ;
then
if [ $mrpe -eq 1 ] ; then
- echo "set -o noclobber ; exec > \"$CACHEFILE.new\" || exit
1 ; run_mrpe $NAME $CMDLINE && mv \"$CACHEFILE.new\"
\"$CACHEFILE\" || rm -f \"$CACHEFILE\"
\"$CACHEFILE.new\"" | nohup /usr/bin/bash >/dev/null 2>&1 &
+ echo "set -o noclobber ; exec > \"$CACHEFILE.new\" || exit
1 ; run_mrpe $NAME \"$CMDLINE\" && mv \"$CACHEFILE.new\"
\"$CACHEFILE\" || rm -f \"$CACHEFILE\"
\"$CACHEFILE.new\"" | nohup /usr/bin/bash >/dev/null 2>&1 &
else
echo "set -o noclobber ; exec > \"$CACHEFILE.new\" || exit
1 ; $CMDLINE && mv \"$CACHEFILE.new\" \"$CACHEFILE\" || rm -f
\"$CACHEFILE\" \"$CACHEFILE.new\"" | nohup /usr/bin/bash
>/dev/null 2>&1 &
fi