]> git.ipfire.org Git - thirdparty/systemd.git/commit
namespace: rework how we resolve symlinks in mount points 8708/head
authorLennart Poettering <lennart@poettering.net>
Wed, 4 Apr 2018 08:14:43 +0000 (10:14 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 18 Apr 2018 12:17:50 +0000 (14:17 +0200)
commit088696fe29e1eadeced40a5a2b277570f0955164
treed857fb6341adc5aa737a010ea3c72bbdcb044db8
parente8717862737bbf8f5388cdfe068265e0aec0fe68
namespace: rework how we resolve symlinks in mount points

Before this patch we'd resolve all symlinks of bind mounts and other
mount points to establish for a service in advance, and only then start
mounting them. This is problematic, if symlink chains jump around
between directories in a namespace tree, so that to resolve a specific
symlink chain we need to establish another mount already. A typical case
where this happens is if /etc/resolv.conf is a symlink to some file in
/run: in that case we'd normally resolve and mount /etc/resolv.conf
early on, but that's broken, as to do this properly we'd need to resolve
/etc/resolv.conf first, then figure out that /run needs to be mounted
before we can proceed, and thus reorder the order in which we apply
mounts dynamically.

With this change, whenever we are about to apply a mount, we'll do a
single step of the symlink normalization process, patch the mount entry
accordingly, and then sort the list of mounts to establish again, taking
the new path into account. This means that we can correctly deal with
the example above: we might start with wanting to mount /etc/resolv.conf
early, but after resolving it to the path in /run/ we'd push it to the
end of the list, ensuring that /run is mounted first.

(Note that this also fixes another bug: we were following symlinks on
the bind mount source relative to the root directory of the service,
rather than of the host. That's wrong though as we explicitly document
tha the source of bind mounts is always on the host.)
src/core/namespace.c