Skip to content

fix: make BASH_ENV writable by arbitrary Prow/OpenShift UIDs - #255

Draft
davdhacs wants to merge 1 commit into
mainfrom
davdhacs/fix-bash-env-perms
Draft

fix: make BASH_ENV writable by arbitrary Prow/OpenShift UIDs#255
davdhacs wants to merge 1 commit into
mainfrom
davdhacs/fix-bash-env-perms

Conversation

@davdhacs

Copy link
Copy Markdown
Contributor

The CI test images bake BASH_ENV=/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 — one mv failure 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_ENV to a dedicated group-writable directory (/var/lib/bash-env/env, GID 0, 0775 dir / 0664 file) 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.sh ci_export swap and the .openshift-ci/dispatch.sh guard 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) against apollo-ci:stackrox-test-0.5.11:

  • Before: each cci-export prints 3 Permission denied lines (mv + 2 appends).
  • After the relocation: zero.

Considered alternatives

  • chmod 0666 on the file alone: fixes the appends but not the mv (which needs write on the parent dir), so noise remains.
  • Making /etc group-writable: works but loosens a system directory unnecessarily.
  • Changing the wrapper mv to 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_ENV apparatus (and the seed file) is likely removable — a larger change left out of this minimal fix.

Partially generated with AI assistance (Claude).

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).
@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown

Important

Review available on request

  • 🔍 Trigger review

Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment @coderabbitai review to review the latest changes. For a full review, comment @coderabbitai full review.

⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 34e6dc3a-5895-427b-b958-2b356fd65bab


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

Build Images

Image Flavor Image Tag
jenkins-plugin quay.io/stackrox-io/apollo-ci:jenkins-plugin-0.5.14-1-g790dc713f5
scanner-build quay.io/stackrox-io/apollo-ci:scanner-build-0.5.14-1-g790dc713f5
scanner-test quay.io/stackrox-io/apollo-ci:scanner-test-0.5.14-1-g790dc713f5
stackrox-build quay.io/stackrox-io/apollo-ci:stackrox-build-0.5.14-1-g790dc713f5
stackrox-test quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.14-1-g790dc713f5
stackrox-ui-test quay.io/stackrox-io/apollo-ci:stackrox-ui-test-0.5.14-1-g790dc713f5

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