]> git.ipfire.org Git - thirdparty/systemd.git/commit
util: Fine tune running_in_chroot() a bit
authorLennart Poettering <lennart@poettering.net>
Thu, 24 Nov 2016 16:42:19 +0000 (17:42 +0100)
committerMartin Pitt <martin.pitt@ubuntu.com>
Wed, 14 Dec 2016 09:13:52 +0000 (10:13 +0100)
commit295ee9845c801300298d01256eb5a9e3ff117ae0
treee46946b349906d7ac5148a718c14bd135c684004
parent4014818d530ad3f6f5e4b94b79a9336376feface
util: Fine tune running_in_chroot() a bit

Let's be a bit more careful when detecting chroot() environments, so that we
can discern them from namespaced environments.

Previously this would simply check if the root directory of PID 1 matches our
own root directory. With this commit, we also check whether the namespaces of
PID 1 and ourselves are the same. If not we assume we are running inside of a
namespaced environment instead of a chroot() environment.

This has the benefit that systemctl (which uses running_in_chroot()) will work
as usual when invoked in a namespaced service.
src/basic/virt.c