Imported Debian patch 4.8.10-2

This commit is contained in:
Timo Aaltonen
2020-11-23 20:48:56 +02:00
committed by Mario Fetka
parent 8bc559c5a1
commit 358acdd85f
917 changed files with 1185414 additions and 1069733 deletions

View File

@@ -3,6 +3,8 @@
#
from __future__ import absolute_import
import os
from ipaplatform.tasks import tasks
@@ -28,3 +30,27 @@ def test_ipa_version():
assert not v3 == v4
assert v4 > v3
assert v4 >= v3
def test_detect_container():
container = None
# naive detection, may fail for OpenVZ and other container runtimes
if os.path.isfile('/run/systemd/container'):
with open('/run/systemd/container') as f:
container = f.read().strip()
elif os.geteuid() == 0:
with open('/proc/1/environ') as f:
environ = f.read()
for item in environ.split('\x00'):
if not item:
continue
k, v = item.split('=', 1)
if k == 'container':
container = v
detected = tasks.detect_container()
if container == 'oci':
# systemd doesn't know about podman
assert detected in {'container-other', container}
else:
assert detected == container