Don't configure KEYRING ccache in containers

Kernel keyrings are not namespaced yet. Keyrings can leak into other
containers. Therefore keyrings should not be used in containerized
environment.

Don't configure Kerberos to use KEYRING ccache backen when a container
environment is detected by systemd-detect-virt --container.

Fixes: https://pagure.io/freeipa/issue/7807
Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
Reviewed-By: Tibor Dudlak <tdudlak@redhat.com>
This commit is contained in:
Christian Heimes
2018-12-12 17:32:06 +01:00
committed by Tibor Dudlák
parent 49cc72d5c9
commit 165a941109
5 changed files with 64 additions and 3 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