From nobody Wed Dec 13 21:53:26 2023 X-Original-To: dev-commits-src-all@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 4Sr8PL5cx3z54N5X; Wed, 13 Dec 2023 21:53:26 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Sr8PL520wz3Q53; Wed, 13 Dec 2023 21:53:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1702504406; 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=vzJ8YNbSVHSelxAEP0ET1Y/Rlhe6AYT3YxA5f87cyyg=; b=N60c+8JIiH0JwXI+GDZlKmKtPb4WnNfwtleS3QoKX6oCoHvGBRuZfHxUmX/VYeBFovsBzk y6f38XXJ6YDMBj6NWaV4YDu4+PpCAIKevmk7QWdY0Doup5aOiMo5EMSdiWdZFhHltYpfmL W+8aGNqy+kkwUGNKiEAAEnNiQy+AzJBcMpmyyPguRXhUKmR0tEZ6Jrg4X2v+rVamOeuZ7W UHPqiPNLv9ZRMWQvqb35SAWSJjMlf+BdCbg3KzkkJbOuhdbVL/V6zGZ5NTGy8LJjZTH8GL 7hflyX9vDc05pNfZCQh3Mqfl/jfdHnN75MJuKUuj2ir+IYxx4dF3KEsYWlg5KA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1702504406; a=rsa-sha256; cv=none; b=mIoGDG5JyT6qu2nCxDAE7glyTrcXWJ2w4VfHeNEB8UWjmcZGls0uMcCeU+TXVFW65iENRY bBmmaSujyDGsA0ypj7xULDrgQSF2TGzj0vCiWXZCKZDPeuM5zBEnD8qad/iPLb0nPtGVEf JBItPTS8KL+IVM6CX9k4yqu+CWsLKiRHr4AjH7UVFaV/M5+ka05sPKQaiJFtCFMJlGNTFe IMc7dPK3HsUDryeGMjXVoPqofT5dVVu60mP6eIT/6WTBuFL2ecjRtedaYkZo6U2SdL6ais vYmSEebD8lIDwQdMk1EscsQmZlxdquQgV+QFAOGsEGdKbvpkj1mTToZRGdfsZg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1702504406; 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=vzJ8YNbSVHSelxAEP0ET1Y/Rlhe6AYT3YxA5f87cyyg=; b=KNrruaGtWiA3GYQVbd8ffPQxvUyX2W+x5lgvrwsEdfjZ41FeRZ/6ugnDr500huW2tUVWHj 2Ij72rFNyMz/605jB1bu3BdFPIlVG8xwiI03i1+fIpYnvEOtbtFx0Y9053+82jYsPqNJ4e lPtMQ1pl5BZ30ZsznL26D9AjEvrZcNGt1NTH1mUUDYUyJW0a4EXvBEjwenc2DlFXpUWNJC NpcESK00oKI46cahkka8kWJp2DLgwL/5lwp6mWI83w28QhEmsbySEVEfSm2Esgkk8lGhDL D20ssCivfuHTTn3psl7/H6hTfy7HdiXlVcb9yEPnO9tq6uBQv5MMGSqBrNBOhw== 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 4Sr8PL43YZz1Fsf; Wed, 13 Dec 2023 21:53:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3BDLrQ5E073074; Wed, 13 Dec 2023 21:53:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BDLrQFn073071; Wed, 13 Dec 2023 21:53:26 GMT (envelope-from git) Date: Wed, 13 Dec 2023 21:53:26 GMT Message-Id: <202312132153.3BDLrQFn073071@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jessica Clarke Subject: git: 7c9a6ac58cbb - stable/13 - bsdinstall: Encode dists to valid variable names in checksum script List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7c9a6ac58cbb5e86a1dda94b346c164f572654d9 Auto-Submitted: auto-generated The branch stable/13 has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=7c9a6ac58cbb5e86a1dda94b346c164f572654d9 commit 7c9a6ac58cbb5e86a1dda94b346c164f572654d9 Author: Jessica Clarke AuthorDate: 2023-12-06 21:37:32 +0000 Commit: Jessica Clarke CommitDate: 2023-12-13 21:52:48 +0000 bsdinstall: Encode dists to valid variable names in checksum script Currently we just strip the .txz of the dist name (and add a status_ prefix) to get the shell variable name for its status, but this doesn't give a valid result for dists like base-dbg, kernel-dbg and lib32-dbg, or even kernel.KERNCONF (or, combining the two, kernel.KERNCONF-dbg). As a result, four things go wrong for such dists: 1. If there is a dot and/or a dash in the name, writing to the variable fails and spits an error out on stderr to the log 3. If there is a dot in the name before any dash, the syntax is always invalid, reading the variable fails, spits an error out on stderr to the log, the result is the empty string and that is interpreted as being 0% 2. If there is a dash in the name before any dot, and there is a dist whose name is the substring up to that first dash, and it has already had its status written to, reading the variable instead reads that dist's variable and so the status of that dist is displayed instead 3. If there is a dash in the name before any dot, and either there is not a dist whose name is the substring up to that first dash or there is such a dist but it has not already had its status written to, reading the varaible instead results in the substring after the first dash, including any additional string expansion syntax that follows (i.e. ${status_kernel-dbg:--11}, the expression used to read the variable, is interpreted as reading status_kernel with a default value of "dbg:--11") For example, in a default install with base, kernel, kernel-dbg and lib32, the following sequence of displays happens: 1. base is In Progress, kernel is Pending, kernel-dbg is 0% (what shows for the garbage input "dbg:--11") and lib32 is Pending 2. base is Passed, kernel is In Progress, kernel-dbg is In Progress (since kernel has now had its status written to) and lib32 is Pending 3. base is Passed, kernel is Passed, kernel-dbg is Passed (again, since that is the status of kernel, despite that kernel-dbg is being verified at this point) and lib32 is Pending 4. base is Passed, kernel is Passed, kernel-dbg is Passed and lib32 is In Progress Fix this with a crude encoding scheme. More special characters can easily be added if needed in future. Note that, prior to bsddialog being used (and thus for branches this is MFC'ed to where dialog is still used), the same problem existed but displayed slightly differently due to a combination of different default values and different behaviour for unintended inputs. Fixes: b70047d41362 ("Add generation of an installation manifest containing SHA256 checksums as ...") MFC after: 1 week (cherry picked from commit 47d669f10ea3eb92a3783376549728b42c9e22b9) --- usr.sbin/bsdinstall/scripts/checksum | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/checksum b/usr.sbin/bsdinstall/scripts/checksum index 3c85d9594346..99c2346280b1 100755 --- a/usr.sbin/bsdinstall/scripts/checksum +++ b/usr.sbin/bsdinstall/scripts/checksum @@ -27,14 +27,20 @@ test -f $BSDINSTALL_DISTDIR/MANIFEST || exit 0 +dist_to_statusvar() +{ + printf 'status_' + echo "$1" | sed 's/_/__/g;s/\./_dot_/g;s/-/_dash_/g' +} + percentage=0 for dist in $DISTRIBUTIONS; do - distname=$(basename $dist .txz) - eval "status_$distname=7" + statusvar=$(dist_to_statusvar $dist) + eval "$statusvar=7" items="" for i in $DISTRIBUTIONS; do - items="$items $i `eval echo \\\${status_$(basename $i .txz):-Pending}`" + items="$items $i `eval echo \\\${$(dist_to_statusvar $i):-Pending}`" done dialog --backtitle "FreeBSD Installer" --title "Checksum Verification" \ --mixedgauge "Verifying checksums of selected distributions." \ @@ -54,13 +60,13 @@ for dist in $DISTRIBUTIONS; do CK_VALID=$? if [ $CK_VALID -le 1 ]; then if [ $CK_VALID -eq 0 ]; then - eval "status_$distname=2" + eval "$statusvar=2" else - eval "status_$distname=6" + eval "$statusvar=6" fi percentage=$(echo $percentage + 100/`echo $DISTRIBUTIONS | wc -w` | bc) else - eval "status_$distname=1" + eval "$statusvar=1" case $(/bin/freebsd-version -u) in *-ALPHA*|*-CURRENT|*-STABLE|*-PRERELEASE) dialog --backtitle "FreeBSD Installer" --title "Error" \