Skip to content

fix: hand installation profile to the service identity; degrade when unreadable (#596) - #597

Merged
chubes4 merged 1 commit into
mainfrom
fix/596-installation-profile-ownership
Sep 16, 2026
Merged

chubes4 merged 1 commit into
mainfrom
fix/596-installation-profile-ownership

Conversation

@chubes4

@chubes4 chubes4 commented Sep 16, 2026

Copy link
Copy Markdown
Member

Problem

Setup run as root leaves .wp-coding-agents/installation-profile as root:0600. Every subsequent ./upgrade.sh by the unprivileged service user then aborts in Phase 1:

lib/desired-state-reconciler.sh: line 138: /var/www/extrachill.com/.wp-coding-agents/installation-profile: Permission denied

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 resolved SERVICE_USER (≠ root), chown the state directory and profile to that identity, preserving the site group. File stays 0600 to its owner.
  • installation_profile_load: an existing-but-unreadable profile is treated like an absent one — warn with the current owner and the exact chown repair 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.
  • Test: tests/installation-profile.sh covers 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.sh pass.
  • On the affected VPS install (profile still root:0600), ./upgrade.sh --dry-run now 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.

…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
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.

upgrade.sh: installation-profile written root:600 by root-run setup blocks all later upgrades by the service user

1 participant