diff options
author | Martin Schwenke <martin@meltin.net> | 2013-08-21 16:38:17 +1000 |
---|---|---|
committer | Amitay Isaacs <amitay@gmail.com> | 2013-08-22 17:00:20 +1000 |
commit | 6c468c94a2db505be996ae36f35cace612a81f7f (patch) | |
tree | 79a20f6fe805e11c4f0fb498cd617493059c6dda /ctdb/tools | |
parent | cc74417341a31bf0ee71ba97dabff9fb696a197e (diff) | |
download | samba-6c468c94a2db505be996ae36f35cace612a81f7f.tar.gz samba-6c468c94a2db505be996ae36f35cace612a81f7f.tar.xz samba-6c468c94a2db505be996ae36f35cace612a81f7f.zip |
tools/ctdb_diagnostics: Safer temporary file creation
Signed-off-by: Martin Schwenke <martin@meltin.net>
(This used to be ctdb commit 406e1cb1fdd17ddd239774d0228e3657b73ae68f)
Diffstat (limited to 'ctdb/tools')
-rwxr-xr-x | ctdb/tools/ctdb_diagnostics | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/ctdb/tools/ctdb_diagnostics b/ctdb/tools/ctdb_diagnostics index e37ed6b39d..a7cbb222de 100755 --- a/ctdb/tools/ctdb_diagnostics +++ b/ctdb/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 <<EOF @@ -323,5 +327,8 @@ echo "Diagnostics finished with $NUM_ERRORS errors" cat $ERRORS rm -f $ERRORS } + +rm -rf "$tmpdir" + exit $NUM_ERRORS |