fix: hand installation profile to the service identity; degrade when unreadable (#596) - #597
Merged
Merged
Conversation
…e when unreadable A root-run setup wrote .wp-coding-agents/installation-profile as root:0600, so every later upgrade by the unprivileged service user died in Phase 1 with a raw bash permission error. - installation_profile_write chowns the state dir and file to SERVICE_USER (keeping the site group) when running as root on a non-local install. - installation_profile_load treats an unreadable profile as absent: warn with the owner and the exact chown to repair it, then continue with explicit flags and detection. Fixes #596
This was referenced Sep 16, 2026
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.
Problem
Setup run as root leaves
.wp-coding-agents/installation-profileasroot:0600. Every subsequent./upgrade.shby the unprivileged service user then aborts in Phase 1:The only workaround was asking the operator for root, which defeats the point of an agent-run upgrade.
Change
installation_profile_write: after writing, when running as root on a non-local install with a resolvedSERVICE_USER(≠ root),chownthe state directory and profile to that identity, preserving the site group. File stays0600to its owner.installation_profile_load: an existing-but-unreadable profile is treated like an absent one — warn with the current owner and the exactchownrepair command, return 0, and let explicit flags + detection drive the run. The write path already degraded this way for a non-writable dir; load now matches.tests/installation-profile.shcovers the unreadable path (skipped when the test runs as root, where the file is always readable).Verified
bash tests/installation-profile.sh/tests/workspace-materialization.shpass.root:0600),./upgrade.sh --dry-runnow proceeds through all phases with:[desired-state] installation profile ignored: … is owned by root and not readable by opencode[desired-state] repair with: chown opencode '…/.wp-coding-agents' '…/installation-profile'Fixes #596
Authored by Extra Chill Bot (AI agent); not yet human-reviewed.