stage(oscap.remediation): link /proc/self/fd to /dev/fd

Remediation bash didn't work correctly without /dev/fd.
Link /proc/self/fd to /dev/fd within the tree.
This commit is contained in:
Marcos Libanori Sanches 2023-11-21 14:43:32 -03:00 committed by Simon de Vlieger
parent edbf409a40
commit 810a48d859

View file

@ -20,6 +20,7 @@ import subprocess
import sys
import osbuild.api
from osbuild.util.mnt import mount
SCHEMA = """
"additionalProperties": false,
@ -206,6 +207,12 @@ def main(tree, options):
f"{data_dir}/{REMEDIATION_SCRIPT}"
]
for source in ("/dev", "/proc"):
target = os.path.join(tree, source.lstrip("/"))
os.makedirs(target, exist_ok=True)
mount(source, target, ro=False)
os.symlink("/proc/self/fd", f"{tree}/dev/fd")
log = None
if verbose_log is not None:
log = open(f"{tree}/{data_dir}/{verbose_log}.remediation", "w", encoding="utf8")