chiark / gitweb /
util: Fine tune running_in_chroot() a bit
authorLennart Poettering <lennart@poettering.net>
Thu, 24 Nov 2016 16:42:19 +0000 (17:42 +0100)
committerSven Eden <yamakuzure@gmx.net>
Mon, 17 Jul 2017 15:58:35 +0000 (17:58 +0200)
commited280b715fc427a925d418adc8ec0cfaa395f526
tree60b6fc65e6779ece5f5dbda8d6bac18081e483a8
parentd3c92fb53bb92ec00914aa4b51bd21d88e887128
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