diff options
author | 2020-07-09 22:51:34 +0300 | |
---|---|---|
committer | 2020-07-09 12:51:34 -0700 | |
commit | ec269ac72f473795bff0e394888d859a2b7d39d8 (patch) | |
tree | 6804db8d49b7a0ebfbd3f2ad97c3fcd1361d7654 /infra/utils.py | |
parent | bbb5d82fc95a78f82729748fe145a0d135b8cee1 (diff) |
CIFuzz: switch to systemd-detect-virt to detect docker (#4101)
Diffstat (limited to 'infra/utils.py')
-rw-r--r-- | infra/utils.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/infra/utils.py b/infra/utils.py index 17cc2379..4685c603 100644 --- a/infra/utils.py +++ b/infra/utils.py @@ -89,15 +89,14 @@ def get_fuzz_targets(path): def get_container_name(): """Gets the name of the current docker container you are in. - /proc/self/cgroup can be used to check control groups e.g. Docker. - See: https://docs.docker.com/config/containers/runmetrics/ for more info. Returns: Container name or None if not in a container. """ - with open('/proc/self/cgroup') as file_handle: - if 'docker' not in file_handle.read(): - return None + result = subprocess.run(['systemd-detect-virt', '-c'], + stdout=subprocess.PIPE).stdout + if b'docker' not in result: + return None with open('/etc/hostname') as file_handle: return file_handle.read().strip() |