Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 01 Dec 2000 17:52:11 -0500 (EST)
From:      Mike Heffner <mheffner@vt.edu>
To:        Chris Faulhaber <jedgar@fxp.org>
Cc:        FreeBSD-audit <FreeBSD-audit@freebsd.org>
Subject:   Re: manctl(8) tempfile fix
Message-ID:  <XFMail.20001201175211.mheffner@vt.edu>
In-Reply-To: <20001201170620.A20094@earth.causticlabs.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On 01-Dec-2000 Chris Faulhaber wrote:
| > 
| > --- manctl.sh.orig      Fri Dec  1 01:24:35 2000
| > +++ manctl.sh   Fri Dec  1 01:42:39 2000
| > @@ -94,12 +94,13 @@
| >                 else
| >                         if [ $2 != "symbolic" ] ; then
| >                                 echo gunzipping page $pname 1>&2
| > -                               gunzip -c $pname > /tmp/manager.$$
| > +                               temp=`mktemp /tmp/managerXXXXXXXXXX` ||
| > exit 1
|  
|  It might be better with:
|  
|    temp='mktemp -t manager` || exit 1
|  
|  allowing mktemp(1) to use the user's TMPDIR or system's _PATH_TMP instead
|  of hardcoding /tmp...
|  

Alright, I was considering this, but I figured I would leave it how it was,
anyways here's a new patch:


--- manctl.sh.orig      Fri Dec  1 01:24:35 2000
+++ manctl.sh   Fri Dec  1 17:48:47 2000
@@ -94,12 +94,13 @@
                else
                        if [ $2 != "symbolic" ] ; then
                                echo gunzipping page $pname 1>&2
-                               gunzip -c $pname > /tmp/manager.$$
+                               temp=`mktemp -t manager` || exit 1
+                               gunzip -c $pname > $temp
                                chmod u+w $pname
-                               cp /tmp/manager.$$ $pname
+                               cp $temp $pname
                                chmod 444 $pname
                                mv $pname $fname.$sect
-                               rm /tmp/manager.$$
+                               rm -f $temp
                        else
                                # skip symlinks - this can be
                                # a program like expn, which is
@@ -180,11 +181,13 @@
                ln ../$2 $fname
        else
                echo inlining page $fname 1>&2
+               temp=`mktemp -t manager` || exit 1
                cat $fname | \
-               (cd .. ; soelim ) > /tmp/manager.$$
+               (cd .. ; soelim ) > $temp
                chmod u+w $fname
-               cp /tmp/manager.$$ $fname
+               cp $temp $fname
                chmod 444 $fname
+               rm -f $temp
        fi
 }
 
@@ -279,13 +282,14 @@
                else
                        if [ $2 != "symbolic" ] ; then
                                echo gzipping page $pname 1>&2
+                               temp=`mktemp -t manager` || exit 1
                                cat $pname | \
-                               (cd .. ; soelim )| gzip -c -- > /tmp/manager.$$
+                               (cd .. ; soelim )| gzip -c -- > $temp
                                chmod u+w $pname
-                               cp /tmp/manager.$$ $pname
+                               cp $temp $pname
                                chmod 444 $pname
                                mv $pname $pname.gz
-                               rm /tmp/manager.$$
+                               rm -f $temp
                        else
                                # skip symlink - this can be
                                # a program like expn, which is


-- 
  Mike Heffner     <mheffner@vt.edu>
  Blacksburg, VA         ICQ# 882073
  http://my.ispchannel.com/~mheffner


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.20001201175211.mheffner>