HomeFreeBSD

locate.updatedb: Explicitly exit from trap code.

Description

locate.updatedb: Explicitly exit from trap code.

When a signal is trapped, the script continues after the trap code has
run, unless the trap code explicitly exits. In the particular case of
locate.updatedb, this is mostly harmless, except that the trap code is
executed twice (once for the signal and once when we reach the end of
the script), but it's still worth fixing.

Furthermore, install the trap as soon as we've created the temporary
directory, to minimize the window during which we can fail to clean up
after ourselves if interrupted.

While here, simplify the empty check at the end and make some minor
style tweaks.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D46475

(cherry picked from commit f62c1f3f8e91c78d402e1db4e518e4899a4ba2b9)

locate.updatedb: Revert to using cat to copy the db.

This script is usually run unprivileged, so install fails to create a
temporary file while copying the finished database. Revert to using
cat, which can overwrite the existing file as it is usually owned by
the same user which is running the script.

Fixes: f62c1f3f8e91
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D46872

(cherry picked from commit 26bd374e72681860af4bf9d639308ad245949460)

Details

Provenance
desAuthored on Aug 29 2024, 3:05 PM
Parents
rG013d817b5393: igc: Add NVM/firmware prints and sysctl
Branches
Unknown
Tags
Unknown