git: 094a5146dff4 - stable/14 - freebsd-update: refuse to operate on a pkgbase system
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 12 Nov 2024 13:41:24 UTC
The branch stable/14 has been updated by emaste:
URL: https://cgit.FreeBSD.org/src/commit/?id=094a5146dff465622640cd2ec40a13451a0e6598
commit 094a5146dff465622640cd2ec40a13451a0e6598
Author: Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2024-10-30 19:15:13 +0000
Commit: Ed Maste <emaste@FreeBSD.org>
CommitDate: 2024-11-12 13:40:05 +0000
freebsd-update: refuse to operate on a pkgbase system
FreeBSD-update is not compatible with packaged base.
PR: 282252
Reviewed by: bapt, markj (earlier)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47341
(cherry picked from commit cf1aba2857c1ec59c9a34d363cb18a61ffa34a10)
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
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47378
(cherry picked from commit 856e158dc4aa5e43f0f15fcd3089fc0d71861b0e)
---
usr.sbin/freebsd-update/freebsd-update.sh | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/usr.sbin/freebsd-update/freebsd-update.sh b/usr.sbin/freebsd-update/freebsd-update.sh
index 77b12a3756c2..f575f89bcf82 100644
--- a/usr.sbin/freebsd-update/freebsd-update.sh
+++ b/usr.sbin/freebsd-update/freebsd-update.sh
@@ -1046,6 +1046,26 @@ IDS_check_params () {
fetch_setup_verboselevel
}
+# Packaged base and freebsd-update are incompatible. Exit with an error if
+# packaged base is in use.
+check_pkgbase()
+{
+ # Packaged base requires that pkg is bootstrapped.
+ if ! pkg -c ${BASEDIR} -N >/dev/null 2>/dev/null; then
+ return
+ fi
+ # 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 <<EOF
+freebsd-update is incompatible with the use of packaged base. Please see
+https://wiki.freebsd.org/PkgBase for more information.
+EOF
+ exit 1
+}
+
#### Core functionality -- the actual work gets done here
# Use an SRV query to pick a server. If the SRV query doesn't provide
@@ -3541,6 +3561,9 @@ export LC_ALL=C
# Clear environment variables that may affect operation of tools that we use.
unset GREP_OPTIONS
+# Disallow use with packaged base.
+check_pkgbase
+
get_params $@
for COMMAND in ${COMMANDS}; do
cmd_${COMMAND}