#!/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.
#
# 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
;;
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
do
$locate -d $db /
done | $code $bigrams
+rm -rf $DTMP
#!/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.
#
# 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
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 |
$code $bigrams < $filelist
else
echo "`basename $0`: cannot build locate database" >&2
+ rm -rf $DTMP
exit 1
fi
+rm -rf $DTMP
#!/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.
#
# 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
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
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