Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion open_terminal/utils/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ def __init__(self, command: str, cwd: str | None, env: dict | None, run_as_user:
if run_as_user:
# Build the inner command: optionally cd first, then run the command.
inner = f"cd {shlex.quote(cwd)} && {command}" if cwd else command
command = f"sudo -u {shlex.quote(run_as_user)} -- bash -c {shlex.quote(inner)}"
# ``sudo`` resets the environment by default. ``-E`` preserves
# it so that caller-supplied env vars (e.g. ``GH_TOKEN``) actually
# reach the child process.
command = f"sudo -E -u {shlex.quote(run_as_user)} -- bash -c {shlex.quote(inner)}"
cwd = None # Popen runs as parent user — can't chdir into chmod 700 dirs
master_fd, slave_fd = pty.openpty()
try:
Expand Down