From f14ea6d8bc70458c842d205f0ae5d5e6e4f71808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=91=D0=BE=D0=B1?= =?UTF-8?q?=D1=8B=D1=80=D0=B5=D0=B2?= Date: Fri, 5 Jun 2026 19:50:08 +0300 Subject: [PATCH] fix: run WARP package scripts outside sandbox --- app.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index a5841fe..21af8a6 100755 --- a/app.py +++ b/app.py @@ -303,13 +303,30 @@ def run_script(path: str, extra_env=None): env = os.environ.copy() if extra_env: env.update(extra_env) + cmd = [path] + runner = "direct" + if shutil.which("systemd-run") and os.geteuid() == 0: + unit = "warp-webui-script-" + datetime.now(timezone.utc).strftime("%Y%m%d%H%M%S") + cmd = [ + "systemd-run", + "--wait", + "--pipe", + "--collect", + "--quiet", + f"--unit={unit}", + ] + for key, value in (extra_env or {}).items(): + cmd.append(f"--setenv={key}={value}") + cmd.append(path) + runner = "systemd-run" start = time.time() - proc = subprocess.run([path], shell=False, capture_output=True, text=True, timeout=600, env=env) + proc = subprocess.run(cmd, shell=False, capture_output=True, text=True, timeout=900, env=env) dur_ms = int((time.time() - start) * 1000) log_event( "info", "script_executed", path=path, + runner=runner, returncode=proc.returncode, duration_ms=dur_ms, stdout_tail=(proc.stdout or "")[-2000:], @@ -319,6 +336,7 @@ def run_script(path: str, extra_env=None): 200 if proc.returncode == 0 else 500, { "path": path, + "runner": runner, "result_code": proc.returncode, "stdout": (proc.stdout or "").strip(), "stderr": (proc.stderr or "").strip(), @@ -1228,6 +1246,7 @@ INDEX_HTML = r"""