Files
cloud-apache-container/docs/shared-httpd-symlink-module.md
shadowdaoandClaude Sonnet 5.5 cc68d30d57
shared-httpd mod_whp_symlink PR check / Symlink-Module-Probe (pull_request) Successful in 2m25s
ci(mod_whp_symlink): harden PR job on shared runners; publish builds never reuse cache
- PR workflow: no secrets/registry login, checkout without persisted credentials,
  docker build --pull --no-cache, per-run tag shared-httpd:pr-probe-<run_id>,
  always() cleanup of the image and containers.
- build-push.yaml: every docker/build-push-action step gets pull: true and
  no-cache: true (base is already digest-pinned by the resolve step).
- Wiring tests for both; docs: CI trust model.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-23 07:35:18 -08:00

3.1 KiB

shared-httpd: mod_whp_symlink (tenant symlink safety)

Source: src/mod_whp_symlink/mod_whp_symlink.c, built in a separate stage of Dockerfile.shared-httpd against the distribution httpd-devel (the runtime keeps the stock AlmaLinux httpd RPMs). Defaults: configs/whp-symlink.conf.

What it does

  • WHPHtaccessOptionsRemap On: rewrites a tenant .htaccess Options line before the core parses it, deny-by-default (only known-safe keywords are emitted, a name is only emitted when AllowOverride Options= permits it):
    • any FollowSymLinks form becomes SymLinksIfOwnerMatch;
    • any Includes form becomes IncludesNOEXEC, positive ExecCGI is dropped;
    • bare All keeps Apache semantics (All includes Indexes and excludes MultiViews), so it becomes Indexes SymLinksIfOwnerMatch under WHP's Options= list;
    • quoted/escaped lines are refused (config error, 500, nothing enabled).
  • WHPOwnerGuard Off|Log|On (+ WHPOwnerGuardRoot): fstat() owner check on the file descriptor actually served; closes the SymLinksIfOwnerMatch check-then-open race and the swapped-public_html case. Ships in Log mode.

The earlier WHPSymlinkWalk prototype (post-walk lstat check) was removed: it is racy by construction, the owner guard is the race-free mechanism.

Probe test

scripts/tests/whp-symlink-module.test.sh [image] starts the image, creates two tenants and probes every Options form, nested containers, the module directives, the swapped docroot and bare Options All (Indexes on, MultiViews off, same-owner symlink followed, cross-tenant refused).

Run locally (needs docker, about 5 minutes for the build):

docker build -f Dockerfile.shared-httpd -t shared-httpd:symtest .
WHP_SYMTEST_REQUIRE=1 ./scripts/tests/whp-symlink-module.test.sh shared-httpd:symtest

Without WHP_SYMTEST_REQUIRE=1 a missing docker or image is a SKIP (exit 0); with it, a FAIL. Any failed assertion exits 1.

CI

  • Pull requests touching the module, its config, Dockerfile.shared-httpd or the test: .gitea/workflows/shared-httpd-symlink-pr.yaml builds the amd64 image locally (no push, no secrets) and runs the test with WHP_SYMTEST_REQUIRE=1.
  • Publish: Build-Shared-httpd in build-push.yaml runs the same test against the amd64 image it just pushed by digest, before the arm64 build and the tag-assembly step. A failure publishes no tag. (amd64 only; the arm64 image is not probed.)

CI trust model

Gitea has only shared ubuntu-latest runners (two), used by the publish jobs and by PR jobs alike; there is no separate label for untrusted code. So:

  • The PR workflow runs PR-supplied Dockerfile and C source with no secrets and no registry login, builds with --pull --no-cache under a per-run tag (shared-httpd:pr-probe-<run_id>), and removes its image and containers in an if: always() step.
  • Every docker/build-push-action step in build-push.yaml sets pull: true and no-cache: true, on a fresh buildx builder per job and a digest-pinned base image, so no cache or local image from an earlier job on the runner is reused by a publish build.
  • Repo setting (maintainer's call): require approval for PR workflows from forks.