stages/oscap.remediation: setup env helper
Add a small helper function to setup the mountpoints and symlink for the stage. This will help in making the stage easier to test.
This commit is contained in:
parent
9bef57d5a6
commit
a1beb4d295
1 changed files with 9 additions and 5 deletions
|
|
@ -11,6 +11,14 @@ XCCDF_RESULTS = "oscap_eval_xccdf_results.xml"
|
|||
REMEDIATION_SCRIPT = "oscap_remediation.bash"
|
||||
|
||||
|
||||
def setup_env(tree):
|
||||
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")
|
||||
|
||||
|
||||
# pylint: disable=too-many-statements,too-many-branches
|
||||
def main(tree, options):
|
||||
# required vars
|
||||
|
|
@ -32,11 +40,7 @@ def main(tree, options):
|
|||
data_dir = data_dir.lstrip('/')
|
||||
os.makedirs(f"{tree}/{data_dir}", exist_ok=True)
|
||||
|
||||
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")
|
||||
setup_env(tree)
|
||||
|
||||
# build common data stream-related args list
|
||||
ds_args = ["--profile", profile_id]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue