From 406e1cb1fdd17ddd239774d0228e3657b73ae68f Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Wed, 21 Aug 2013 16:38:17 +1000 Subject: [PATCH] tools/ctdb_diagnostics: Safer temporary file creation Signed-off-by: Martin Schwenke --- tools/ctdb_diagnostics | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/ctdb_diagnostics b/tools/ctdb_diagnostics index e37ed6b3..a7cbb222 100755 --- a/tools/ctdb_diagnostics +++ b/tools/ctdb_diagnostics @@ -130,7 +130,7 @@ show_and_compare_files () { continue 2; } - fstf=/tmp/`basename $f`.node$n + fstf=$tmpdir/`basename $f`.node$n onnode $n cat $f > $fstf 2>&1 echo " ================================" @@ -141,7 +141,7 @@ show_and_compare_files () { first=false else echo "Testing for same config file $f on node $n" - tmpf=/tmp/`basename $f`.node$n + tmpf=$tmpdir/`basename $f`.node$n onnode $n cat $f > $tmpf 2>&1 diff $diff_opts $fstf $tmpf >/dev/null 2>&1 || { error "File $f is different on node $n" @@ -155,7 +155,11 @@ show_and_compare_files () { done } -ERRORS="/tmp/diag_err.$$" +if ! tmpdir=$(mktemp -d) ; then + echo "Unable to create a temporary directory" + exit 1 +fi +ERRORS="${tmpdir}/diag_err" NUM_ERRORS=0 cat <