Merging this to trunk publishes images used by the production fleet..gitea/workflows/build-push.yaml triggers on every push to trunk and builds + pushes ALL families (cac, cac-fpm, cac-litespeed, cac-lsphp, shared-httpd, shared-ols) with their phpNN tags and latest (= php85). This PR changes files copied into cac, cac-fpm (entrypoints, create-vhost.sh, new dev-mode.sh) and shared-ols (ols-htaccess-watcher.sh). Production behaviour of cac is unchanged (see the diff proof below), but the new images still reach production tags on merge, so schedule it with the fleet rollout. The PR itself triggers no CI (push-to-trunk only); the checks below were run locally.
Does not touch Dockerfile.shared-httpd or any shared-httpd file (PR #59 and the symlink prototype are unaffected).
What changed (one commit per item)
local-dev.sh works end to end: unquoted brace mkdir (was a literal {apache,system} dir), removed the /var/log and /etc/httpd/logs mounts that collided with the entrypoint, credentials from /home/<user>/mysql_creds, -a N selects the cac:phpNN tag (never latest), waits for healthy instead of sleep 160, WordPress only into an empty web root. CAC_IMAGE overrides the image (used to test local builds).
PHPVER: README/CLAUDE.md say the image tag selects PHP and latest = PHP 8.5 today; DEV-only startup warning when an explicit PHPVER does not match the image.
DEV MariaDB/memcached on AlmaLinux 10: dnf --allowerasing MariaDB-server MariaDB-client (mariadb.org 11.4, fallback AlmaLinux mariadb-server), memcached from AppStream, readiness wait, and any failure is a loud FATAL banner plus exit 1 (the HEALTHCHECK only probes Apache, so "unhealthy" could not express it). PROD never runs this. Applied to cac and cac-fpm (same broken block).
README: uid=$(id -u) / user=$(whoami), AlmaLinux 10. There is no gid variable in the entrypoint, so only uid is documented.
DEV ergonomics (DEV only): display_errors=On, opcache.revalidate_freq=0, XDEBUG=1 (Remi php-pecl-xdebug3 for the image's PHP; XDEBUG_MODE/START/CLIENT_HOST/CLIENT_PORT), posix (php-process), HTTP->HTTPS redirect keeps a non-standard port (PUBLIC_HTTPS_PORT, set by local-dev.sh from -s). error_reporting is intentionally left at the prod value (E_DEPRECATED floods wp-cli and PHP 8.5 startup).
DOCROOT_SUBDIR: Apache DocumentRoot = public_html/<sub>, validated with the same rules as WHP's panel/internal/vhost/docrootsub (ASCII letters/digits/./_/-, max 4 segments, 64 bytes per segment, 128 total, no segment starting with . or -, no ./../empty, cgi-bin and the other reserved names refused, newline-safe). Parent public_html gets Options None / AllowOverride None / Require all denied (same shape WHP renders). Unset = byte-identical vhost.
shared-ols: ols-htaccess-watcher.sh now triggers on .htaccess directly in any vhost's real docRoot (read from the rendered vhconf.conf files, refreshed only when httpd_config.conf changes); legacy */public_html/.htaccess only as a fallback when the set is empty; deep plugin .htaccess files still do not trigger. New scripts/tests/ols-htaccess-watcher.test.sh + CI wiring.
Proof (images built locally with docker from this branch)
Prod unchanged: container run in PROD mode (no environment, no DOCROOT_SUBDIR) from the published cac:php85 and from the new build; /etc/httpd/conf.d, conf.modules.d, httpd.conf, /etc/php-fpm.d, php-fpm.conf, php.ini, php.d (70 files) are identical (diff -r). php84: identical except remoteip.conf, which holds the container's own docker network address (differs per container run).
local-dev.sh from a fresh checkout (git archive), -a 83, -a 84, -a 85: container healthy, WordPress downloaded + wp-config created, front page answers, PHP 8.3.37 / 8.4.28 / 8.5.13 as per tag, .htaccess rewrite works, host edits show immediately (twice, opcache revalidate 0), DEV MariaDB 11.4.14 and memcached work from PHP, posix present, display_errors=1, files stay owned by the host uid, redirect https://ld83-local.dev:19483/x keeps the port.
README manual recipe (uid=$(id -u), PHPVER=84, XDEBUG=1): healthy, Xdebug loaded, and a real DBGp init packet arrived at a listener on host port 9003.
DOCROOT_SUBDIR=public with a CI4-like tree: /, pretty URLs and static files served from public/; vendor/, app/ and .env are not reachable as files (requests fall into the app's front controller, .env is 403); public_html/.htaccess is not read. 24 valid/invalid values tested against the validator (including newline injection and cgi-bin).
DEV failure visibility: --network none DEV container exits 1 with the FATAL banner listing MariaDB/memcached/Xdebug.
shared-ols (real shared-ols image built from this branch, two tenants): folder-site .htaccess edit -> graceful restart issued and the new rewrite takes effect (302); normal-site edit still triggers; deep plugin file does not; the original image does NOT reload for the folder site. The 9-case test passes inside the image.
Notes
Known limitation (pre-existing, not changed): inotify misses tenant directories created after the watcher starts; see the long comment in the watcher.
local-dev.sh WordPress step downloads core only into an empty web root.
## DO NOT MERGE without coordination
**Merging this to `trunk` publishes images used by the production fleet.** `.gitea/workflows/build-push.yaml` triggers on every push to `trunk` and builds + pushes ALL families (cac, cac-fpm, cac-litespeed, cac-lsphp, shared-httpd, shared-ols) with their `phpNN` tags and `latest` (= php85). This PR changes files copied into `cac`, `cac-fpm` (entrypoints, `create-vhost.sh`, new `dev-mode.sh`) and `shared-ols` (`ols-htaccess-watcher.sh`). Production behaviour of cac is unchanged (see the diff proof below), but the new images still reach production tags on merge, so schedule it with the fleet rollout. The PR itself triggers no CI (push-to-trunk only); the checks below were run locally.
Does not touch `Dockerfile.shared-httpd` or any shared-httpd file (PR #59 and the symlink prototype are unaffected).
## What changed (one commit per item)
1. **local-dev.sh works end to end**: unquoted brace mkdir (was a literal `{apache,system}` dir), removed the `/var/log` and `/etc/httpd/logs` mounts that collided with the entrypoint, credentials from `/home/<user>/mysql_creds`, `-a N` selects the `cac:phpNN` tag (never `latest`), waits for healthy instead of `sleep 160`, WordPress only into an empty web root. `CAC_IMAGE` overrides the image (used to test local builds).
2. **PHPVER**: README/CLAUDE.md say the image tag selects PHP and `latest` = PHP 8.5 today; DEV-only startup warning when an explicit `PHPVER` does not match the image.
3. **DEV MariaDB/memcached on AlmaLinux 10**: `dnf --allowerasing MariaDB-server MariaDB-client` (mariadb.org 11.4, fallback AlmaLinux mariadb-server), memcached from AppStream, readiness wait, and any failure is a loud FATAL banner plus exit 1 (the HEALTHCHECK only probes Apache, so "unhealthy" could not express it). PROD never runs this. Applied to cac and cac-fpm (same broken block).
4. **README**: `uid=$(id -u)` / `user=$(whoami)`, AlmaLinux 10. There is no gid variable in the entrypoint, so only uid is documented.
5. **DEV ergonomics** (DEV only): `display_errors=On`, `opcache.revalidate_freq=0`, `XDEBUG=1` (Remi `php-pecl-xdebug3` for the image's PHP; `XDEBUG_MODE/START/CLIENT_HOST/CLIENT_PORT`), `posix` (php-process), HTTP->HTTPS redirect keeps a non-standard port (`PUBLIC_HTTPS_PORT`, set by local-dev.sh from `-s`). `error_reporting` is intentionally left at the prod value (E_DEPRECATED floods wp-cli and PHP 8.5 startup).
6. **`DOCROOT_SUBDIR`**: Apache DocumentRoot = `public_html/<sub>`, validated with the same rules as WHP's `panel/internal/vhost/docrootsub` (ASCII letters/digits/`.`/`_`/`-`, max 4 segments, 64 bytes per segment, 128 total, no segment starting with `.` or `-`, no `.`/`..`/empty, `cgi-bin` and the other reserved names refused, newline-safe). Parent `public_html` gets `Options None / AllowOverride None / Require all denied` (same shape WHP renders). Unset = byte-identical vhost.
7. **shared-ols**: `ols-htaccess-watcher.sh` now triggers on `.htaccess` directly in any vhost's real `docRoot` (read from the rendered `vhconf.conf` files, refreshed only when `httpd_config.conf` changes); legacy `*/public_html/.htaccess` only as a fallback when the set is empty; deep plugin `.htaccess` files still do not trigger. New `scripts/tests/ols-htaccess-watcher.test.sh` + CI wiring.
## Proof (images built locally with docker from this branch)
- **Prod unchanged**: container run in PROD mode (no `environment`, no `DOCROOT_SUBDIR`) from the published `cac:php85` and from the new build; `/etc/httpd/conf.d`, `conf.modules.d`, `httpd.conf`, `/etc/php-fpm.d`, `php-fpm.conf`, `php.ini`, `php.d` (70 files) are **identical** (`diff -r`). php84: identical except `remoteip.conf`, which holds the container's own docker network address (differs per container run).
- **local-dev.sh from a fresh checkout** (`git archive`), `-a 83`, `-a 84`, `-a 85`: container healthy, WordPress downloaded + wp-config created, front page answers, PHP 8.3.37 / 8.4.28 / 8.5.13 as per tag, `.htaccess` rewrite works, host edits show immediately (twice, opcache revalidate 0), DEV MariaDB 11.4.14 and memcached work from PHP, posix present, `display_errors=1`, files stay owned by the host uid, redirect `https://ld83-local.dev:19483/x` keeps the port.
- **README manual recipe** (`uid=$(id -u)`, `PHPVER=84`, `XDEBUG=1`): healthy, Xdebug loaded, and a real DBGp init packet arrived at a listener on host port 9003.
- **DOCROOT_SUBDIR=public** with a CI4-like tree: `/`, pretty URLs and static files served from `public/`; `vendor/`, `app/` and `.env` are not reachable as files (requests fall into the app's front controller, `.env` is 403); `public_html/.htaccess` is not read. 24 valid/invalid values tested against the validator (including newline injection and cgi-bin).
- **DEV failure visibility**: `--network none` DEV container exits 1 with the FATAL banner listing MariaDB/memcached/Xdebug.
- **shared-ols** (real `shared-ols` image built from this branch, two tenants): folder-site `.htaccess` edit -> `graceful restart issued` and the new rewrite takes effect (302); normal-site edit still triggers; deep plugin file does not; the original image does NOT reload for the folder site. The 9-case test passes inside the image.
## Notes
- Known limitation (pre-existing, not changed): inotify misses tenant directories created after the watcher starts; see the long comment in the watcher.
- `local-dev.sh` WordPress step downloads core only into an empty web root.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
- mkdir of user/logs/{apache,system} was quoted (literal {apache,system} dir) and is no longer needed: the entrypoint creates logs itself
- drop the /var/log and /etc/httpd/logs bind mounts, which collided with the entrypoint (mv of /var/log/httpd: Device or resource busy, then 'unsafe entry' refusal to start)
- read credentials from /home/<user>/mysql_creds (where the entrypoint writes them), not /var/lib/mysql/creds
- -a N (and the default 83) now selects the image tag cac:phpNN instead of always pulling latest (latest is PHP 8.5); validated; CAC_IMAGE overrides for a locally built image
- wait for the container to be healthy (or fail with its logs) instead of sleep 160; WordPress download runs as the user and only into an empty web root
- instance_logs/instance_db_info use docker logs / the right creds path
- new flags -d (DOCROOT_SUBDIR) and -x (XDEBUG) and PUBLIC_HTTPS_PORT are passed through; they take effect with the image changes in the following commits
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
The PHP version is the image tag (cac:phpNN); PHPVER was only a leftover default. README/CLAUDE.md now state that, that cac:latest is PHP 8.5 today (not 8.3), and fix the stale PHP_VER build arg name. In DEV mode only, entrypoint.sh and entrypoint-fpm.sh warn loudly at start if an explicitly set PHPVER does not match the image's PHP (new scripts/dev-mode.sh, sourced in DEV only). PROD is untouched.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
microdnf install MariaDB-server MariaDB-client memcached died in depsolve (MariaDB-client obsoletes the image's AppStream mariadb; mariadb-client-utils requires it), after which the entrypoint carried on: no mysqld, a mysql_creds file for a database that did not exist, and a container that reported healthy. Now (scripts/dev-mode.sh, used by cac and cac-fpm):
- dnf install --allowerasing MariaDB-server MariaDB-client from mariadb.org 11.4, falling back to AlmaLinux mariadb-server; memcached from AppStream; --setopt=skip_if_unavailable so one dead repo does not block the rest; install skipped when already present (docker start)
- initialise/chown the data dir, start mysqld, wait for mysqladmin ping (60 s) instead of sleep 10
- any failure is logged loudly (FATAL banner) and the entrypoint exits non-zero. The HEALTHCHECK only probes Apache, so 'unhealthy' could not express this; a non-zero exit is unmistakable in docker ps/logs. PROD never runs this code.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
The fixed uid=30001 recipe fails on a normal host (host-created logs/ is owned by the host uid, the entrypoint then cannot mkdir under it). Use -e uid=$(id -u) -e user=$(whoami), do not pre-create logs/, pick the PHP version by tag, mention PUBLIC_HTTPS_PORT. The entrypoint has no gid variable (adduser -u derives it), so only uid is documented. AlmaLinux 9 -> 10.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
All DEV only (environment=DEV); production containers never read any of it and render identical config.
- /etc/php.d/99-dev.ini: display_errors=On, opcache.revalidate_freq=0 (error_reporting stays at the prod value: E_DEPRECATED floods wp-cli and PHP 8.5 startup)
- XDEBUG=1 installs php-pecl-xdebug3 from the same Remi module stream as the image's PHP and writes 98-xdebug-dev.ini (XDEBUG_MODE, XDEBUG_START, XDEBUG_CLIENT_HOST default host.docker.internal, XDEBUG_CLIENT_PORT default 9003; values validated); failure to install is a DEV failure (non-zero exit)
- php-process (posix) installed best effort
- create-vhost.sh: with PUBLIC_HTTPS_PORT set (DEV, not 443) the HTTP->HTTPS rewrite keeps the port
- README: DEV mode and Xdebug client settings sections
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
New env var DOCROOT_SUBDIR (default empty = unchanged bytes of the rendered vhost, verified by diff against the published image). Validated like WHP's panel/internal/vhost/docrootsub: ASCII letters, digits, . _ -; up to 4 segments, 64 bytes per segment, 128 total; no segment starting with . or -; no . / .. / empty segment; cgi-bin and the other reserved names refused; newline-safe. Invalid = FATAL message and exit 1. When set, DocumentRoot and the <Directory> move to public_html/<sub> and public_html itself gets Options None / AllowOverride None / Require all denied, the same shape WHP renders on the shared tier. The folder is created (as the customer) if missing. entrypoint now stops if create-vhost.sh fails.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
The watcher only matched */public_html/.htaccess, so sites with a
document-root folder (docRoot public_html/<sub>) never triggered a reload.
Match .htaccess directly inside any docRoot taken from the rendered
$SITES_ROOT/*/vhconf.conf (set refreshed only when httpd_config.conf changes);
legacy match kept as fallback when the set is empty. Deep plugin .htaccess
files still do not trigger. Adds a stubbed-lswsctrl test and CI wiring.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
Independent review (posted as COMMENT: the API refuses self-approval with this account): APPROVE for code, merge only with coordination (do not merge blind)
I re-tested this independently and did not rely on the author's proof. One fix is pushed (64ebfa6, CI only). Nothing here blocks the merge. Before merging, Josh should run the DB check in finding 1 and pick a merge strategy (below).
Production equivalence (the critical part)
Method: I pulled the currently publishedcac:php83/84/85, cac-fpm:php83/84/85 and shared-ols:latest. First I confirmed that the runtime scripts in each published image are byte-identical to origin/trunk (only CI/build-time scripts differ). Then I built two overlays on the same published image: published + trunk scripts/, and published + PR scripts/. Both have the same packages, so any difference comes from the PR alone. Each overlay ran twice: with no environment (what WHP sends; the cac/cac-fpm env profile is only uid/user/domain) and with environment=PROD. All runs used a fixed network IP, so remoteip.conf matches too. That file's diff in the author's run was the per-container docker network address.
posix is not added by any Dockerfile. It is installed at runtime in DEV only, and php -m is identical in prod, so this is not a prod change.
New exit 1 paths: dev_report_failures runs only under environment=DEV. create-vhost.sh || exit 1 can only fire in prod if writing /etc/httpd/conf.d/$domain.conf fails; before this PR httpd would have started without the vhost. Without DEV or DOCROOT_SUBDIR (WHP sends neither), neither path is reachable.
Real builds from this branch succeed: cac:php85, cac-fpm:php83 and shared-ols. Their rendered config is identical to the published images. (My local AlmaLinux base was stale, so the package-level drift I saw is not meaningful; CI resolves the digest fresh.)
shared-ols watcher (runs in production): sound
9/9 ols-htaccess-watcher.test.sh pass inside the overlay image and inside the real image built from this branch.
Extra adversarial run inside the image with 600 vhconfs:
Directory names $(touch /tmp/PWNED), a backtick payload, a]b, @ and *: no injection, no trigger. Docroot paths are only ever data: an awk read plus an associative-array lookup, never eval or arguments.
Refresh of 600 docroots: fine. 300 deep plugin .htaccess writes: 0 restarts and about 0 s CPU.
A folder change (vhconf rewritten plus a re-render) is picked up: the new docroot triggers, the old public_html/.htaccess does not.
Refresh relies on render-shared-ols-config.sh doing mv of a temp file on every render. That gives a new inode each time, so the signature changes. privd's reloadOls runs the render after every vhost write, so the set never goes stale while OLS is serving a site.
An empty or unparseable set falls back to the legacy */public_html/.htaccess match, so a parse failure is never less sensitive than before.
Prod behaviour change, and a positive one: the watcher now fires only for OLS tenants' docroots. Before, it fired for any tenant's public_html/.htaccess under /mnt/users, including shared-httpd and standalone tenants, so there will be fewer pointless OLS restarts.
WHP privd passes sites.user_variables through to the container (spec/builder.go userVars). Its deny list does not cover environment, XDEBUG, DOCROOT_SUBDIR or PUBLIC_HTTPS_PORT. A prod site that carries environment=DEV would now install MariaDB and memcached from the internet on every start, and would exit 1 and restart-loop if those repos are unreachable. Before this PR it went healthy with a broken DB.
Before merge, run SELECT id, user_variables FROM whp.sites WHERE user_variables REGEXP 'environment|XDEBUG|DOCROOT_SUBDIR|PUBLIC_HTTPS_PORT';. Follow-up in WHP: add these names to the privd user-variable deny list.
Low
scripts/create-vhost.sh:35-54
DOCROOT_SUBDIR is honoured in PROD mode too, not gated on DEV. Through user_variables, a standalone cac site could get a folder web root outside WHP's tier gate and its WordPress/site-builder guards. The value is validated exactly like WHP's docrootsub (I checked against the Go source and tested ../etc, cgi-bin, newline injection, 5-deep paths and .git: all FATAL). The effect stays inside the customer's own container.
Design call: gate on DEV, or deny-list it in privd. Not changed here.
The inotify-tools install ran without apt-get update. On runners with shellcheck preinstalled there are no apt lists, so the watcher test silently SKIPped.
apt-get update added; YAML and the multiarch wiring test (40) still pass.
Low (pre-existing, not this PR)
scripts/ols-htaccess-watcher.shdo_restart
A docroot change within FLOOR (60 s) of the last restart is dropped, not deferred: a second permalink save inside a minute does not apply until the next event. Separately, a tenant directory name containing a newline can forge a docroot line (worst case: one rate-limited restart).
Separate follow-up: deferred restart; NUL-separated inotify output.
Nit
scripts/dev-mode.sh:107
The XDEBUG_START=yes default prints "Could not connect to debugging client" on every CLI call (wp-cli) when no IDE is listening.
Consider trigger, or set xdebug.log_level=0.
Tests run
bash -n on all changed scripts.
shellcheck: the CI set of 32 files is clean. dev-mode.sh and local-dev.sh are clean. create-vhost.sh has only the pre-existing SC2154 warnings. entrypoint.sh went from 8 warnings to 4.
multiarch-workflow.test.py: 40 OK. The lsphp pin and repo-version tests and the assemble guard test pass.
Watcher test: 9/9 in both shared-ols images, plus the adversarial run above.
local-dev.sh from a fresh git archive (-a 83 -x -p 18083 -s 18443):
healthy in 44 s; WordPress downloaded and configured; PHP 8.3.37
MariaDB 11.4.14 and memcached running; posix, Xdebug and display_errors on
files stay owned by the host uid
redirect goes to https://…:18443/x
restart is healthy in 8 s
DEV with --network none: exit 1 with the FATAL banner.
DOCROOT_SUBDIR=public: vhost has the parent deny block and the docroot is public_html/public.
Merge coordination
A push to trunk builds all six families with phpNN tags and latest. Trunk also carries #51 to #58, which were merged with [skip ci] and have never been built. Published runtime scripts equal trunk, so for cac and cac-fpm those commits change only build and CI scripts (lsphp/litespeed build, multiarch assembly). Every family is still rebuilt against current upstream packages.
Lower blast radius: merge with [skip ci] in the merge message, then workflow_dispatch with only=cac,cac-fpm,shared-ols. This PR does not touch cac-litespeed, cac-lsphp or shared-httpd.
Pickup: running containers do not change. A site gets the new image only when WHP recreates its container (site update or recreate, auto_recreate_on_update during WHP updates) and pulls the tag. shared-ols changes on a host when its tier container is recreated (shared-ols:latest). Watch one recreated cac-fpm site and the canary's shared-ols (docker logs should show docroot set refreshed: N vhost docroot(s) on the first .htaccess edit) before the fleet picks it up.
## Independent review (posted as COMMENT: the API refuses self-approval with this account): APPROVE for code, merge only with coordination (do not merge blind)
I re-tested this independently and did not rely on the author's proof. One fix is pushed (64ebfa6, CI only). Nothing here blocks the merge. Before merging, Josh should run the DB check in finding 1 and pick a merge strategy (below).
### Production equivalence (the critical part)
Method: I pulled the **currently published** `cac:php83/84/85`, `cac-fpm:php83/84/85` and `shared-ols:latest`. First I confirmed that the runtime scripts in each published image are byte-identical to `origin/trunk` (only CI/build-time scripts differ). Then I built two overlays on the same published image: published + trunk `scripts/`, and published + PR `scripts/`. Both have the same packages, so any difference comes from the PR alone. Each overlay ran twice: with no `environment` (what WHP sends; the `cac`/`cac-fpm` env profile is only uid/user/domain) and with `environment=PROD`. All runs used a fixed network IP, so `remoteip.conf` matches too. That file's diff in the author's run was the per-container docker network address.
| image | mode | /etc/httpd + php-fpm.d + php-fpm.conf + php.ini + php.d + crontab + passwd | rpm -qa | ps | /home tree (mode/owner) | php -m | HTTP | logs | exit/health | start |
|---|---|---|---|---|---|---|---|---|---|---|
| cac:php83 | none / PROD | 74 files identical | same | same | same | same | same | same | 0 / healthy | 6.1 s vs 6.2 s |
| cac:php84 | none / PROD | 74 identical | same | same | same | same | same | same | 0 / healthy | ≈ |
| cac:php85 | none / PROD | 74 identical | same | same | same | same | same | same | 0 / healthy | ≈ |
| cac-fpm:php83 | none / PROD | 64 identical | same | same | same | same | same | same | 0 / healthy | ≈ |
| cac-fpm:php84 | none / PROD | 64 identical | same | same | same | same | same | same | 0 / healthy | ≈ |
| cac-fpm:php85 | none / PROD | 64 identical | same | same | same | same | same | same | 0 / healthy | ≈ |
- **posix** is not added by any Dockerfile. It is installed at runtime in DEV only, and `php -m` is identical in prod, so this is **not a prod change**.
- New `exit 1` paths: `dev_report_failures` runs only under `environment=DEV`. `create-vhost.sh || exit 1` can only fire in prod if writing `/etc/httpd/conf.d/$domain.conf` fails; before this PR httpd would have started without the vhost. Without DEV or `DOCROOT_SUBDIR` (WHP sends neither), neither path is reachable.
- Real builds from this branch succeed: `cac:php85`, `cac-fpm:php83` and `shared-ols`. Their rendered config is identical to the published images. (My local AlmaLinux base was stale, so the package-level drift I saw is not meaningful; CI resolves the digest fresh.)
### shared-ols watcher (runs in production): sound
- 9/9 `ols-htaccess-watcher.test.sh` pass inside the overlay image and inside the real image built from this branch.
- Extra adversarial run inside the image with 600 vhconfs:
- Directory names `$(touch /tmp/PWNED)`, a backtick payload, `a]b`, `@` and `*`: **no injection**, no trigger. Docroot paths are only ever data: an awk read plus an associative-array lookup, never `eval` or arguments.
- Refresh of 600 docroots: fine. 300 deep plugin `.htaccess` writes: 0 restarts and about 0 s CPU.
- A folder change (vhconf rewritten plus a re-render) is picked up: the new docroot triggers, the old `public_html/.htaccess` does not.
- Refresh relies on `render-shared-ols-config.sh` doing `mv` of a temp file on every render. That gives a new inode each time, so the signature changes. privd's `reloadOls` runs the render after every vhost write, so the set never goes stale while OLS is serving a site.
- An empty or unparseable set falls back to the legacy `*/public_html/.htaccess` match, so a parse failure is never less sensitive than before.
- Prod behaviour change, and a positive one: the watcher now fires only for OLS tenants' docroots. Before, it fired for any tenant's `public_html/.htaccess` under `/mnt/users`, including shared-httpd and standalone tenants, so there will be fewer pointless OLS restarts.
### Findings
| sev | where | finding | action |
|---|---|---|---|
| Medium (conditional) | `scripts/entrypoint.sh:77-85`, `scripts/dev-mode.sh:33-45` | WHP privd passes `sites.user_variables` through to the container (`spec/builder.go userVars`). Its deny list does not cover `environment`, `XDEBUG`, `DOCROOT_SUBDIR` or `PUBLIC_HTTPS_PORT`. A prod site that carries `environment=DEV` would now install MariaDB and memcached from the internet on every start, and would **exit 1 and restart-loop** if those repos are unreachable. Before this PR it went healthy with a broken DB. | Before merge, run `SELECT id, user_variables FROM whp.sites WHERE user_variables REGEXP 'environment\|XDEBUG\|DOCROOT_SUBDIR\|PUBLIC_HTTPS_PORT';`. Follow-up in WHP: add these names to the privd user-variable deny list. |
| Low | `scripts/create-vhost.sh:35-54` | `DOCROOT_SUBDIR` is honoured in PROD mode too, not gated on DEV. Through user_variables, a standalone cac site could get a folder web root outside WHP's tier gate and its WordPress/site-builder guards. The value is validated exactly like WHP's `docrootsub` (I checked against the Go source and tested `../etc`, `cgi-bin`, newline injection, 5-deep paths and `.git`: all FATAL). The effect stays inside the customer's own container. | Design call: gate on DEV, or deny-list it in privd. Not changed here. |
| Low (fixed, 64ebfa6) | `.gitea/workflows/build-push.yaml` | The inotify-tools install ran without `apt-get update`. On runners with shellcheck preinstalled there are no apt lists, so the watcher test silently SKIPped. | `apt-get update` added; YAML and the multiarch wiring test (40) still pass. |
| Low (pre-existing, not this PR) | `scripts/ols-htaccess-watcher.sh` `do_restart` | A docroot change within `FLOOR` (60 s) of the last restart is **dropped, not deferred**: a second permalink save inside a minute does not apply until the next event. Separately, a tenant directory name containing a newline can forge a docroot line (worst case: one rate-limited restart). | Separate follow-up: deferred restart; NUL-separated inotify output. |
| Nit | `scripts/dev-mode.sh:107` | The `XDEBUG_START=yes` default prints "Could not connect to debugging client" on every CLI call (wp-cli) when no IDE is listening. | Consider `trigger`, or set `xdebug.log_level=0`. |
### Tests run
- `bash -n` on all changed scripts.
- shellcheck: the CI set of 32 files is clean. `dev-mode.sh` and `local-dev.sh` are clean. `create-vhost.sh` has only the pre-existing SC2154 warnings. `entrypoint.sh` went from 8 warnings to 4.
- `multiarch-workflow.test.py`: 40 OK. The lsphp pin and repo-version tests and the assemble guard test pass.
- Watcher test: 9/9 in both shared-ols images, plus the adversarial run above.
- `local-dev.sh` from a fresh `git archive` (`-a 83 -x -p 18083 -s 18443`):
- healthy in 44 s; WordPress downloaded and configured; PHP 8.3.37
- MariaDB 11.4.14 and memcached running; posix, Xdebug and display_errors on
- files stay owned by the host uid
- redirect goes to `https://…:18443/x`
- restart is healthy in 8 s
- DEV with `--network none`: exit 1 with the FATAL banner.
- `DOCROOT_SUBDIR=public`: vhost has the parent deny block and the docroot is `public_html/public`.
### Merge coordination
- A push to trunk builds **all six families** with `phpNN` tags and `latest`. Trunk also carries #51 to #58, which were merged with `[skip ci]` and have never been built. Published runtime scripts equal trunk, so for cac and cac-fpm those commits change only build and CI scripts (lsphp/litespeed build, multiarch assembly). Every family is still rebuilt against current upstream packages.
- Lower blast radius: merge with `[skip ci]` in the merge message, then `workflow_dispatch` with `only=cac,cac-fpm,shared-ols`. This PR does not touch cac-litespeed, cac-lsphp or shared-httpd.
- Pickup: running containers do not change. A site gets the new image only when WHP recreates its container (site update or recreate, `auto_recreate_on_update` during WHP updates) and pulls the tag. shared-ols changes on a host when its tier container is recreated (`shared-ols:latest`). Watch one recreated cac-fpm site and the canary's shared-ols (`docker logs` should show `docroot set refreshed: N vhost docroot(s)` on the first `.htaccess` edit) before the fleet picks it up.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
Review follow-up (PR #61 review 121):
- create-vhost.sh ignores DOCROOT_SUBDIR (log line) unless environment=DEV,
and entrypoint.sh only creates the folder in DEV. Defence in depth so a
production container cannot move its web root through the env, even if a
site owner got the variable into the container (WHP also denies it now).
- dev-mode.sh: XDEBUG_START defaults to trigger instead of yes, so CLI runs
(wp-cli) do not print "Could not connect to debugging client" without an
IDE. XDEBUG_START=yes still connects on every request.
- README/CLAUDE.md updated.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
You are not authorized to merge this pull request.
This pull request can be merged automatically.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
DO NOT MERGE without coordination
Merging this to
trunkpublishes images used by the production fleet..gitea/workflows/build-push.yamltriggers on every push totrunkand builds + pushes ALL families (cac, cac-fpm, cac-litespeed, cac-lsphp, shared-httpd, shared-ols) with theirphpNNtags andlatest(= php85). This PR changes files copied intocac,cac-fpm(entrypoints,create-vhost.sh, newdev-mode.sh) andshared-ols(ols-htaccess-watcher.sh). Production behaviour of cac is unchanged (see the diff proof below), but the new images still reach production tags on merge, so schedule it with the fleet rollout. The PR itself triggers no CI (push-to-trunk only); the checks below were run locally.Does not touch
Dockerfile.shared-httpdor any shared-httpd file (PR #59 and the symlink prototype are unaffected).What changed (one commit per item)
{apache,system}dir), removed the/var/logand/etc/httpd/logsmounts that collided with the entrypoint, credentials from/home/<user>/mysql_creds,-a Nselects thecac:phpNNtag (neverlatest), waits for healthy instead ofsleep 160, WordPress only into an empty web root.CAC_IMAGEoverrides the image (used to test local builds).latest= PHP 8.5 today; DEV-only startup warning when an explicitPHPVERdoes not match the image.dnf --allowerasing MariaDB-server MariaDB-client(mariadb.org 11.4, fallback AlmaLinux mariadb-server), memcached from AppStream, readiness wait, and any failure is a loud FATAL banner plus exit 1 (the HEALTHCHECK only probes Apache, so "unhealthy" could not express it). PROD never runs this. Applied to cac and cac-fpm (same broken block).uid=$(id -u)/user=$(whoami), AlmaLinux 10. There is no gid variable in the entrypoint, so only uid is documented.display_errors=On,opcache.revalidate_freq=0,XDEBUG=1(Remiphp-pecl-xdebug3for the image's PHP;XDEBUG_MODE/START/CLIENT_HOST/CLIENT_PORT),posix(php-process), HTTP->HTTPS redirect keeps a non-standard port (PUBLIC_HTTPS_PORT, set by local-dev.sh from-s).error_reportingis intentionally left at the prod value (E_DEPRECATED floods wp-cli and PHP 8.5 startup).DOCROOT_SUBDIR: Apache DocumentRoot =public_html/<sub>, validated with the same rules as WHP'spanel/internal/vhost/docrootsub(ASCII letters/digits/./_/-, max 4 segments, 64 bytes per segment, 128 total, no segment starting with.or-, no./../empty,cgi-binand the other reserved names refused, newline-safe). Parentpublic_htmlgetsOptions None / AllowOverride None / Require all denied(same shape WHP renders). Unset = byte-identical vhost.ols-htaccess-watcher.shnow triggers on.htaccessdirectly in any vhost's realdocRoot(read from the renderedvhconf.conffiles, refreshed only whenhttpd_config.confchanges); legacy*/public_html/.htaccessonly as a fallback when the set is empty; deep plugin.htaccessfiles still do not trigger. Newscripts/tests/ols-htaccess-watcher.test.sh+ CI wiring.Proof (images built locally with docker from this branch)
environment, noDOCROOT_SUBDIR) from the publishedcac:php85and from the new build;/etc/httpd/conf.d,conf.modules.d,httpd.conf,/etc/php-fpm.d,php-fpm.conf,php.ini,php.d(70 files) are identical (diff -r). php84: identical exceptremoteip.conf, which holds the container's own docker network address (differs per container run).git archive),-a 83,-a 84,-a 85: container healthy, WordPress downloaded + wp-config created, front page answers, PHP 8.3.37 / 8.4.28 / 8.5.13 as per tag,.htaccessrewrite works, host edits show immediately (twice, opcache revalidate 0), DEV MariaDB 11.4.14 and memcached work from PHP, posix present,display_errors=1, files stay owned by the host uid, redirecthttps://ld83-local.dev:19483/xkeeps the port.uid=$(id -u),PHPVER=84,XDEBUG=1): healthy, Xdebug loaded, and a real DBGp init packet arrived at a listener on host port 9003./, pretty URLs and static files served frompublic/;vendor/,app/and.envare not reachable as files (requests fall into the app's front controller,.envis 403);public_html/.htaccessis not read. 24 valid/invalid values tested against the validator (including newline injection and cgi-bin).--network noneDEV container exits 1 with the FATAL banner listing MariaDB/memcached/Xdebug.shared-olsimage built from this branch, two tenants): folder-site.htaccessedit ->graceful restart issuedand the new rewrite takes effect (302); normal-site edit still triggers; deep plugin file does not; the original image does NOT reload for the folder site. The 9-case test passes inside the image.Notes
local-dev.shWordPress step downloads core only into an empty web root.🤖 Generated with Claude Code
https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
- mkdir of user/logs/{apache,system} was quoted (literal {apache,system} dir) and is no longer needed: the entrypoint creates logs itself - drop the /var/log and /etc/httpd/logs bind mounts, which collided with the entrypoint (mv of /var/log/httpd: Device or resource busy, then 'unsafe entry' refusal to start) - read credentials from /home/<user>/mysql_creds (where the entrypoint writes them), not /var/lib/mysql/creds - -a N (and the default 83) now selects the image tag cac:phpNN instead of always pulling latest (latest is PHP 8.5); validated; CAC_IMAGE overrides for a locally built image - wait for the container to be healthy (or fail with its logs) instead of sleep 160; WordPress download runs as the user and only into an empty web root - instance_logs/instance_db_info use docker logs / the right creds path - new flags -d (DOCROOT_SUBDIR) and -x (XDEBUG) and PUBLIC_HTTPS_PORT are passed through; they take effect with the image changes in the following commits Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6Independent review (posted as COMMENT: the API refuses self-approval with this account): APPROVE for code, merge only with coordination (do not merge blind)
I re-tested this independently and did not rely on the author's proof. One fix is pushed (
64ebfa6, CI only). Nothing here blocks the merge. Before merging, Josh should run the DB check in finding 1 and pick a merge strategy (below).Production equivalence (the critical part)
Method: I pulled the currently published
cac:php83/84/85,cac-fpm:php83/84/85andshared-ols:latest. First I confirmed that the runtime scripts in each published image are byte-identical toorigin/trunk(only CI/build-time scripts differ). Then I built two overlays on the same published image: published + trunkscripts/, and published + PRscripts/. Both have the same packages, so any difference comes from the PR alone. Each overlay ran twice: with noenvironment(what WHP sends; thecac/cac-fpmenv profile is only uid/user/domain) and withenvironment=PROD. All runs used a fixed network IP, soremoteip.confmatches too. That file's diff in the author's run was the per-container docker network address.php -mis identical in prod, so this is not a prod change.exit 1paths:dev_report_failuresruns only underenvironment=DEV.create-vhost.sh || exit 1can only fire in prod if writing/etc/httpd/conf.d/$domain.conffails; before this PR httpd would have started without the vhost. Without DEV orDOCROOT_SUBDIR(WHP sends neither), neither path is reachable.cac:php85,cac-fpm:php83andshared-ols. Their rendered config is identical to the published images. (My local AlmaLinux base was stale, so the package-level drift I saw is not meaningful; CI resolves the digest fresh.)shared-ols watcher (runs in production): sound
ols-htaccess-watcher.test.shpass inside the overlay image and inside the real image built from this branch.$(touch /tmp/PWNED), a backtick payload,a]b,@and*: no injection, no trigger. Docroot paths are only ever data: an awk read plus an associative-array lookup, neverevalor arguments..htaccesswrites: 0 restarts and about 0 s CPU.public_html/.htaccessdoes not.render-shared-ols-config.shdoingmvof a temp file on every render. That gives a new inode each time, so the signature changes. privd'sreloadOlsruns the render after every vhost write, so the set never goes stale while OLS is serving a site.*/public_html/.htaccessmatch, so a parse failure is never less sensitive than before.public_html/.htaccessunder/mnt/users, including shared-httpd and standalone tenants, so there will be fewer pointless OLS restarts.Findings
scripts/entrypoint.sh:77-85,scripts/dev-mode.sh:33-45sites.user_variablesthrough to the container (spec/builder.go userVars). Its deny list does not coverenvironment,XDEBUG,DOCROOT_SUBDIRorPUBLIC_HTTPS_PORT. A prod site that carriesenvironment=DEVwould now install MariaDB and memcached from the internet on every start, and would exit 1 and restart-loop if those repos are unreachable. Before this PR it went healthy with a broken DB.SELECT id, user_variables FROM whp.sites WHERE user_variables REGEXP 'environment|XDEBUG|DOCROOT_SUBDIR|PUBLIC_HTTPS_PORT';. Follow-up in WHP: add these names to the privd user-variable deny list.scripts/create-vhost.sh:35-54DOCROOT_SUBDIRis honoured in PROD mode too, not gated on DEV. Through user_variables, a standalone cac site could get a folder web root outside WHP's tier gate and its WordPress/site-builder guards. The value is validated exactly like WHP'sdocrootsub(I checked against the Go source and tested../etc,cgi-bin, newline injection, 5-deep paths and.git: all FATAL). The effect stays inside the customer's own container.64ebfa6).gitea/workflows/build-push.yamlapt-get update. On runners with shellcheck preinstalled there are no apt lists, so the watcher test silently SKIPped.apt-get updateadded; YAML and the multiarch wiring test (40) still pass.scripts/ols-htaccess-watcher.shdo_restartFLOOR(60 s) of the last restart is dropped, not deferred: a second permalink save inside a minute does not apply until the next event. Separately, a tenant directory name containing a newline can forge a docroot line (worst case: one rate-limited restart).scripts/dev-mode.sh:107XDEBUG_START=yesdefault prints "Could not connect to debugging client" on every CLI call (wp-cli) when no IDE is listening.trigger, or setxdebug.log_level=0.Tests run
bash -non all changed scripts.dev-mode.shandlocal-dev.share clean.create-vhost.shhas only the pre-existing SC2154 warnings.entrypoint.shwent from 8 warnings to 4.multiarch-workflow.test.py: 40 OK. The lsphp pin and repo-version tests and the assemble guard test pass.local-dev.shfrom a freshgit archive(-a 83 -x -p 18083 -s 18443):https://…:18443/x--network none: exit 1 with the FATAL banner.DOCROOT_SUBDIR=public: vhost has the parent deny block and the docroot ispublic_html/public.Merge coordination
phpNNtags andlatest. Trunk also carries #51 to #58, which were merged with[skip ci]and have never been built. Published runtime scripts equal trunk, so for cac and cac-fpm those commits change only build and CI scripts (lsphp/litespeed build, multiarch assembly). Every family is still rebuilt against current upstream packages.[skip ci]in the merge message, thenworkflow_dispatchwithonly=cac,cac-fpm,shared-ols. This PR does not touch cac-litespeed, cac-lsphp or shared-httpd.auto_recreate_on_updateduring WHP updates) and pulls the tag. shared-ols changes on a host when its tier container is recreated (shared-ols:latest). Watch one recreated cac-fpm site and the canary's shared-ols (docker logsshould showdocroot set refreshed: N vhost docroot(s)on the first.htaccessedit) before the fleet picks it up.🤖 Generated with Claude Code
https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.