diff options
author | kmos <kmos@cvs.openbsd.org> | 2019-08-30 02:49:36 +0000 |
---|---|---|
committer | kmos <kmos@cvs.openbsd.org> | 2019-08-30 02:49:36 +0000 |
commit | 7d7a9d369acaf4f088e8ee491649984c8995ace8 (patch) | |
tree | d1c801cb83c9a2cb12732871012fa94376a626dd | |
parent | 52badb0be0f7d393b23f124c67b158098051a431 (diff) |
locate.updatedb can't update the database unless it is run as root.
It will scan the entire disk before attempting to create the updated
database and then error out.
add a quick check to see if it as running as root and erroring out if
that is not the case.
"Makes sense" deraadt@
-rw-r--r-- | usr.bin/locate/locate/updatedb.sh | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/usr.bin/locate/locate/updatedb.sh b/usr.bin/locate/locate/updatedb.sh index 16e6bc88a69..7af477966e0 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.14 2019/01/17 06:15:44 tedu Exp $ +# $OpenBSD: updatedb.sh,v 1.15 2019/08/30 02:49:35 kmos Exp $ # # Copyright (c) September 1995 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. # All rights reserved. @@ -29,6 +29,11 @@ # updatedb - update locate database for local mounted filesystems # +if [ $( id -u ) != 0 ]; then + echo "$0: must be root" + exit 1 +fi + LOCATE_CONFIG="/etc/locate.rc" if [ -f "$LOCATE_CONFIG" -a -r "$LOCATE_CONFIG" ]; then . $LOCATE_CONFIG |