src/ipahealthcheck/system/filesystemspace.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/ipahealthcheck/system/filesystemspace.py b/src/ipahealthcheck/system/filesystemspace.py index 0e5b50a..bdd99e7 100644 --- a/src/ipahealthcheck/system/filesystemspace.py +++ b/src/ipahealthcheck/system/filesystemspace.py @@ -3,6 +3,7 @@ # from __future__ import division +import errno import os import shutil @@ -11,16 +12,27 @@ from ipahealthcheck.core.plugin import duration, Result from ipahealthcheck.core import constants +def is_hidepid(): + """Determine if /proc is mounted with hidepid=1/2 option""" + try: + os.lstat('/proc/1/stat') + except OSError as e: + return e.errno in (errno.EPERM, errno.ENOENT) + return False + + def in_container(): """Determine if we're running in a container.""" - with open('/proc/1/sched', 'r') as sched: - data_sched = sched.readline() + data_sched = '' + if not is_hidepid(): + with open('/proc/1/sched', 'r') as sched: + data_sched = sched.readline() with open('/proc/self/cgroup', 'r') as cgroup: data_cgroup = cgroup.readline() checks = [ - data_sched.split()[0] not in ('systemd', 'init',), + data_sched and data_sched.split()[0] not in ('systemd', 'init',), data_cgroup.split()[0] not in ('libpod'), os.path.exists('/.dockerenv'), os.path.exists('/.dockerinit'),