From a7373f9201649150f20b0c30b8751a2faba357e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20Gr=C3=B6nlund?= Date: Wed, 10 Aug 2016 22:24:00 +0200 Subject: [PATCH] Low: ping: Avoid temp files in fping_check (bsc#987348) Unfortunately the previous attempt to avoid this issue (commit 7eb958ce4) didn't work since the problem happens only when the output buffer is flushed but the write fails. Since there is no mechanism in the shell to check if a pipe write is successful, this silently fails. In ping_check, there are no temporary files created. It's possible to avoid the temporaries for fping too, but I had to resort to using python. --- extra/resources/ping | 65 +++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/extra/resources/ping b/extra/resources/ping index 76a45a8cdcb..4ddf6bdcfb2 100755 --- a/extra/resources/ping +++ b/extra/resources/ping @@ -241,34 +241,49 @@ fping_check() { 99) ocf_log err "Ambiguous IP versions in host_list: '$OCF_RESKEY_host_list'"; exit $OCF_ERR_CONFIGURED;; esac - active=0 - f_out=`mktemp` - f_err=`mktemp` - if [ ! -f "$f_out" ] || [ ! -f "$f_err" ]; then - ocf_log err "Failed to create temporary files for fping output; is /tmp full?" - exit $OCF_ERR_PERM - fi - - n=$OCF_RESKEY_attempts - timeout=`expr $OCF_RESKEY_timeout \* 1000 / $OCF_RESKEY_attempts` - - cmd="$p_exe -r $OCF_RESKEY_attempts -t $timeout -B 1.0 $OCF_RESKEY_options $OCF_RESKEY_host_list" - $cmd>$f_out 2>$f_err; rc=$? - active=`grep alive $f_out|wc -l` + outp=$(python <