From 856e158dc4aa5e43f0f15fcd3089fc0d71861b0e Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Thu, 31 Oct 2024 22:13:44 -0400 Subject: [PATCH] freebsd-update: improve pkgbase check The previous version used a case-insensitive match (default for -x). The presence of packages like freebsd-git-devtools and freebsd-ftpd would falsely trigger the packaged base check. Instead, just use `pkg which /usr/bin/uname` as a packaged base indication. pkg uses /usr/bin/uname to determine ABI, so we can rely on it existing. If it comes from a package then packaged base is in use. Also, extend the check to all freebsd-update commands. It is easier to just disallow all commands, and easier to test. Reported by: Mark Millard Reviewed by: manu Fixes: cf1aba2857c1 ("freebsd-update: refuse to operate on a pkgbase system") Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D47378 --- usr.sbin/freebsd-update/freebsd-update.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/usr.sbin/freebsd-update/freebsd-update.sh b/usr.sbin/freebsd-update/freebsd-update.sh index 80a8bf28825..ccd98a883dc 100644 --- a/usr.sbin/freebsd-update/freebsd-update.sh +++ b/usr.sbin/freebsd-update/freebsd-update.sh @@ -1107,12 +1107,13 @@ check_pkgbase() if ! pkg -c ${BASEDIR} -N >/dev/null 2>/dev/null; then return fi - # Presence of FreeBSD-* package(s) indicates packaged base. - if ! pkg -c ${BASEDIR} info -q -x '^FreeBSD' 2>/dev/null; then + # uname(1) is used by pkg to determine ABI, so it should exist. + # If it comes from a package then this system uses packaged base. + if ! pkg -c ${BASEDIR} which /usr/bin/uname >/dev/null; then return fi cat <