--- fax/faxspool.in.orig 2008-12-06 22:30:36.000000000 +0300 +++ fax/faxspool.in 2008-12-06 22:48:40.000000000 +0300 @@ -653,12 +653,12 @@ # # mkdir a directory in $TMP (or /tmp), convert input to G3 in there # -spooldir=${TMP:-/tmp}/$new_seq.$$.`date +%S` +spooldir=`mktemp -d "${TMP:-/tmp}"/"$new_seq.$$".XXXXXXXX` -if ( umask 077 ; mkdir $spooldir ) ; then +if [ $? -eq 0 ]; then $echo "spooling to $spooldir (->$new_seq)..." else - $echo "ERROR: can't create work dir '$spooldir', giving up" >&2 ; exit 6 + $echo "ERROR: can't create work dir inside '${TMP:-/tmp}', giving up" >&2 ; exit 6 fi # @@ -675,9 +675,12 @@ if [ x$file = x- ] then $echo "spooling $file (stdin)..." - trap "rm /tmp/faxsp.$$" 0 - cat - >/tmp/faxsp.$$ - file=/tmp/faxsp.$$ + file=`mktemp "$spooldir/faxsp.XXXXXXXX"` + if [ -z "$file" ]; then + $echo "ERROR: can't create work file, giving up" >&2; exit 6 + fi + trap "rm -f $file" 0 + cat - >"$file" else $echo "spooling $file..." fi @@ -924,7 +927,7 @@ then $echo "\nnothing to do (no cover page, no data)." >&2 cd $FAX_SPOOL_OUT - rmdir $spooldir + rm -rf $spooldir exit 52 fi @@ -965,7 +968,7 @@ # clean up rm $job.q cd .. -rmdir $spooldir +rm -rf $spooldir if [ -z "`find $LAST_RUN -ctime -1 -print 2>/dev/null`" ] then