Hi,

Quoting Francesco Poli (2024-01-29 00:07:08)
> What's *your* umask? Is it Debian default (022), by chance?

yes.

> This seems to work with Debian default umask (022):
> 
>   $ printf '%o\n' "$(( 0666 - 00022 ))"
>   644
> 
> but fails whenever a umask includes an octal digit equal to 7, due to
> the carryover:
> 
>   $ printf '%o\n' "$(( 0666 - 00007 ))"
>   657
> 
> Shouldn't this use the bitwise AND combined with the bitwise NOT?
> 
>   $ umask
>   0007
>   $ printf '%o\n' "$(( 0666 & ~0$(umask) ))"
>   660
>   $ umask 022
>   $ umask
>   0022
>   $ printf '%o\n' "$(( 0666 & ~0$(umask) ))"
>   644
> 
> I would think that mmdebstrap-autopkgtest-build-qemu should run:
> 
>   chmod "$(printf %o "$(( 0666 & ~0$(umask) ))")" "$IMAGE"
> 
> Does it make sense to you?

I now have this locally. Is this attribution (name/email) correct?

>From 8410dc6636817c4e02cf9eba090a70051c494c48 Mon Sep 17 00:00:00 2001
From: Francesco Poli <[email protected]>
Date: Mon, 29 Jan 2024 08:28:53 +0100
Subject: [PATCH] mmdebstrap-autopkgtest-build-qemu: fix octal mode computation

---
 mmdebstrap-autopkgtest-build-qemu | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mmdebstrap-autopkgtest-build-qemu 
b/mmdebstrap-autopkgtest-build-qemu
index 5684cbe..1ed14db 100755
--- a/mmdebstrap-autopkgtest-build-qemu
+++ b/mmdebstrap-autopkgtest-build-qemu
@@ -357,7 +357,7 @@ echo "mmdebstrap $*"
 mmdebstrap "$@" || die "mmdebstrap failed"
 
 unshare -U -r --map-groups=auto chown 0:0 "$IMAGE"
-chmod "$(printf %o "$(( 0666 - 0$(umask) ))")" "$IMAGE"
+chmod "$(printf %o "$(( 0666 & ~0$(umask) ))")" "$IMAGE"
 
 echo "root=LABEL=autopkgtestvm rw console=ttyS0" > "$WORKDIR/cmdline"
 
-- 
2.39.2

> > Can you list some reasons why qcow2 should be preferred over
> > raw images?
> 
> I was under the impression that the qcow2 format was the recommended
> one for QEMU/KVM virtual machine images. At least, qemu-img(1)
> describes it as "the most versatile format"...
> 
> Anyway, if you think that the raw format is a better choice for
> autopkgtest and sbuild VM images, I take your word for it.

I'm asking because I'm not the expert. :)

I asked in #debian-devel and f_g (Fabian Grünbichler) commented that the main
reasoning for choosing qcow over raw images is snapshot, link clone and backing
image support.

I don't think these features are useful for users of autopkgtest or sbuild with
these images. Or do you see a use for them in this area?

Thanks!

cheers, josch

Attachment: signature.asc
Description: signature

Reply via email to