mirror of https://github.com/google/oss-fuzz.git
CIFuzz: switch to systemd-detect-virt to detect docker (#4101)
Closes https://github.com/google/oss-fuzz/issues/4093
This commit is contained in:
parent
bbb5d82fc9
commit
ec269ac72f
|
@ -89,15 +89,14 @@ def get_fuzz_targets(path):
|
||||||
|
|
||||||
def get_container_name():
|
def get_container_name():
|
||||||
"""Gets the name of the current docker container you are in.
|
"""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:
|
Returns:
|
||||||
Container name or None if not in a container.
|
Container name or None if not in a container.
|
||||||
"""
|
"""
|
||||||
with open('/proc/self/cgroup') as file_handle:
|
result = subprocess.run(['systemd-detect-virt', '-c'],
|
||||||
if 'docker' not in file_handle.read():
|
stdout=subprocess.PIPE).stdout
|
||||||
return None
|
if b'docker' not in result:
|
||||||
|
return None
|
||||||
with open('/etc/hostname') as file_handle:
|
with open('/etc/hostname') as file_handle:
|
||||||
return file_handle.read().strip()
|
return file_handle.read().strip()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue