]> git.ipfire.org Git - thirdparty/systemd.git/commit
nspawn: make sure images containing an ESP are compatible with userns -U mode
authorLennart Poettering <lennart@poettering.net>
Tue, 28 Nov 2017 15:46:26 +0000 (16:46 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 5 Dec 2017 12:49:12 +0000 (13:49 +0100)
commit2d3a5a73e0fd5283bd9de42decfd779e6a85ba53
tree97635a39cb8314862cb79902d8e3fcae8cd194c0
parentbb8ad9eacaaf08078ad08e289c4cef08c7c38663
nspawn: make sure images containing an ESP are compatible with userns -U mode

In -U mode we might need to re-chown() all files and directories to
match the UID shift we want for the image. That's problematic on fat
partitions, such as the ESP (and which is generated by mkosi's
--bootable switch), because fat of course knows no UID/GID file
ownership natively.

With this change we take benefit of the uid= and gid= mount options FAT
knows: instead of chown()ing all files and directories we can just
specify the right UID/GID to use at mount time.

This beefs up the image dissection logic in two ways:

1. First of all support for mounting relevant file systems with
   uid=/gid= is added: when a UID is specified during mount it is used for
   all applicable file systems.

2. Secondly, two new mount flags are added:
   DISSECT_IMAGE_MOUNT_ROOT_ONLY and DISSECT_IMAGE_MOUNT_NON_ROOT_ONLY.
   If one is specified the mount routine will either only mount the root
   partition of an image, or all partitions except the root partition.
   This is used by nspawn: first the root partition is mounted, so that
   we can determine the UID shift in use so far, based on ownership of
   the image's root directory. Then, we mount the remaining partitions
   in a second go, this time with the right UID/GID information.
src/basic/mount-util.c
src/basic/mount-util.h
src/core/namespace.c
src/dissect/dissect.c
src/nspawn/nspawn.c
src/shared/dissect-image.c
src/shared/dissect-image.h