Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Dec 2000 15:54:48 -0500
From:      Chris Faulhaber <jedgar@fxp.org>
To:        Warner Losh <imp@village.org>
Cc:        freebsd-audit@FreeBSD.ORG
Subject:   Re: mktemp(1) usage
Message-ID:  <20001212155447.A21073@earth.causticlabs.com>
In-Reply-To: <200012100526.WAA26396@harmony.village.org>; from imp@village.org on Sat, Dec 09, 2000 at 10:26:06PM -0700
References:  <20001209150853.A57045@peitho.fxp.org> <200012100526.WAA26396@harmony.village.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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




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