Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Apr 2022 03:41:13 GMT
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 0869fa0c0ab7 - stable/12 - bectl: push space-in-name check down into libbe
Message-ID:  <202204060341.2363fDhe088672@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=0869fa0c0ab7a684e09c414d9689abc202669ff6

commit 0869fa0c0ab7a684e09c414d9689abc202669ff6
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2022-04-03 02:04:31 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2022-04-06 03:40:31 +0000

    bectl: push space-in-name check down into libbe
    
    This check was previously in `create` only, not applying to renames.  It
    should really be applied at the libbe level, so that we can avoid
    writing about this restriction over and over again.
    
    While we're here: `bectl rename` always succeeds, even when it doesn't.
    Start returning the error.
    
    Reported By:    Christian McDonald <cmcdonald netgate com>
    
    (cherry picked from commit dadb9c70938c4ae2c260f6af65752c67ac752284)
---
 lib/libbe/be.c     | 11 +++++++++++
 sbin/bectl/bectl.c |  9 ++-------
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/lib/libbe/be.c b/lib/libbe/be.c
index 98304c8bd166..6c7bf1b2ae45 100644
--- a/lib/libbe/be.c
+++ b/lib/libbe/be.c
@@ -957,6 +957,17 @@ be_validate_name(libbe_handle_t *lbh, const char *name)
 	if (!zfs_name_valid(name, ZFS_TYPE_DATASET))
 		return (BE_ERR_INVALIDNAME);
 
+	/*
+	 * ZFS allows spaces in boot environment names, but the kernel can't
+	 * handle booting from such a dataset right now.  vfs.root.mountfrom
+	 * is defined to be a space-separated list, and there's no protocol for
+	 * escaping whitespace in the path component of a dev:path spec.  So
+	 * while loader can handle this situation alright, it can't safely pass
+	 * it on to mountroot.
+	 */
+	if (strchr(name, ' ') != NULL)
+		return (BE_ERR_INVALIDNAME);
+
 	return (BE_ERR_SUCCESS);
 }
 
diff --git a/sbin/bectl/bectl.c b/sbin/bectl/bectl.c
index 0c8b9c313488..1b31c337a3f2 100644
--- a/sbin/bectl/bectl.c
+++ b/sbin/bectl/bectl.c
@@ -133,7 +133,6 @@ get_cmd_info(const char *cmd)
 	return (NULL);
 }
 
-
 static int
 bectl_cmd_activate(int argc, char *argv[])
 {
@@ -217,10 +216,7 @@ bectl_cmd_create(int argc, char *argv[])
 	bootenv = *argv;
 
 	err = BE_ERR_SUCCESS;
-	if (strchr(bootenv, ' ') != NULL)
-		/* BE datasets with spaces are not bootable */
-		err = BE_ERR_INVALIDNAME;
-	else if ((atpos = strchr(bootenv, '@')) != NULL) {
+	if ((atpos = strchr(bootenv, '@')) != NULL) {
 		/*
 		 * This is the "create a snapshot variant". No new boot
 		 * environment is to be created here.
@@ -462,7 +458,6 @@ bectl_cmd_rename(int argc, char *argv[])
 	dest = argv[2];
 
 	err = be_rename(be, src, dest);
-
 	switch (err) {
 	case BE_ERR_SUCCESS:
 		break;
@@ -471,7 +466,7 @@ bectl_cmd_rename(int argc, char *argv[])
 		    src, dest);
 	}
 
-	return (0);
+	return (err);
 }
 
 static int



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202204060341.2363fDhe088672>