From ebe187788a45eb095bb85a8286240ac2a9e231bf Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Sun, 16 Aug 2026 07:01:14 +0200 Subject: [PATCH] lib.pm.dpkg: Pass context to run_sudo() _run() forwards the execution context to run_cmd() when sudo is not requested, but calls run_sudo(cmd) without the context in the sudo case. run_sudo() then falls back to a fresh local context, so sudoed dpkg and dpkg-query commands run on the local machine instead of on the given context, e.g. Distro._delete() on a remote host. Pass the context and non-interactive stdin to run_sudo() as well. Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.84.2 Signed-off-by: Jan Lindemann --- src/python/jw/pkg/lib/pm/dpkg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python/jw/pkg/lib/pm/dpkg.py b/src/python/jw/pkg/lib/pm/dpkg.py index a7b30813..8b2857e9 100644 --- a/src/python/jw/pkg/lib/pm/dpkg.py +++ b/src/python/jw/pkg/lib/pm/dpkg.py @@ -29,7 +29,7 @@ async def _run( cmd: list[str], sudo: bool = False, ec: ExecContext | None = None ) -> str: return ( - await run_sudo(cmd) + await run_sudo(cmd, ec = ec, cmd_input = InputMode.NonInteractive) if sudo else await run_cmd(cmd, ec = ec, cmd_input = InputMode.NonInteractive) ).stdout_str