From 17c6e486e1998a199e5757b85607efb82c26f9ce Mon Sep 17 00:00:00 2001 From: Wouter Verhelst Date: Fri, 27 May 2011 17:53:52 +0200 Subject: [PATCH 1/1] use mktemp -d appending a suffix to a safely-created temporary file to do other stuff is not necessarily a good idea. Create a directory safely instead. --- simple_test | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/simple_test b/simple_test index a05a6a5..44191eb 100755 --- a/simple_test +++ b/simple_test @@ -1,9 +1,10 @@ #!/bin/sh # Yes, that's POSIX sh, not bash! -tmpnam=`mktemp` -conffile=${tmpnam}.conf -pidfile=${tmpnam}.pid +tmpdir=`mktemp -d` +conffile=${tmpdir}/nbd.conf +pidfile=${tmpdir}/nbd.pid +tmpnam=${tmpdir}/nbd.dd ulimit -c unlimited @@ -75,13 +76,12 @@ EOF if [ -f ${pidfile} ] then kill `cat ${pidfile}` - rm -f ${pidfile} else kill $PID fi if [ -z "$2" ] then - rm -f $tmpnam ${conffile} + rm -rf $tmpdir fi exit $retval fi @@ -156,13 +156,12 @@ esac if [ -f ${pidfile} ] then kill `cat ${pidfile}` - rm -f ${pidfile} else kill $PID fi if [ -z "$2" ] then - rm -f $tmpnam ${conffile} + rm -rf $tmpdir fi if [ $retval -ne 0 ] then -- 1.7.10.4