From: deraadt Date: Sun, 15 Sep 1996 23:38:38 +0000 (+0000) Subject: kill the race; noticed by bitblt X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8ad08c9a92d6efd1954352bd04aa828a3704a8fa;p=openbsd kill the race; noticed by bitblt --- diff --git a/usr.bin/locate/locate/concatdb.sh b/usr.bin/locate/locate/concatdb.sh index 40d4950d5d5..bb66e12c522 100644 --- a/usr.bin/locate/locate/concatdb.sh +++ b/usr.bin/locate/locate/concatdb.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# $OpenBSD: concatdb.sh,v 1.2 1996/09/15 16:50:37 michaels Exp $ +# $OpenBSD: concatdb.sh,v 1.3 1996/09/15 23:38:38 deraadt Exp $ # # Copyright (c) September 1995 Wolfram Schneider . Berlin. # All rights reserved. @@ -32,7 +32,7 @@ # # Sequence of databases is important. # -# $Id: concatdb.sh,v 1.2 1996/09/15 16:50:37 michaels Exp $ +# $Id: concatdb.sh,v 1.3 1996/09/15 23:38:38 deraadt Exp $ # The directory containing locate subprograms : ${LIBEXECDIR=/usr/libexec}; export LIBEXECDIR @@ -58,9 +58,17 @@ case $# in ;; esac +DTMP=${TMPDIR=/tmp}/_concatdb$$ +bigrams=$DTMP/bigrams -bigrams=$TMPDIR/_concatdb$$.bigrams -trap 'rm -f $bigrams' 0 1 2 3 5 10 15 +um=`umask` +umask 022 +if ! mkdir $DTMP ; then + echo failed to create tmp dir $DTMP + exit 1 +fi +umask $um +trap 'rm -rf $DTMP' 0 1 2 3 5 10 15 for db do @@ -71,3 +79,4 @@ for db do $locate -d $db / done | $code $bigrams +rm -rf $DTMP diff --git a/usr.bin/locate/locate/mklocatedb.sh b/usr.bin/locate/locate/mklocatedb.sh index 4f8142bca10..a410e588f73 100644 --- a/usr.bin/locate/locate/mklocatedb.sh +++ b/usr.bin/locate/locate/mklocatedb.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# $OpenBSD: mklocatedb.sh,v 1.2 1996/09/15 16:50:40 michaels Exp $ +# $OpenBSD: mklocatedb.sh,v 1.3 1996/09/15 23:38:38 deraadt Exp $ # # Copyright (c) September 1995 Wolfram Schneider . Berlin. # All rights reserved. @@ -30,7 +30,7 @@ # # usage: mklocatedb [-presort] < filelist > database # -# $Id: mklocatedb.sh,v 1.2 1996/09/15 16:50:40 michaels Exp $ +# $Id: mklocatedb.sh,v 1.3 1996/09/15 23:38:38 deraadt Exp $ # The directory containing locate subprograms @@ -59,12 +59,15 @@ case X"$1" in X-nosort|X-presort) sortcmd=cat; sortopt=;shift;; esac +DTMP=${TMPDIR=/tmp}/_mklocatedb$$ +bigrams=$DTMP/bigrams +filelist=$DTMP/list -bigrams=$TMPDIR/_mklocatedb$$.bigrams -filelist=$TMPDIR/_mklocatedb$$.list - -trap 'rm -f $bigrams $filelist' 0 1 2 3 5 10 15 - +if ! mkdir $DTMP ; then + echo failed to create tmp dir $DTMP + exit 1 +fi +trap 'rm -rf $DTMP' 0 1 2 3 5 10 15 if $sortcmd $sortopt > $filelist; then $bigram < $filelist | $sort -nr | @@ -72,5 +75,7 @@ if $sortcmd $sortopt > $filelist; then $code $bigrams < $filelist else echo "`basename $0`: cannot build locate database" >&2 + rm -rf $DTMP exit 1 fi +rm -rf $DTMP diff --git a/usr.bin/locate/locate/updatedb.sh b/usr.bin/locate/locate/updatedb.sh index ebe9e27ad01..eb76b5f6926 100644 --- a/usr.bin/locate/locate/updatedb.sh +++ b/usr.bin/locate/locate/updatedb.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# $OpenBSD: updatedb.sh,v 1.2 1996/09/15 16:50:41 michaels Exp $ +# $OpenBSD: updatedb.sh,v 1.3 1996/09/15 23:38:39 deraadt Exp $ # # Copyright (c) September 1995 Wolfram Schneider . Berlin. # All rights reserved. @@ -28,7 +28,7 @@ # # updatedb - update locate database for local mounted filesystems # -# $Id: updatedb.sh,v 1.2 1996/09/15 16:50:41 michaels Exp $ +# $Id: updatedb.sh,v 1.3 1996/09/15 23:38:39 deraadt Exp $ LOCATE_CONFIG="/etc/locate.rc" if [ -f "$LOCATE_CONFIG" -a -r "$LOCATE_CONFIG" ]; then @@ -70,8 +70,16 @@ case X"$PRUNEPATHS" in done;; esac -tmp=${TMPDIR=/tmp}/_updatedb$$ -trap 'rm -f $tmp' 0 1 2 3 5 10 15 +um=`umask` +umask 022 +DTMP=${TMPDIR=/tmp}/_updatedb$$ +tmp=$DTMP/updatedb +if ! mkdir $DTMP ; then + echo failed to create tmp dir $DTMP + exit 1 +fi +umask $um +trap 'rm -rf $DTMP' 0 1 2 3 5 10 15 # search locally # echo $find $SEARCHPATHS $excludes -or -print && exit @@ -81,6 +89,8 @@ then case X"`$find $tmp -size -257c -print`" in X) cat $tmp > $FCODES;; *) echo "updatedb: locate database $tmp is empty" + rm -rf $DTMP exit 1 esac fi +rm -rf $DTMP