Skip to content

fix: preserve custom env vars in multi-user mode via sudo -E#141

Open
Blumlaut wants to merge 1 commit into
open-webui:mainfrom
Blumlaut:fix/preserve-env-multi-user-sudo
Open

fix: preserve custom env vars in multi-user mode via sudo -E#141
Blumlaut wants to merge 1 commit into
open-webui:mainfrom
Blumlaut:fix/preserve-env-multi-user-sudo

Conversation

@Blumlaut

Copy link
Copy Markdown

Problem

In multi-user mode (OPEN_TERMINAL_MULTI_USER=true), custom environment variables passed via the env field in POST /execute are silently dropped.

PtyRunner wraps commands with sudo -u <user> -- bash -c "...", but sudo resets the environment by default for security. The env dict is passed to subprocess.Popen, but never reaches the actual subprocess.

This breaks any workflow that relies on injecting env vars (e.g. GH_TOKEN for GitHub CLI authentication, API keys, custom config).

Solution

Add -E flag to sudo to preserve the environment through the user switch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant