]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
TMPDIR fixes. Shell portability fixes.
authorTim Rice <tim@multitalents.net>
Thu, 20 Oct 2005 21:42:49 +0000 (21:42 +0000)
committerTim Rice <tim@multitalents.net>
Thu, 20 Oct 2005 21:42:49 +0000 (21:42 +0000)
etc/faxaddmodem.sh.in
etc/faxsetup.sh.in
etc/probemodem.sh.in
util/faxcron.sh.in
util/recvstats.sh.in
util/xferfaxstats.sh.in

index d9f7f353378a37fdf66ad8d2bc99492c59460f12..e4981bb3d46f1e762ff4fef5b666103718b18212 100644 (file)
@@ -101,11 +101,12 @@ if [ "$euid" != "root" ]; then
 fi
 
 # security
-if ! TMPDIR=`mktemp -d /tmp/.faxaddmodem.XXXXXX/`; then
+TMPDIR=`(mktemp -d /tmp/.faxaddmodem.XXXXXX) 2>/dev/null`
+if test X$TMPDIR = X; then
     TMPDIR=/tmp/.faxaddmodem$$
-    umask 077
-    mkdir $TMPDIR || exit 1
 fi
+@RM@ -rf $TMPDIR
+(umask 077 ; mkdir $TMPDIR) || exit 1
 
 SH=$SCRIPT_SH                  # shell for use below
 CPATH=$SPOOL/etc/config                # prefix of configuration file
index e9f2f0d53a1a584d776b9bd580db4d2b9d712abf..51bb81b13f7699a1fb304942bd0d7d5df663b09e 100644 (file)
@@ -885,7 +885,7 @@ if onServer; then
     #
 
     JUNK="etc/setup.tmp"
-    trap "$RM \$JUNK; exit 1" 1 2 15
+    trap "$RM \$JUNK; $RM -r \$TMPDIR; exit 1" 1 2 15
 
     exec 5>etc/setup.tmp
     echo '# Warning, this file was automatically generated by faxsetup' >&5
@@ -2151,7 +2151,13 @@ if onServer; then
        echo "No scheduler config file exists, creating one from scratch."
        ok=prompt                               # prompt for parameters
 
-       PROMPTS=/tmp/faxpr$$
+       TMPDIR=`(mktemp -d /tmp/.faxsetup.XXXXXX) 2>/dev/null`
+       if test x$TMPDIR = x; then
+           TMPDIR=/tmp/.faxsetup$$
+       fi
+       $RM -rf $TMPDIR
+       (umask 077 ; mkdir $TMPDIR) || exit 1
+       PROMPTS=$TMPDIR/faxpr$$
        JUNK="$JUNK $PROMPTS"
        $RM -rf $PROMPTS
 
@@ -2462,5 +2468,6 @@ Note "Done verifying system setup."
 
 if onServer; then
     $RM $JUNK
+    $RM -r $TMPDIR
 fi
 exit 0
index 47feef0da33cb1854334db9c0d0b2aeb8fa7e58d..6386798249283f447981612f6c3982fc627f8f29 100644 (file)
@@ -78,21 +78,19 @@ test -f $SPOOL/etc/setup.cache || {
 . $SPOOL/etc/setup.cache       # common configuration stuff
 . $SPOOL/etc/setup.modem       # modem-specific stuff
 
-SH=$SCRIPT_SH                  # shell for use below
-if ! TMPDIR=`mktemp -d /tmp/.probemodem.XXXXXX`; then
-    TMPDIR=/tmp/.probemodem.sh$$
-    mkdir $TMPDIR || exit 1
+TMPDIR=`(mktemp -d /tmp/.probemodem.XXXXXX) 2>/dev/null`
+if test X$TMPDIR = X; then
+    TMPDIR=/tmp/.probemodem$$
 fi
+@RM@ -fr $TMPDIR
+(umask 077 ; mkdir $TMPDIR) || exit 1
+
+SH=$SCRIPT_SH                  # shell for use below
 OUT=$TMPDIR/probemodem$$       # temp file in which modem output is recorded
 SVR4UULCKN=$LIBEXEC/lockname   # SVR4 UUCP lock name construction program
 ONDELAY=$LIBEXEC/ondelay       # prgm to open devices blocking on carrier
 CAT="$CAT -u"                  # something to do unbuffered reads and writes
 
-# security
-${NOCLOBBER_ON}
-> $OUT || exit 1
-${NOCLOBBER_OFF}
-
 while [ -z "$TTY" -o ! -c /dev/$TTY ]; do
     if [ "$TTY" != "" ]; then
        echo "/dev/$TTY is not a terminal device."
@@ -130,7 +128,7 @@ done
 # Lock the device for later use when deducing the modem type.
 #
 JUNK="$LOCKX $OUT"
-trap "rm -f $JUNK; exit 1" 0 1 2 15
+trap "@RM@ -f $JUNK; @RM@ -fr $TMPDIR; exit 1" 0 1 2 15
 
 LOCKSTR=`expr "         $$" : '.*\(..........\)'`
 # lock the device by all of its names
@@ -272,7 +270,7 @@ while [ -z "$RESULT" ]; do
        echo ""
        echo "Hmm, something seems to be hung, check your modem eh?"
      done)& nagpid=$!
-    trap "rm -f \$JUNK; kill $nagpid \$catpid; exit 1" 0 1 2 15
+    trap "@RM@ -f \$JUNK; @RM@ -fr $TMPDIR; kill $nagpid \$catpid; exit 1" 0 1 2 15
 
     if [ x"$ATCMD" != x"" ]; then
        SendToModem "$ATCMD"
@@ -285,7 +283,7 @@ while [ -z "$RESULT" ]; do
     wait $nagpid               # Really waits its end
     exec 2>&3 3>&-             # Restore stderr
 
-    trap "rm -f \$JUNK; test \"\$catpid\" && kill \$catpid; exit 1" 0 1 2 15
+    trap "@RM@ -f \$JUNK; @RM@ -fr $TMPDIR; test \"\$catpid\" && kill \$catpid; exit 1" 0 1 2 15
     sleep 1
 
     RESULT=`tr -ds '\015' '\012' < $OUT | $SED -n '$p'`
index 6a79d480ea4ee08b3e86ad57ccdeebb84984b2ac..54e3edd66ed86bf9481b8b0419df469827e4ac2b 100644 (file)
@@ -69,10 +69,12 @@ TEE=tee
 UPDATE="date +'%D %H:%M' >$LAST"
 
 # security
-if ! TMPDIR=`mktemp -d /tmp/.faxcron.XXXXXX`; then
-    TMPDIR=/tmp/.faxcron.sh$$
-    mkdir $TMPDIR || exit 1
+TMPDIR=`(mktemp -d /tmp/.faxcron.XXXXXX) 2>/dev/null`
+if test X$TMPDIR = X; then
+    TMPDIR=/tmp/.faxcron$$
 fi
+@RM@ -fr $TMPDIR
+(umask 077 ; mkdir $TMPDIR) || exit 1
 
 JUNK=$TMPDIR/faxjunk$$         # temp file used multiple times
 AWKTMP=$TMPDIR/faxawk$$                # temp file for awk program
index 80552938880578db1554c1a265f7ec2d44625a4b..d4b4a408bde5ba140adde132a805219a35c0381d 100644 (file)
@@ -154,14 +154,14 @@ esac
 #
 # Generate an awk program to process the statistics file.
 #
-if ! TMPDIR=`mktemp -d /tmp/.recvstats.XXXXXX`; then
-    TMPDIR=/tmp/.recvstats.sh$$
-    mkdir $TMPDIR || exit 1
+TMPDIR=`(mktemp -d /tmp/.recvstats.XXXXXX) 2>/dev/null`
+if test X$TMPDIR = X; then
+    TMPDIR=/tmp/.recvstats$$
 fi
-
-tmpAwk=$TMPDIR/faxawk$$                # temp file for awk program
-
-trap "rm -rf $TMPDIR; exit 1" 0 1 2 15
+@RM@ -fr $TMPDIR
+(umask 077 ; mkdir $TMPDIR) || exit 1
+tmpAwk=$TMPDIR/xferfax$$
+trap "@RM@ -f $tmpAwk; @RM@ -fr $TMPDIR; exit 1" 0 1 2 15
 
 ($CAT<<'EOF'
 #
index 4c7d06c8d8f0089b74ca4e956874ca41deb426d2..264366a63c4307de1f1712c1d6f1a5632e984e9d 100644 (file)
@@ -183,15 +183,14 @@ esac
 #
 # Generate an awk program to process the statistics file.
 #
-# security
-if ! TMPDIR=`mktemp -d /tmp/.xferfaxstats.XXXXXX`; then
-    TMPDIR=/tmp/.xferfaxstats.sh$$
-    mkdir $TMPDIR || exit 1
+TMPDIR=`(mktemp -d /tmp/.xferfaxstats.XXXXXX) 2>/dev/null`
+if test X$TMPDIR = X; then
+    TMPDIR=/tmp/.xferfaxstats$$
 fi
-
-tmpAwk=$TMPDIR/faxawk$$                # temp file for awk program
-
-trap "rm -rf $TMPDIR; exit 1" 0 1 2 15
+@RM@ -fr $TMPDIR
+(umask 077 ; mkdir $TMPDIR) || exit 1
+tmpAwk=$TMPDIR/xferfax$$
+trap "@RM@ -fr $TMPDIR; exit 1" 0 1 2 15
 
 ($CAT<<'EOF'
 #