summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-01-03 23:33:51 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-01-03 23:33:51 +0000
commit39d39aa298875366d497ae76d5375b751f7e4f65 (patch)
tree12db138f99002554340c1ae4d1febad31c3a5834
parentb83ea1e88d8cad78992bda4aaf42748dd414b62d (diff)
locate shell scripts now use mktemp(1) and weekly runs updatedb
as bin not nobody to avoid NFS problems.
-rw-r--r--etc/weekly6
-rw-r--r--usr.bin/locate/locate/concatdb.sh17
-rw-r--r--usr.bin/locate/locate/mklocatedb.sh20
-rw-r--r--usr.bin/locate/locate/updatedb.sh18
4 files changed, 17 insertions, 44 deletions
diff --git a/etc/weekly b/etc/weekly
index 0d9f5b78f46..bed9e309f0e 100644
--- a/etc/weekly
+++ b/etc/weekly
@@ -1,6 +1,6 @@
#!/bin/sh -
#
-# $OpenBSD: weekly,v 1.4 1996/12/18 04:32:57 millert Exp $
+# $OpenBSD: weekly,v 1.5 1997/01/03 23:33:50 millert Exp $
#
PATH=/bin:/sbin:/usr/sbin:/usr/bin:/usr/libexec
@@ -59,8 +59,8 @@ echo ""
if [ -f /var/db/locate.database ]; then
echo "Rebuilding locate database:"
chmod 644 /var/db/locate.database
- chown nobody.nobody /var/db/locate.database
- echo /usr/libexec/locate.updatedb | nice -5 su -m nobody 2>/dev/null
+ chown bin /var/db/locate.database
+ echo /usr/libexec/locate.updatedb | nice -5 su -m bin 2>/dev/null
chown root.wheel /var/db/locate.database
else
echo "Not rebuilding locate database; no /var/db/locate.database"
diff --git a/usr.bin/locate/locate/concatdb.sh b/usr.bin/locate/locate/concatdb.sh
index bb66e12c522..3659a1fb7aa 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.3 1996/09/15 23:38:38 deraadt Exp $
+# $OpenBSD: concatdb.sh,v 1.4 1997/01/03 23:33:48 millert 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.3 1996/09/15 23:38:38 deraadt Exp $
+# $Id: concatdb.sh,v 1.4 1997/01/03 23:33:48 millert Exp $
# The directory containing locate subprograms
: ${LIBEXECDIR=/usr/libexec}; export LIBEXECDIR
@@ -58,17 +58,9 @@ case $# in
;;
esac
-DTMP=${TMPDIR=/tmp}/_concatdb$$
-bigrams=$DTMP/bigrams
+bigrams=`mktemp ${TMPDIR=/tmp}/_bigrams.XXXXXX` || exit 1
-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
+trap 'rm -f $bigrams' 0 1 2 3 5 10 15
for db
do
@@ -79,4 +71,3 @@ 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 a410e588f73..37bd7cd59d9 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.3 1996/09/15 23:38:38 deraadt Exp $
+# $OpenBSD: mklocatedb.sh,v 1.4 1997/01/03 23:33:49 millert 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.3 1996/09/15 23:38:38 deraadt Exp $
+# $Id: mklocatedb.sh,v 1.4 1997/01/03 23:33:49 millert Exp $
# The directory containing locate subprograms
@@ -50,7 +50,6 @@ fi
: ${code=locate.code}
: ${sort=sort}
-
sortopt="-u -T $TMPDIR"
sortcmd=$sort
@@ -59,15 +58,10 @@ case X"$1" in
X-nosort|X-presort) sortcmd=cat; sortopt=;shift;;
esac
-DTMP=${TMPDIR=/tmp}/_mklocatedb$$
-bigrams=$DTMP/bigrams
-filelist=$DTMP/list
-
-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
+bigrams=`mktemp ${TMPDIR=/tmp}/_bigrams.XXXXXX` || exit 1
+trap 'rm -f $bigrams' 0 1 2 3 5 10 15
+filelist=`mktemp ${TMPDIR=/tmp}/_filelist.XXXXXX` || exit 1
+trap 'rm -f $bigrams $filelist' 0 1 2 3 5 10 15
if $sortcmd $sortopt > $filelist; then
$bigram < $filelist | $sort -nr |
@@ -75,7 +69,5 @@ 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 11ef1152afd..44869c4af29 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.5 1996/11/30 18:12:51 millert Exp $
+# $OpenBSD: updatedb.sh,v 1.6 1997/01/03 23:33:49 millert 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.5 1996/11/30 18:12:51 millert Exp $
+# $Id: updatedb.sh,v 1.6 1997/01/03 23:33:49 millert Exp $
LOCATE_CONFIG="/etc/locate.rc"
if [ -f "$LOCATE_CONFIG" -a -r "$LOCATE_CONFIG" ]; then
@@ -71,16 +71,8 @@ case X"$PRUNEPATHS" in
done;;
esac
-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
+tmp=`mktemp ${TMPDIR=/tmp}/_updatedb.XXXXXX` || exit 1
+trap 'rm -rf $tmp' 0 1 2 3 5 10 15
# search locally
# echo $find $SEARCHPATHS $excludes -or -print && exit
@@ -90,8 +82,6 @@ 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