Skip to content

codex-home input is ignored when safety-strategy is unprivileged-user #99

@WKBae

Description

@WKBae

codex-home is passed via environment variables of subprocess.spawn.

const child = spawn(program, command, {
env,
stdio: ["pipe", "inherit", "inherit"],
});

However, if safety-strategy: unprivileged-user is set, the command is prefixed with sudo -u ${codexUser} --:

command.push("sudo", "-u", codexUser, "--");

The problem is, sudo does not pass enviroment variables unless -E(--preserve-env) flag is set.
This causes configuration mismatch, usually leading to 401 Unauthorized because proxy config is not applied:

ERROR codex_api::endpoint::responses_websocket: failed to connect to websocket: HTTP error: 401 Unauthorized, url: wss://api.openai.com/v1/responses
...
ERROR: Reconnecting... 5/5
ERROR: unexpected status 401 Unauthorized: Missing bearer or basic authentication in header, url: https://api.openai.com/v1/responses, cf-ray: ..., request id: ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions