chiark / gitweb /
util-lib: improve container detection logic
authorLennart Poettering <lennart@poettering.net>
Tue, 6 Dec 2016 14:51:26 +0000 (15:51 +0100)
committerSven Eden <yamakuzure@gmx.net>
Mon, 17 Jul 2017 15:58:35 +0000 (17:58 +0200)
commitc1a072fc4997f736c2c7cd9716ea2a3973c9704a
tree23e32b237942256e54959087163d7ef3a43529f3
parent4a7059686430f596810f0c83e4897154828fd352
util-lib: improve container detection logic

Previously, elogind-detect-virt was unable to detect "elogind-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