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 0e6549c874)
This commit is contained in:
Robert Wing committed 2021-06-11 09:41:51 -08:00
1 parent 1e83183d38
commit e1dfdff109
2 files changed
+12 -1

No files matched your search

+8 -1
View File
@@ -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,
+4
View File
@@ -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