From nobody Sat Nov 02 19:24:44 2024 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 4Xgnjm2Yzwz5cYnZ; Sat, 02 Nov 2024 19:24:44 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xgnjm1zngz4syb; Sat, 2 Nov 2024 19:24:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730575484; 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=t9A5RgRzpu7YIr9wni7dIMk6QlBtv7ETvZc9cuq765I=; b=VhD/7g6LhNnKnQXH6MRVSh+ofgYk+HsQwtI/TCRk+WwAXHtL2VDMUmyfgHp34FDPWThY7g WGD3GPPgFB7chczlsAlQWPuH8xfxwNtOs1KXT4R3+PD5UDsLXgDSY2eYXfNNJIkRtjsMIo ZqclDzG1KGqlLeyjnD6zxFY1HldXiudj2wmGt72GJ4PO/ozQzlm/8rV3oOSHjfJlBdKmSf EIQy4Us6mvV/UsJcugJuzwDSnxc3Ft0ATrVXe9n6d7BNh2g28XH5bn0n5WsIf0WHXY7Tco nwQow1l+XlnUEOKln36UzjNiq97iPxDZP9Dl7FOSUo0h2dssr94wkfabKXL7OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730575484; 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=t9A5RgRzpu7YIr9wni7dIMk6QlBtv7ETvZc9cuq765I=; b=Aqpiuq3Rqj1PkKIr8H3I3g5c4/FQxTmQqgYKIYHz5PBeTQehLiaB2XxnnA5TvENR1fg/mC 6PKhns5djwZXTP5cNgkj077XXANbd3ASDRy0eDgHmEt7AJVgzixKmdvgxSzzf05Fup97ty 6ctvT8JUMdrV7uTkiTdQPwQ//AjkHgOyXZC8yj6ycnIXyVPAKhIvbin6QOIuWqobX88UyD /smWsk0iQccjOn49qbFDuEyEuJde5qaXKwLrqTquPyjrXkj4GcP8KvZLd0G3m3nr2JxUqx LYVqWlWaNBOSFGCLIS1tP4KHjQR4LcpOoIrBbg7wm1r15j3IBCz3oWs8QhaN8g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730575484; a=rsa-sha256; cv=none; b=gzPCAG1l4AbpYNBUWg/bpNnQW3vNg/0XuvqqZLENEPcd/eqh8LnEHaf8Oc2Y/hb49pGAQM BKbG+EBK33ueaukmVEycV7VoZOfYWSgXAkVenXCgtLRjH0eNzGaxLnQ7oDYpDvap7RE4Wr G+y1JbwFboTi0vDf9LWTnCn2wx91tIDh+ma4mab6/M9jobmGM9TH9YvCviHho2Ve++EBC2 ylCPJv3L33Gr+ORASnZn4Hwu/teNZDW1vvOvrD43c7GSJNvQMCSd7zzMhPe6uip+S1SKrt HygWU2BczafK3pQ4dOsjg/HwYYD+omkx5dT++jEuIO1rQKKaegu9S2cqa/nuVQ== 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 4Xgnjm1b3vzHVf; Sat, 2 Nov 2024 19:24:44 +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 4A2JOiVn014345; Sat, 2 Nov 2024 19:24:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A2JOijA014342; Sat, 2 Nov 2024 19:24:44 GMT (envelope-from git) Date: Sat, 2 Nov 2024 19:24:44 GMT Message-Id: <202411021924.4A2JOijA014342@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 856e158dc4aa - main - freebsd-update: improve pkgbase check 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: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 856e158dc4aa5e43f0f15fcd3089fc0d71861b0e Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=856e158dc4aa5e43f0f15fcd3089fc0d71861b0e commit 856e158dc4aa5e43f0f15fcd3089fc0d71861b0e Author: Ed Maste AuthorDate: 2024-11-01 02:13:44 +0000 Commit: Ed Maste CommitDate: 2024-11-02 19:24:39 +0000 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 80a8bf288251..ccd98a883dca 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 <