project-stacker/stacker

> Include a squashfs image in stacker binary for validation of mount

smoser opened this issue · 0 comments

smoser commented

Serge had the idea in #514 to include a squashfs image inside stacker and use that to determine if extract methods (kernel-mount, squashfuse-mount, unsquashfs) are available. that would simplify things compared to what we're doing in #514 as you would know that the image attempting to be mounted is good.

We could keep inside the stacker binary an empty squashfs; every time stacker starts, we try to mount it from and to a tmpdir, and use that to inform whether to use kernel mounting...

It may seem wasteful, but apart from not having to do the Once() for the first kernel mount of an image, it also prevents us from misinterpreting an attempted mount of a bad squashfs blob as insufficient privilege.

I kind of like it.

$ echo "hi mom" > file.txt
$ mksquashfs file.txt out.squashfs
$ ls -l out.squashfs
-rw-r--r-- 1 smoser smoser 4096 Oct  5 16:09 out.squashfs
$ mkdir mnt
$ mount -t squashfs -o loop,ro out.squashfs mnt
$ cat mnt/file.txt 
hi mom

4096 bytes isn't too wasteful.

Originally posted by @smoser in #514 (comment)