summaryrefslogtreecommitdiff
path: root/usr.bin/locate
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-09-15 23:38:40 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-09-15 23:38:40 +0000
commitd1898ee5f48d648d2613af874188db02f9e0da8f (patch)
treeeea4a9d0a36be43dccc761e2afd904de3d64d772 /usr.bin/locate
parentabbaf7d4eba9e8eb177694cd56e60145bb6c27df (diff)
kill the race; noticed by bitblt
Diffstat (limited to 'usr.bin/locate')
-rw-r--r--usr.bin/locate/locate/concatdb.sh17
-rw-r--r--usr.bin/locate/locate/mklocatedb.sh19
-rw-r--r--usr.bin/locate/locate/updatedb.sh18
3 files changed, 39 insertions, 15 deletions
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 <wosch@FreeBSD.org>. 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 <wosch@FreeBSD.org>. 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 <wosch@FreeBSD.org>. 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