From owner-freebsd-audit Tue Dec 12 12:54:10 2000 From owner-freebsd-audit@FreeBSD.ORG Tue Dec 12 12:54:07 2000 Return-Path: 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 9148E37B400 for ; Tue, 12 Dec 2000 12:54:06 -0800 (PST) Received: from earth.causticlabs.com (oca-c1s6-34.mfi.net [209.26.31.27]) by peitho.fxp.org (Postfix) with ESMTP id E45E81360E; Tue, 12 Dec 2000 15:54:05 -0500 (EST) Received: by earth.causticlabs.com (Postfix, from userid 1000) id 235151F23; Tue, 12 Dec 2000 15:54:48 -0500 (EST) Date: Tue, 12 Dec 2000 15:54:48 -0500 From: Chris Faulhaber To: Warner Losh Cc: freebsd-audit@FreeBSD.ORG Subject: Re: mktemp(1) usage Message-ID: <20001212155447.A21073@earth.causticlabs.com> Mail-Followup-To: Chris Faulhaber , Warner Losh , freebsd-audit@FreeBSD.ORG References: <20001209150853.A57045@peitho.fxp.org> <200012100526.WAA26396@harmony.village.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200012100526.WAA26396@harmony.village.org>; from imp@village.org on Sat, Dec 09, 2000 at 10:26:06PM -0700 Sender: jedgar@earth.causticlabs.com Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sat, Dec 09, 2000 at 10:26:06PM -0700, Warner Losh wrote: > In message <20001209150853.A57045@peitho.fxp.org> Chris Faulhaber writes: > : Would it be more appropriate for scripts such as periodic(8) to > : call mktemp(1) using the -t flag. In addition to using TMPDIR, > : this allows the use of the system's _PATH_TMP instead of > : hardcoding /tmp. > > I think so. > The following takes care of the few mktemp(1) uses in the tree. -- Chris D. Faulhaber - jedgar@fxp.org - jedgar@FreeBSD.org -------------------------------------------------------- FreeBSD: The Power To Serve - http://www.FreeBSD.org Index: etc/rc =================================================================== RCS file: /home/ncvs/src/etc/rc,v retrieving revision 1.240 diff -u -r1.240 rc --- etc/rc 2000/11/21 04:21:54 1.240 +++ etc/rc 2000/12/12 20:53:06 @@ -589,7 +589,7 @@ [Nn][Oo] | '') ;; *) - if T=`mktemp /tmp/_motd.XXXXXX`; then + if T=`mktemp -t _motd`; then uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T} awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T} cmp -s ${T} /etc/motd || { Index: usr.bin/locate/locate/concatdb.sh =================================================================== RCS file: /home/ncvs/src/usr.bin/locate/locate/concatdb.sh,v retrieving revision 1.10 diff -u -r1.10 concatdb.sh --- usr.bin/locate/locate/concatdb.sh 2000/01/12 08:01:00 1.10 +++ usr.bin/locate/locate/concatdb.sh 2000/12/12 20:53:06 @@ -56,7 +56,7 @@ esac -bigrams=`mktemp ${TMPDIR=/tmp}/_bigrams.XXXXXXXXXX` || exit 1 +bigrams=`mktemp -t _bigrams` || exit 1 trap 'rm -f $bigrams' 0 1 2 3 5 10 15 for db Index: usr.bin/locate/locate/mklocatedb.sh =================================================================== RCS file: /home/ncvs/src/usr.bin/locate/locate/mklocatedb.sh,v retrieving revision 1.10 diff -u -r1.10 mklocatedb.sh --- usr.bin/locate/locate/mklocatedb.sh 2000/01/12 08:01:00 1.10 +++ usr.bin/locate/locate/mklocatedb.sh 2000/12/12 20:53:06 @@ -39,7 +39,7 @@ : ${TMPDIR:=/tmp}; export TMPDIR test -d "$TMPDIR" || TMPDIR=/tmp -if ! TMPDIR=`mktemp -d $TMPDIR/mklocateXXXXXXXXXX`; then +if ! TMPDIR=`mktemp -d -t mklocate`; then exit 1 fi Index: usr.bin/locate/locate/updatedb.sh =================================================================== RCS file: /home/ncvs/src/usr.bin/locate/locate/updatedb.sh,v retrieving revision 1.17 diff -u -r1.17 updatedb.sh --- usr.bin/locate/locate/updatedb.sh 2000/01/12 08:01:01 1.17 +++ usr.bin/locate/locate/updatedb.sh 2000/12/12 20:53:06 @@ -36,7 +36,7 @@ # The directory containing locate subprograms : ${LIBEXECDIR:=/usr/libexec}; export LIBEXECDIR : ${TMPDIR:=/tmp}; export TMPDIR -if ! TMPDIR=`mktemp -d $TMPDIR/locateXXXXXXXXXX`; then +if ! TMPDIR=`mktemp -d -t locate`; then exit 1 fi Index: usr.sbin/periodic/periodic.sh =================================================================== RCS file: /home/ncvs/src/usr.sbin/periodic/periodic.sh,v retrieving revision 1.19 diff -u -r1.19 periodic.sh --- usr.sbin/periodic/periodic.sh 2000/11/26 03:37:34 1.19 +++ usr.sbin/periodic/periodic.sh 2000/12/12 20:53:06 @@ -27,7 +27,7 @@ host=`hostname` export host -tmp_output=`mktemp ${TMPDIR:-/tmp}/periodic.XXXXXXXXXX` +tmp_output=`mktemp -t periodic` # Execute each executable file in the directory list. If the x bit is not # set, assume the user didn't really want us to muck with it (it's a To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message