git: 097458ac665d - main - freebsd-update: Error for -b basedir without UNAME_r set

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Wed, 11 Feb 2026 15:45:52 UTC
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=097458ac665db732cc91a22279da4cc14f694da2

commit 097458ac665db732cc91a22279da4cc14f694da2
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2024-12-10 13:47:34 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2026-02-11 15:44:45 +0000

    freebsd-update: Error for -b basedir without UNAME_r set
    
    freebsd-update sets the currently running release from UNAME -r, which
    can be overridden via the --currently-running commandline option (or by
    setting UNAME_r in the environment).  This may be invalid if -b is used
    to specify a basedir other than /, so error out if -b is specified
    without setting the currently running version.
    
    PR:             283229
    Reviewed by:    cperciva
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D48016
---
 usr.sbin/freebsd-update/freebsd-update.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/usr.sbin/freebsd-update/freebsd-update.sh b/usr.sbin/freebsd-update/freebsd-update.sh
index aa42af13a302..a58b50e9ca2e 100644
--- a/usr.sbin/freebsd-update/freebsd-update.sh
+++ b/usr.sbin/freebsd-update/freebsd-update.sh
@@ -755,6 +755,10 @@ fetchupgrade_check_params () {
 	esac
 	chmod 700 ${WORKDIR}
 	cd ${WORKDIR} || exit 1
+	if [ "$BASEDIR" != / ] && [ -z "$UNAME_r" ]; then
+		echo "$(basename $0): -b basedir requires --currently-running to be specified."
+		exit 1
+	fi
 
 	# Generate release number.  The s/SECURITY/RELEASE/ bit exists
 	# to provide an upgrade path for FreeBSD Update 1.x users, since