From owner-freebsd-audit Fri Dec 1 14: 6:13 2000 Delivered-To: freebsd-audit@freebsd.org Received: from peitho.fxp.org (peitho.fxp.org [209.26.95.40]) by hub.freebsd.org (Postfix) with ESMTP id 82D6337B400 for ; Fri, 1 Dec 2000 14:06:08 -0800 (PST) Received: from earth.causticlabs.com (oca-c1s3-18.mfi.net [209.26.94.111]) by peitho.fxp.org (Postfix) with ESMTP id D04A213611; Fri, 1 Dec 2000 17:06:09 -0500 (EST) Received: by earth.causticlabs.com (Postfix, from userid 1000) id DC5CC1F5C; Fri, 1 Dec 2000 17:06:20 -0500 (EST) Date: Fri, 1 Dec 2000 17:06:20 -0500 From: Chris Faulhaber To: Mike Heffner Cc: FreeBSD-audit Subject: Re: manctl(8) tempfile fix Message-ID: <20001201170620.A20094@earth.causticlabs.com> Mail-Followup-To: Chris Faulhaber , Mike Heffner , FreeBSD-audit References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from mheffner@vt.edu on Fri, Dec 01, 2000 at 01:52:23AM -0500 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Fri, Dec 01, 2000 at 01:52:23AM -0500, Mike Heffner wrote: > This patch changes manctl(8) to use mktemp rather than shell pid substitution > for tempfile names. Reviews? > > > --- 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... > + 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 /tmp/managerXXXXXXXXXX` || exit 1 > cat $fname | \ ...see above... > - (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 /tmp/managerXXXXXXXXXX` || exit 1 > cat $pname | \ ...see above... > - (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 > ...otherwise, looks ok -- Chris D. Faulhaber - jedgar@fxp.org - jedgar@FreeBSD.org -------------------------------------------------------- FreeBSD: The Power To Serve - http://www.FreeBSD.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message