Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Oct 2024 06:46:11 GMT
From:      Robert Wing <rew@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 525a177c1657 - main - mkuzip: drop support for executable uzip images
Message-ID:  <202410210646.49L6kBYJ013309@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by rew:

URL: https://cgit.FreeBSD.org/src/commit/?id=525a177c165740fc697df3de5b92e58b3b41477c

commit 525a177c165740fc697df3de5b92e58b3b41477c
Author:     Robert Wing <rew@FreeBSD.org>
AuthorDate: 2024-10-21 06:43:41 +0000
Commit:     Robert Wing <rew@FreeBSD.org>
CommitDate: 2024-10-21 06:45:09 +0000

    mkuzip: drop support for executable uzip images
    
    A uzip image has a 128-byte header, historically, this header could be
    executed as a shell script to mount the uzip image to a user provided
    mountpoint.
    
    The embedded shell commands only work for uzip images that were created
    with zlib or zstd compression that contained an ISO-9660 file system.
    Given the limited space available in the uzip header, it is not
    practical to extend this feature to include other file systems or to
    provide sensible error handling and error messages to the user.
    For these reasons, abandon the embedded shell script in the uzip image
    header.
    
    To maintain backwards compatibility, the shebang and shell must reside
    in the 128-byte header.
    
    This change of behavior is documented in mkuzip(8) and an example
    has been provided for creating/mounting uzip images.
    
    PR: 276174
---
 usr.bin/mkuzip/mkuz_lzma.h | 12 +++---------
 usr.bin/mkuzip/mkuz_zlib.h |  4 +---
 usr.bin/mkuzip/mkuz_zstd.h |  4 +---
 usr.bin/mkuzip/mkuzip.8    | 45 ++++++++++++++++++++++++++++-----------------
 usr.bin/mkuzip/mkuzip.c    |  2 +-
 5 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/usr.bin/mkuzip/mkuz_lzma.h b/usr.bin/mkuzip/mkuz_lzma.h
index abdcc996e4c3..de7633c395ca 100644
--- a/usr.bin/mkuzip/mkuz_lzma.h
+++ b/usr.bin/mkuzip/mkuz_lzma.h
@@ -25,17 +25,11 @@
  * SUCH DAMAGE.
  */
 
-/* Format L3.0, since we move to XZ API */
-#define CLOOP_MAGIC_LZMA \
-    "#!/bin/sh\n" \
-    "#L3.0\n" \
-    "n=uncompress\n" \
-    "m=geom_$n\n" \
-    "(kldstat -m $m 2>&-||kldload $m)>&-&&" \
-        "mount_cd9660 /dev/`mdconfig -af $0`.$n $1\n" \
-    "exit $?\n"
 #define DEFAULT_SUFX_LZMA   ".ulzma"
 
+/* Format L3.0, since we move to XZ API */
+#define CLOOP_MAGIC_LZMA "#!/bin/sh\n#L3.0\n"
+
 size_t mkuz_lzma_cbound(size_t);
 void *mkuz_lzma_init(int *);
 void mkuz_lzma_compress(void *, const struct mkuz_blk *, struct mkuz_blk *);
diff --git a/usr.bin/mkuzip/mkuz_zlib.h b/usr.bin/mkuzip/mkuz_zlib.h
index 88e68343a27d..5ecf77bb7284 100644
--- a/usr.bin/mkuzip/mkuz_zlib.h
+++ b/usr.bin/mkuzip/mkuz_zlib.h
@@ -26,9 +26,7 @@
 
 #define DEFAULT_SUFX_ZLIB       ".uzip"
 
-#define CLOOP_MAGIC_ZLIB        "#!/bin/sh\n#V2.0 Format\n" \
-    "(kldstat -qm g_uzip||kldload geom_uzip)>&-&&" \
-    "mount_cd9660 /dev/`mdconfig -af $0`.uzip $1\nexit $?\n"
+#define CLOOP_MAGIC_ZLIB        "#!/bin/sh\n#V2.0 Format\n"
 
 size_t mkuz_zlib_cbound(size_t);
 void *mkuz_zlib_init(int *);
diff --git a/usr.bin/mkuzip/mkuz_zstd.h b/usr.bin/mkuzip/mkuz_zstd.h
index b434afe61eee..ca62d3afd417 100644
--- a/usr.bin/mkuzip/mkuz_zstd.h
+++ b/usr.bin/mkuzip/mkuz_zstd.h
@@ -27,9 +27,7 @@
 
 #define DEFAULT_SUFX_ZSTD       ".uzst"
 
-#define CLOOP_MAGIC_ZSTD        "#!/bin/sh\n#Z4.0 Format\n" \
-    "(kldstat -qm g_uzip||kldload geom_uzip)>&-&&" \
-    "mount_cd9660 /dev/`mdconfig -af $0`.uzip $1\nexit $?\n"
+#define CLOOP_MAGIC_ZSTD        "#!/bin/sh\n#Z4.0 Format\n"
 
 size_t mkuz_zstd_cbound(size_t);
 void *mkuz_zstd_init(int *);
diff --git a/usr.bin/mkuzip/mkuzip.8 b/usr.bin/mkuzip/mkuzip.8
index 6f7495ce5418..3b3afc626633 100644
--- a/usr.bin/mkuzip/mkuzip.8
+++ b/usr.bin/mkuzip/mkuzip.8
@@ -207,23 +207,6 @@ The same tradeoff continues to apply: reads in
 .Xr geom_uzip 4
 become more expensive the greater the cluster size.
 .Pp
-The
-.Nm
-utility
-inserts a short shell script at the beginning of the generated image,
-which makes it possible to
-.Dq run
-the image just like any other shell script.
-The script tries to load the
-.Xr geom_uzip 4
-class if it is not loaded, configure the image as an
-.Xr md 4
-disk device using
-.Xr mdconfig 8 ,
-and automatically mount it using
-.Xr mount_cd9660 8
-on the mount point provided as the first argument to the script.
-.Pp
 The de-duplication is a
 .Fx
 specific feature and while it does not require any changes to on-disk
@@ -247,6 +230,34 @@ for
 .Dq 1 .
 .Sh EXIT STATUS
 .Ex -std
+.Sh EXAMPLES
+.Pp
+The following describes how to create and mount a uzip image.
+.Pp
+Create a file system image:
+.Bd -literal -offset indent
+makefs /src.img /usr/src
+.Ed
+.Pp
+Create the uzip image, the output file will be named src.img.uzip:
+.Bd -literal -offset indent
+mkuzip /src.img
+.Ed
+.Pp
+Ensure geom_uzip is loaded:
+.Bd -literal -offset indent
+kldload geom_uzip
+.Ed
+.Pp
+Create an MD device backed by the uzip image:
+.Bd -literal -offset indent
+mdconfig -f /src.img.uzip
+.Ed
+.Pp
+Mount the uzip image:
+.Bd -literal -offset indent
+mount -o ro /dev/md0.uzip /mnt
+.Ed
 .Sh SEE ALSO
 .Xr gzip 1 ,
 .Xr xz 1 ,
diff --git a/usr.bin/mkuzip/mkuzip.c b/usr.bin/mkuzip/mkuzip.c
index f627562af7df..5d2aa9a48a98 100644
--- a/usr.bin/mkuzip/mkuzip.c
+++ b/usr.bin/mkuzip/mkuzip.c
@@ -298,7 +298,7 @@ int main(int argc, char **argv)
 	toc[hdr.nblocks] = 0;
 
 	cfs.fdw = open(oname, (cfs.en_dedup ? O_RDWR : O_WRONLY) | O_TRUNC | O_CREAT,
-		   S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+		   S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
 	if (cfs.fdw < 0) {
 		err(1, "open(%s)", oname);
 		/* Not reached */



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