]> git.ipfire.org Git - thirdparty/systemd.git/commit
util-lib: improve container detection logic
authorLennart Poettering <lennart@poettering.net>
Tue, 6 Dec 2016 14:51:26 +0000 (15:51 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 14 Dec 2016 17:29:30 +0000 (18:29 +0100)
commit8d6e80343a1463afbaed1beca4b18c49ce056034
tree7ddaad8f563df86791d7b0ea309f566cfc4ff3c4
parentf6f372d2f46ac9be7cbb1ecd8f82f1b3ab669924
util-lib: improve container detection logic

Previously, systemd-detect-virt was unable to detect "systemd-nspawn -a"
container environments, i.e. where PID 1 is a stub process running in host
context, as in that case /proc/1/environ was inherited from the host. Let's
improve that, and add an additional check for container environments where
/proc/1/environ is not cleaned up and does not contain the $container
environment variable:

The /proc/1/sched file shows the host PID in the first line. if this is not
1, we know we are running in a PID namespace (but not which implementation).

With these changes we should be able to detect container environments that
don't set $container at all.
src/basic/virt.c