From 3a674d9e3bdb1e766d6d01fcc1f868d0f15e5822 Mon Sep 17 00:00:00 2001 From: sascha Date: Sat, 8 Aug 2026 22:27:13 +0200 Subject: [PATCH] fix: sysctl audit via procfs --- app.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index 660a9aa..9eb1ddd 100644 --- a/app.py +++ b/app.py @@ -1209,15 +1209,15 @@ SYSCTL_AUDIT_KEYS = ( def _sysctl_audit_command() -> str: - script = f'''import glob, json, subprocess + script = f'''import glob, json +from pathlib import Path keys = {SYSCTL_AUDIT_KEYS!r} live, errors = {{}}, {{}} for key in keys: - result = subprocess.run(["sysctl", "-n", key], capture_output=True, text=True) - if result.returncode == 0: - live[key] = result.stdout.strip() - else: - errors[key] = result.stderr.strip()[:160] + try: + live[key] = Path("/proc/sys/" + key.replace(".", "/")).read_text().strip() + except OSError as exc: + errors[key] = str(exc)[:160] persistent = {{}} for path in ["/etc/sysctl.conf", *sorted(glob.glob("/etc/sysctl.d/*.conf"))]: try: -- 2.49.1