Support OpenShift arbitrary UIDs (restricted-v2 SCC)#84
Open
snecklifter wants to merge 1 commit intovespa-engine:masterfrom
Open
Support OpenShift arbitrary UIDs (restricted-v2 SCC)#84snecklifter wants to merge 1 commit intovespa-engine:masterfrom
snecklifter wants to merge 1 commit intovespa-engine:masterfrom
Conversation
Make container images compatible with OpenShift 4.20's default security context which assigns arbitrary UIDs with GID 0 (root group): - Add vespa user to root group (-G root) in both Dockerfiles - Make /etc/passwd group-writable for runtime UID injection - Set root group ownership with g+w on all writable directories - Entrypoint: inject passwd entry for arbitrary UIDs so id/whoami work Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Open
3 tasks
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.
Summary
restricted-v2Security Context Constraint (SCC)/etc/passwdentry at runtime so standard utilities (id,whoami, Go'suser.Current()) workBackground: OpenShift SCCs and the root group
OpenShift uses Security Context Constraints (SCCs) to control what pods can do at runtime. The default
restricted-v2SCC enforces:1000660000+), not the UID specified viaUSERin the Dockerfilesetuid()/setgid()are blocked;CAP_SETUIDandCAP_SETGIDare droppedAs stated in the OpenShift documentation:
Why root group ownership is safe
Using GID 0 as the group owner does not grant root privileges. It simply allows any UID assigned to the root group (which OpenShift always does) to read/write the directories. The actual user remains unprivileged — it cannot escalate to UID 0, bind privileged ports, or perform any root-level operations.
Changes
Dockerfiles (
Dockerfile,Dockerfile.minimal)-G roottouseraddso thevespauser is a member of the root group/etc/passwdgroup-writable (chmod g+w) to allow runtime UID injectionchgrp -R 0) and group-write permissions (chmod -R g+w) on all writable directories:/opt/vespa/logs,/opt/vespa/var,/opt/vespa/secure,/opt/vespa/var/zookeeperEntrypoint (
include/start-container.sh)whoamifails (UID not in/etc/passwd), avespaentry is appended mapping the current UID to GID 0VESPA_USER=vespaso downstream scripts resolve correctlyCompanion PR
The corresponding Vespa application code changes (user-switching, ownership validation, startup scripts) are in vespa-engine/vespa.
Test plan
docker run --user=$(shuf -i 1000000-1999999 -n1):0to simulate OpenShiftwhoamireturnsvespainside container after entrypoint passwd injection/opt/vespa/varand/opt/vespa/logsare writablevespa-start-configserverandvespa-start-servicessucceed under arbitrary UIDvespauser (UID 1000)Dockerfile.minimalbuild with same arbitrary UID scenario🤖 Generated with Claude Code