From owner-dev-commits-src-all@freebsd.org Fri Jun 11 18:03:07 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7CAFB662786; Fri, 11 Jun 2021 18:03:07 +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 4G1pbv30Pjz4S8s; Fri, 11 Jun 2021 18:03:07 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 4EF522734B; Fri, 11 Jun 2021 18:03:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15BI37ps029198; Fri, 11 Jun 2021 18:03:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15BI37TY029197; Fri, 11 Jun 2021 18:03:07 GMT (envelope-from git) Date: Fri, 11 Jun 2021 18:03:07 GMT Message-Id: <202106111803.15BI37TY029197@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Robert Wing Subject: git: e1dfdff10967 - stable/12 - bectl(8): don't allow creation of boot environments with spaces MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rew X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: e1dfdff10967d294f8c9acb22812380901be3f80 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jun 2021 18:03:07 -0000 The branch stable/12 has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=e1dfdff10967d294f8c9acb22812380901be3f80 commit e1dfdff10967d294f8c9acb22812380901be3f80 Author: Robert Wing AuthorDate: 2021-06-03 16:36:11 +0000 Commit: Robert Wing CommitDate: 2021-06-11 17:41:51 +0000 bectl(8): don't allow creation of boot environments with spaces Boot environment datasets that contain spaces are not bootable. When a user attempts to create a boot environment with a space, abort the creation and print an error message. PR: 254441 Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D30194 (cherry picked from commit 0e6549c8745049e3d6fba3ad748034de2d5cbd2a) --- sbin/bectl/bectl.c | 9 ++++++++- sbin/bectl/tests/bectl_test.sh | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sbin/bectl/bectl.c b/sbin/bectl/bectl.c index 768d1cd89ac2..0c8b9c313488 100644 --- a/sbin/bectl/bectl.c +++ b/sbin/bectl/bectl.c @@ -217,7 +217,10 @@ bectl_cmd_create(int argc, char *argv[]) bootenv = *argv; err = BE_ERR_SUCCESS; - if ((atpos = strchr(bootenv, '@')) != NULL) { + if (strchr(bootenv, ' ') != NULL) + /* BE datasets with spaces are not bootable */ + err = BE_ERR_INVALIDNAME; + else if ((atpos = strchr(bootenv, '@')) != NULL) { /* * This is the "create a snapshot variant". No new boot * environment is to be created here. @@ -245,6 +248,10 @@ bectl_cmd_create(int argc, char *argv[]) switch (err) { case BE_ERR_SUCCESS: break; + case BE_ERR_INVALIDNAME: + fprintf(stderr, + "bectl create: boot environment name must not contain spaces\n"); + break; default: if (atpos != NULL) fprintf(stderr, diff --git a/sbin/bectl/tests/bectl_test.sh b/sbin/bectl/tests/bectl_test.sh index 4a3fc78db0bc..c23cde13adb5 100755 --- a/sbin/bectl/tests/bectl_test.sh +++ b/sbin/bectl/tests/bectl_test.sh @@ -105,6 +105,10 @@ bectl_create_body() atf_check zfs create -o mountpoint=/usr -o canmount=noauto \ ${zpool}/ROOT/default/usr + # BE datasets with spaces are not bootable, PR 254441. + atf_check -e not-empty -s not-exit:0 \ + bectl -r ${zpool}/ROOT create "foo bar" + # Test standard creation, creation of a snapshot, and creation from a # snapshot. atf_check bectl -r ${zpool}/ROOT create -e default default2