ci+chore(mod_whp_symlink): remove racy WHPSymlinkWalk prototype; run the probe test in CI; assert Options All mapping
shared-httpd mod_whp_symlink PR check / Symlink-Module-Probe (pull_request) Successful in 1m15s

- Remove the WHPSymlinkWalk post-walk lstat prototype (check-then-use race by
  construction; WHPOwnerGuard is the race-free mechanism): hook, directive,
  per-dir member, header docs. The directive is now an unknown command.
- Probe test: WHP_SYMTEST_REQUIRE=1 turns every SKIP into a FAIL (no docker, no
  image, container does not start) and a minimum assertion count is enforced.
  New assertions: bare `Options All` keeps Apache semantics (Indexes on,
  MultiViews off, same-owner symlink followed, cross-tenant refused) plus
  None/+MultiViews controls (106 assertions).
- CI: new pull_request workflow shared-httpd-symlink-pr.yaml (builds amd64
  locally, no push/secrets, runs the probe test); build-push.yaml
  Build-Shared-httpd runs the probe test against the amd64 digest it just pushed,
  before the arm64 build and tag assembly, so a failure publishes no tag.
  Test script added to the shellcheck set; wiring tests added.
- docs/shared-httpd-symlink-module.md: behaviour, local run, CI.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
This commit is contained in:
shadowdaoandClaude Sonnet 5.5 committed 2026-11-23 07:33:47 -08:00
1 parent 1953a176f5
commit 0d9e57e012
7 files changed
+161 -62

No files matched your search

+25 -4
View File
@@ -5,13 +5,18 @@
## shapes (`Options +FollowSymlinks`) no longer answer 500; the owner guard refuses
## a swapped public_html.
## whp-symlink-module.test.sh [image] (default shared-httpd:latest)
## SKIPs (exit 0) without docker or the image.
## Locally it SKIPs (exit 0) without docker or the image. With WHP_SYMTEST_REQUIRE=1
## (CI) a missing docker/image or a container that does not start FAILS instead,
## so the job can never go green without having run the probes.
## Build the image first: docker build -f Dockerfile.shared-httpd -t shared-httpd:symtest .
set -u
IMAGE="${1:-shared-httpd:latest}"
REQUIRE="${WHP_SYMTEST_REQUIRE:-0}"
skip() { if [ "$REQUIRE" = 1 ]; then echo "FAIL (required): $*"; exit 1; fi; echo "SKIP: $*"; exit 0; }
NAME="whp-symtest-$$"; T="$(mktemp -d)"
trap 'docker rm -f "$NAME" >/dev/null 2>&1; rm -rf "$T"' EXIT
command -v docker >/dev/null 2>&1 || { echo "SKIP: no docker"; exit 0; }
docker image inspect "$IMAGE" >/dev/null 2>&1 || { echo "SKIP: no image $IMAGE"; exit 0; }
command -v docker >/dev/null 2>&1 || skip "no docker"
docker image inspect "$IMAGE" >/dev/null 2>&1 || skip "no image $IMAGE"
fail=0; pass=0
ok() { pass=$((pass+1)); echo "ok $*"; }
bad() { fail=$((fail+1)); echo "FAIL $*"; }
@@ -108,13 +113,21 @@ EOF
printf "printf 'S<!--#exec cmd=\"id\" -->E\\\\n' > %s/p.shtml; printf '#!/bin/sh\\\\necho Content-type: text/plain\\\\necho\\\\nid\\\\n' > %s/p.cgi; chmod 755 %s/p.cgi\n" "$d" "$d" "$d"
done < "$T/blocks"
echo "echo $n > /nblocks"
# bare `Options All` (Apache semantics: everything except MultiViews) must map to
# `Indexes SymLinksIfOwnerMatch` here: directory listing on, MultiViews off (the
# site's base Options turn MultiViews on, and a bare absolute line resets it),
# same-owner symlink followed, cross-tenant symlink refused. Controls: `None`
# lists nothing, `+MultiViews` negotiates.
echo 'mkdir -p $A/all1 $A/all2 $A/all3; for d in all1 all2 all3; do echo OWN > $A/$d/own.txt; done'
echo 'ln -s own.txt $A/all1/same.txt; ln -s $B/secret.txt $A/all1/steal.txt'
echo 'printf "Options All\n" > $A/all1/.htaccess; printf "Options None\n" > $A/all2/.htaccess; printf "Options +MultiViews\n" > $A/all3/.htaccess'
# a tenant must not be able to switch the module off
echo 'mkdir -p $A/g1 $A/g2; echo OWN > $A/g1/own.txt; echo OWN > $A/g2/own.txt'
echo 'printf "WHPOwnerGuard Off\n" > $A/g1/.htaccess; printf "<If \"true\">\nWHPHtaccessOptionsRemap Off\n</If>\n" > $A/g2/.htaccess'
echo 'chmod -R a+rX /mnt/users; chown -R -h 1006:1006 /mnt/users/a; chown -R -h 1003:1003 /mnt/users/b'
} > "$T/fx.sh"
docker run -d --name "$NAME" "$IMAGE" >/dev/null || { echo "SKIP: cannot start $IMAGE"; exit 0; }
docker run -d --name "$NAME" "$IMAGE" >/dev/null || skip "cannot start $IMAGE"
sleep 3
docker cp "$T/site.conf" "$NAME:/etc/httpd/conf.d/vhosts/zz-symtest.conf" >/dev/null
docker cp "$T/fx.sh" "$NAME:/fx.sh" >/dev/null
@@ -143,6 +156,14 @@ for i in $(seq 1 "$N"); do
case "$x$c" in *uid=*) bad "block $blk: code executed" ;; *) ok "block $blk: no exec" ;; esac
[ "${o:0:3}" = 200 ] && ok "block $blk: directory works (200)" || bad "block $blk: own file ${o:0:3}"
done
# bare `Options All` keeps Apache's meaning (Indexes yes, MultiViews no) minus the unsafe parts
r=$(get a.test /all1/); case "$r" in 200*"Index of"*) ok "Options All: Indexes kept (listing 200)" ;; *) bad "Options All: no directory listing (${r:0:60})" ;; esac
r=$(get a.test /all1/own); [ "${r:0:3}" = 404 ] && ok "Options All: MultiViews not enabled (404)" || bad "Options All: MultiViews answered ${r:0:3}"
r=$(get a.test /all1/same.txt); [ "${r:0:3}" = 200 ] && ok "Options All: same-owner symlink followed (200)" || bad "Options All: same-owner symlink ${r:0:3}"
r=$(get a.test /all1/steal.txt); case "$r" in *B-SECRET*) bad "Options All: cross-tenant symlink read" ;; *) ok "Options All: cross-tenant symlink refused (${r:0:3})" ;; esac
r=$(get a.test /all2/); [ "${r:0:3}" = 403 ] && ok "control: Options None lists nothing (403)" || bad "control: Options None ${r:0:3}"
r=$(get a.test /all3/own); [ "${r:0:3}" = 200 ] && ok "control: +MultiViews negotiates (200)" || bad "control: +MultiViews ${r:0:3}"
[ "$pass" -ge 100 ] || bad "only $pass assertions ran (expected >= 100)"
for g in g1 g2; do
o=$(get a.test /$g/own.txt); [ "${o:0:3}" = 500 ] && ok "tenant cannot set module directives ($g: 500)" || bad "tenant module directive accepted ($g: ${o:0:3})"
done