#!/usr/bin/env python3
"""Use Podman's stock profile, leaving chroot authorization to the kernel."""
import json
import sys
from pathlib import Path

profile = json.loads(Path("/usr/share/containers/seccomp.json").read_text())
rules = profile["syscalls"]
for rule in rules:
    if "chroot" in rule["names"]:
        rule["names"].remove("chroot")
profile["syscalls"] = [rule for rule in rules if rule["names"]]
profile["syscalls"].append({"names": ["chroot"], "action": "SCMP_ACT_ALLOW"})
json.dump(profile, sys.stdout)
