Skip to content

fix(safe-env): skip readonly EUID and PPID variables under set -e - #5126

Closed
vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/safe-env-readonly-euid-ppid-guard
Closed

vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/safe-env-readonly-euid-ppid-guard

Conversation

@vaibhavsrv

Copy link
Copy Markdown
Contributor

Why this matters

ods/lib/safe-env.sh parses .env files and script outputs to export variables for Docker Compose and ODS lifecycle commands. Previously, a guard was added skipping Bash's readonly variable UID. However, container wrapper scripts and multi-user environments frequently define EUID and PPID (e.g. for user/group mapping or process ancestry).

Because Bash enforces EUID and PPID as readonly shell variables, attempting export EUID=... or export PPID=... under set -e triggers an immediate fatal error (bash: line X: EUID: readonly variable) and terminates ODS lifecycle commands before reaching Compose.

Skipping EUID and PPID alongside UID in both load_env_file and load_env_from_output avoids aborting execution while allowing the rest of the .env file to load normally.

Overlap check

Searched live open/closed PRs by safe-env, readonly, load_env_file, and lib/safe-env.sh. #3820 merged the initial UID readonly variable check, #3718 merged inline comments handling, and #3712 normalized CRLF line endings. None covers EUID or PPID. This change directly hardens the existing readonly variable filter without conflicting with pending .env serializers.

Validation

  • Ran bash ods/tests/test-safe-env.sh: All 14 test groups pass, including the expanded Test 10 asserting that UID, EUID, and PPID in .env are skipped without failing under set -e.
  • Ran bash ods/tests/test-validate-env.sh and bash ods/tests/test-dotenv-serializer.sh: Both pass cleanly.
  • ShellCheck passes with 0 warnings on ods/lib/safe-env.sh.

Review status and composition

Independent human review welcome. Change is 4 lines in ods/lib/safe-env.sh and 8 lines in ods/tests/test-safe-env.sh. Composes cleanly with upstream public-beta HEAD 33155fb5.

@Lightheartdevs

Copy link
Copy Markdown
Collaborator

Thanks for this contribution. public-beta was promoted into main on 2026-09-24 and no longer receives changes, so we're closing pull requests that target it. This isn't a judgment on the change itself. If it's still needed, please rebase onto main and open a focused PR. See #7253 for details and the contribution policy.

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.

2 participants