git: 81a48881c631 - main - periodic: Use a deterministic $PATH for periodic.

From: Peter Wemm <peter_at_FreeBSD.org>
Date: Tue, 21 Dec 2021 02:58:59 UTC
The branch main has been updated by peter:

URL: https://cgit.FreeBSD.org/src/commit/?id=81a48881c63149e5fc104e158ed3d71a2ec659a7

commit 81a48881c63149e5fc104e158ed3d71a2ec659a7
Author:     Peter Wemm <peter@FreeBSD.org>
AuthorDate: 2021-12-21 01:08:04 +0000
Commit:     Peter Wemm <peter@FreeBSD.org>
CommitDate: 2021-12-21 02:54:56 +0000

    periodic: Use a deterministic $PATH for periodic.
    
    Various tools can have alternate versions elsewhere, eg: the GNU
    mailutils port (a dependency of emacs*) brings /usr/local/bin/mail.
    Match the preset PATH in /etc/crontab for deterministic path searches
    even when run manually with a different environment.
    
    PR:             259265
    Reported by:    iandstanley@gmail.com
---
 usr.sbin/periodic/periodic.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/usr.sbin/periodic/periodic.sh b/usr.sbin/periodic/periodic.sh
index 84e14e9cfd80..26413c4ab51e 100644
--- a/usr.sbin/periodic/periodic.sh
+++ b/usr.sbin/periodic/periodic.sh
@@ -30,6 +30,10 @@ if [ $# -lt 1 ] ; then
     usage
 fi
 
+# Use a deterministic path to match the preset from /etc/crontab in case
+# periodic is run interactively.
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
+
 # If possible, check the global system configuration file,
 # to see if there are additional dirs to check
 if [ -r /etc/defaults/periodic.conf ]; then