From nobody Tue Jan 21 21:15:31 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Yd0Nh3rcYz5lcBt; Tue, 21 Jan 2025 21:15:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Yd0Nh1c0Hz3qQn; Tue, 21 Jan 2025 21:15:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737494132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nex7ERAPsnqsJ5fY65h0aM4VsjcgjGQ1orxqKkEAhv0=; b=dGSkqNasWImJSC5FkAFCYiTzAVW5qCJkBT4D4IGANkvIlU/fuYyzfohObBXaWxi3c00QTD OGsbZKy9fcNdofDZcnnfu4X/9BcnMlMn0JDoQCMNXOrxLRH/yPs7qP2yotgVMgGmwq/X3C Am6QXy4QVvH3cvRcQtucdzeDPrud2f7iyzukBaoh7JwKFogNyPeeTiLDTiuMAfJ5t9GXZP 4L1huu5OFg+bLEUDDQ+CzTZFaVgO/X7QRz05usEMBM/T7jtrUAtvOE7C1blHw6XK3HUI0U WkzD3IB1l5D+AIIeXKjjJLlGA0hr1NQMvvbTRKqZctSjROvJWq3/kfh4Pf9FAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737494132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nex7ERAPsnqsJ5fY65h0aM4VsjcgjGQ1orxqKkEAhv0=; b=cSR5FjsZGbRFHJe4KYCX3Z3H9eBNkSrgyPzZs98SZ+tKh5vo5vbz2AB5p8vB1pcWW0KgDo cjqBUlQ9kXfD4h6CZ9ERcSWjIUHCswSzXLdN2Uhz59W4QebP6evBBFT4V02t8Ew77cQXcd SA8VXsub55wkEi+6QBdEH1d/oDYfqvShLmS41avQsiMqzsS7TM4YRpEFiQZ6PJC+Ecve/f yG/DUJ2qwvktAOANL7/ufKUqeFCZeSCqODM+Ed6aCtP60ck6c0sehKo/JKNyfZwM7ifzpN Bv8qez4dq6P2nFSj3NNZdauZ/PHOFOtAgCJp1PlsvJyI5kdkcmtr8d/mJvM5lg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1737494132; a=rsa-sha256; cv=none; b=a+uonwTTONSP75721uOdXWKI57bGidv7HmD3IBx9GjMxPNJzND7pw+paiTxiQgEp753XRt slYBTCQ1ufE4hsgZMpDv7/WmgvQ1nJpUeBbPrRgJGov6PLXCZF+E2oofNfMUTiP4ajsXAi jIJoqAmmySY+iiQtL/vqgkqk2Wz9YKd0CxDnEx+O4biBiHEO28r3UlBMcobWJXgQ1Ab9bI 5iAhoGQtbGx7bdQy0PW2P5DPgnZpt201RcSn0AyQXx5HlztUKPLjoJzAlw5k+aQbckwHFq HOr2qj4KXiB8WDYAamxCOUooCfErqy3AOOX/Gc1ON++L9MdqhPBD9/rYbizA9Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Yd0Ng5gSlz7gJ; Tue, 21 Jan 2025 21:15:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50LLFVAu051071; Tue, 21 Jan 2025 21:15:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50LLFVft051068; Tue, 21 Jan 2025 21:15:31 GMT (envelope-from git) Date: Tue, 21 Jan 2025 21:15:31 GMT Message-Id: <202501212115.50LLFVft051068@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Juraj Lutter Subject: git: c8b89c11a118 - main - periodic: set _localbase for periodic scripts from within periodic.conf List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: otis X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c8b89c11a1181e900acb638cfde7a55e92553175 Auto-Submitted: auto-generated The branch main has been updated by otis: URL: https://cgit.FreeBSD.org/src/commit/?id=c8b89c11a1181e900acb638cfde7a55e92553175 commit c8b89c11a1181e900acb638cfde7a55e92553175 Author: Juraj Lutter AuthorDate: 2024-11-08 13:38:19 +0000 Commit: Juraj Lutter CommitDate: 2025-01-21 21:14:41 +0000 periodic: set _localbase for periodic scripts from within periodic.conf Set _localbase variable from within /etc/defaults/periodic.conf for use by periodic scripts. This fixes e5d7100c09, no other functional changes intended. Reported by: gahr, otis Reviewed by: markj, gahr MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D47486 --- usr.sbin/periodic/periodic.conf | 9 +++++++++ usr.sbin/periodic/periodic.sh | 12 ++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/usr.sbin/periodic/periodic.conf b/usr.sbin/periodic/periodic.conf index 3bb34d827564..7066c7b49fd1 100644 --- a/usr.sbin/periodic/periodic.conf +++ b/usr.sbin/periodic/periodic.conf @@ -15,6 +15,15 @@ # # +_set_localbase() { + _localbase=`/sbin/sysctl -n user.localbase 2> /dev/null` + # Set default value of _localbase if not previously set + : ${_localbase:="/usr/local"} +} + +# Set _localbase with fallback to /usr/local +_set_localbase + # What files override these defaults ? periodic_conf_files="/etc/periodic.conf /etc/periodic.conf.local ${_localbase}/etc/periodic.conf" diff --git a/usr.sbin/periodic/periodic.sh b/usr.sbin/periodic/periodic.sh index 09727a840eff..a310f04864da 100644 --- a/usr.sbin/periodic/periodic.sh +++ b/usr.sbin/periodic/periodic.sh @@ -29,14 +29,6 @@ if [ $# -lt 1 ] ; then usage fi -_localbase=`/sbin/sysctl -n user.localbase 2> /dev/null` -# Set default value of _localbase if not previously set -: ${_localbase:="/usr/local"} - -# 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:${_localbase}/sbin:${_localbase}/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 @@ -44,6 +36,10 @@ if [ -r /etc/defaults/periodic.conf ]; then source_periodic_confs 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:${_localbase}/sbin:${_localbase}/bin + host=`hostname` export host