git: 01cf73198d1e - stable/13 - bectl(8): don't allow creation of boot environments with spaces
Robert Wing
rew at FreeBSD.org
Fri Jun 11 17:58:32 UTC 2021
The branch stable/13 has been updated by rew:
URL: https://cgit.FreeBSD.org/src/commit/?id=01cf73198d1e0b3d00f9bb75027e75327c2c5b9b
commit 01cf73198d1e0b3d00f9bb75027e75327c2c5b9b
Author: Robert Wing <rew at FreeBSD.org>
AuthorDate: 2021-06-03 16:36:11 +0000
Commit: Robert Wing <rew at FreeBSD.org>
CommitDate: 2021-06-11 17:28:41 +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 50229b4b96b7..d3de58ea2982 100644
--- a/sbin/bectl/bectl.c
+++ b/sbin/bectl/bectl.c
@@ -233,7 +233,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.
@@ -261,6 +264,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 221fe21e29ed..b101591c3ee9 100755
--- a/sbin/bectl/tests/bectl_test.sh
+++ b/sbin/bectl/tests/bectl_test.sh
@@ -122,6 +122,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
More information about the dev-commits-src-all
mailing list