From ebd9704f6f1c6879c3300ddcf74e55cbd1fac057 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Thu, 2 Feb 2023 09:52:13 +0100 Subject: debvm-run: deal with arbitrary disk labels Reported-by: Gioele Barabucci Closes: #1030255 --- bin/debvm-run | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/debvm-run b/bin/debvm-run index 9cfce7f..53bfb3b 100755 --- a/bin/debvm-run +++ b/bin/debvm-run @@ -14,7 +14,7 @@ B [B<-g>] [B<-i> F] [B<-s> I] [B<--> I] =head1 DESCRIPTION B is essentially a thin wrapper around B for running a virtual machine image created by B or something compatible. -The virtual machine image is expected to be a raw ext4 image with file system label B. +The virtual machine image is expected to be a raw ext4 image with a non-empty file system label. The architecture of the machine is detected from the contained F. It must contain a symbolic link pointing to a kernel image at one of F<(|/boot)/vmlinu[xz]> a symbolic link pointing to an initrd image at F in the same directory as the kernel image. Both are extracted and passed to B. @@ -173,10 +173,6 @@ if ! printf '\123\357' | cmp --bytes=2 "$IMAGE" - 1080; then die "image '$IMAGE' is not in ext4 format" fi -if ! printf 'debvm\000' | cmp --bytes=6 "$IMAGE" - 1144; then - die "image '$IMAGE' was not created by debvm-create (wrong disk label)" -fi - cleanup() { set +x test -n "$KERNELTMP" && rm -f "$KERNELTMP" @@ -231,7 +227,17 @@ if command -v file >/dev/null 2>&1; then esac fi -KERNEL_CMDLINE="root=LABEL=debvm rw" +IMAGE_LABEL="$(/sbin/e2label "$IMAGE")" +case "$IMAGE_LABEL" in + "") + die "debvm-run requires a non-empty filesystem label" + ;; + *" "*) + die "debvm-run requires a filesystem label without spaces" + ;; +esac + +KERNEL_CMDLINE="root=LABEL=$IMAGE_LABEL rw" NETDEV="user,id=net0" set -- \ -- cgit v1.2.3