fix: make BASH_ENV writable by arbitrary Prow/OpenShift UIDs - #255
Draft
davdhacs wants to merge 1 commit into
Draft
fix: make BASH_ENV writable by arbitrary Prow/OpenShift UIDs#255davdhacs wants to merge 1 commit into
davdhacs wants to merge 1 commit into
Conversation
BASH_ENV is baked as /etc/initial-bash.env, a root-owned 0644 file. cci-export() (the /bin/bash-wrapper mechanism) appends to and rewrites (mv) that file on every call. Under OpenShift/Prow, the container runs as an arbitrary non-root UID in GID 0, which cannot write /etc or a root-only file — so every cci-export call emits "Permission denied" (an mv failure plus two append failures), spamming CI logs ~1450x per test step. Reading/sourcing the file is fine (world-readable), so the noise is purely the writes. Move BASH_ENV to a dedicated group-writable directory (/var/lib/bash-env/env, GID 0, 0775 dir / 0664 file) so the arbitrary UID can write it. This silences the spam at the source, image-wide, and makes the downstream workarounds (scripts/ci/lib.sh ci_export swap, .openshift-ci/dispatch.sh guard) unnecessary. Also dropped the stale CircleCI framing in the comment (we only use GitHub Actions and Prow now). Verified by simulating an arbitrary UID (uid=1000670000, gid=0) against apollo-ci:stackrox-test-0.5.11: before, each cci-export prints 3 "Permission denied" lines; after the relocation, zero. Note: since CircleCI is retired, the whole cci-export/BASH_ENV apparatus is likely removable in a follow-up; this change is the minimal fix for the log spam. Partially generated with AI assistance (Claude).
|
Important Review available on request
Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment ⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Build Images
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The CI test images bake
BASH_ENV=/etc/initial-bash.env, a root-owned0644file.cci-export()(the/bin/bash-wrappermechanism) appends to and rewrites (mv) that file on every call.Under OpenShift/Prow the container runs as an arbitrary non-root UID in GID 0, which cannot write
/etcor a root-only file. So everycci-exportcall emitsPermission denied— onemvfailure plus two append failures — spamming CI logs ~1450x per test step. Reading/sourcing the file is fine (it is world-readable), so the noise is purely the writes, not shell startup.Fix
Relocate
BASH_ENVto a dedicated group-writable directory (/var/lib/bash-env/env, GID 0,0775dir /0664file) so the arbitrary runtime UID can write it. This silences the spam at the source, image-wide, and makes the downstream workarounds (scripts/ci/lib.shci_exportswap and the.openshift-ci/dispatch.shguard in stackrox/stackrox) unnecessary. Also dropped the stale CircleCI framing in the comment — we only run on GitHub Actions and Prow now.Applied to all three test images:
stackrox-test,stackrox-ui-test,scanner-test.Verification
Simulated an arbitrary UID (
uid=1000670000, gid=0) againstapollo-ci:stackrox-test-0.5.11:cci-exportprints 3Permission deniedlines (mv+ 2 appends).Considered alternatives
chmod 0666on the file alone: fixes the appends but not themv(which needs write on the parent dir), so noise remains./etcgroup-writable: works but loosens a system directory unnecessarily.mvto an in-place rewrite: works but alters the shared cci-export logic and loses atomicity.A dedicated writable directory is the least-invasive option that fully silences the spam.
Follow-up
Since CircleCI is retired, the entire
cci-export/BASH_ENVapparatus (and the seed file) is likely removable — a larger change left out of this minimal fix.Partially generated with AI assistance (Claude).