Makes sense. Kurt Mosiejczuk <[email protected]> wrote:
> locate.updatedb can't update the database unless it is run as root. > > Annoyingly, it will scan the entire disk before attempting to create the > updated database and then error out. > > This just adds a quick check to see if it as running as root and > erroring out if that is not the case. It will save me time in the > future. Periodically I run locate.updatedb without doas by mistake and > don't realize my mistake until many minutes later when I get an error. > > --Kurt > > Index: updatedb.sh > =================================================================== > RCS file: /cvs/src/usr.bin/locate/locate/updatedb.sh,v > retrieving revision 1.14 > diff -u -p -r1.14 updatedb.sh > --- updatedb.sh 17 Jan 2019 06:15:44 -0000 1.14 > +++ updatedb.sh 30 Aug 2019 00:42:17 -0000 > @@ -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 >
