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

+1 -57
View File
@@ -44,12 +44,6 @@
* listings (names only), and PHP (read by the tenant's own FPM). The
* swapped-public_html listing needs WHP's <Directory "/mnt/users">
* Options SymLinksIfOwnerMatch; the guard alone does not close it.
*
* 3. WHPSymlinkWalk Off|Log|On (+ WHPOwnerGuardRoot <prefix>)
* Prototype of "re-implement SymLinksIfOwnerMatch after the walk": a
* fixups hook lstat()s every component of r->filename below the root and
* refuses (403) when a symlink's owner differs from its target's owner.
* Kept for comparison; see the recommendation document.
*/
#include "httpd.h"
#include "http_config.h"
@@ -76,7 +70,6 @@ typedef struct {
typedef struct {
int guard;
int walk;
const char *root;
} whp_dir_conf;
@@ -98,7 +91,6 @@ static void *create_dir(apr_pool_t *p, char *d)
{
whp_dir_conf *c = apr_pcalloc(p, sizeof(*c));
c->guard = MODE_UNSET;
c->walk = MODE_UNSET;
return c;
}
@@ -106,7 +98,6 @@ static void *merge_dir(apr_pool_t *p, void *b_, void *a_)
{
whp_dir_conf *b = b_, *a = a_, *c = apr_pcalloc(p, sizeof(*c));
c->guard = a->guard != MODE_UNSET ? a->guard : b->guard;
c->walk = a->walk != MODE_UNSET ? a->walk : b->walk;
c->root = a->root ? a->root : b->root;
return c;
}
@@ -301,11 +292,6 @@ static const char *cmd_guard(cmd_parms *cmd, void *d, const char *arg)
return set_mode(arg, &((whp_dir_conf *)d)->guard, 1);
}
static const char *cmd_walk(cmd_parms *cmd, void *d, const char *arg)
{
return set_mode(arg, &((whp_dir_conf *)d)->walk, 1);
}
static const char *cmd_root(cmd_parms *cmd, void *d, const char *arg)
{
((whp_dir_conf *)d)->root = arg;
@@ -384,45 +370,6 @@ static apr_status_t guard_filter(ap_filter_t *f, apr_bucket_brigade *bb)
return ap_pass_brigade(f->next, bb);
}
/* ------------------------------------------------------------------ */
/* 3. Post-walk lstat check (prototype of option b) */
static int walk_fixup(request_rec *r)
{
whp_dir_conf *dc = ap_get_module_config(r->per_dir_config,
&whp_symlink_module);
char *path, *p;
size_t rl;
if (dc->walk < MODE_LOG || !under_root(dc, r->filename))
return DECLINED;
path = apr_pstrdup(r->pool, r->filename);
rl = strlen(dc->root);
/* walk every component strictly below the root */
for (p = path + rl; ; p++) {
if (*p == '/' || *p == '\0') {
char save = *p;
struct stat ls, ts;
*p = '\0';
if (p > path + rl && lstat(path, &ls) == 0 && S_ISLNK(ls.st_mode)) {
if (stat(path, &ts) != 0 || ts.st_uid != ls.st_uid) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"whp_symlink: walk: symlink %s (owner %ld) "
"-> target owner %ld%s", path,
(long)ls.st_uid, (long)ts.st_uid,
dc->walk == MODE_ON ? " (refused)" : " (log only)");
if (dc->walk == MODE_ON)
return HTTP_FORBIDDEN;
}
}
*p = save;
if (!save)
break;
}
}
return DECLINED;
}
static const command_rec cmds[] = {
AP_INIT_RAW_ARGS("Options", options_remap, NULL, OR_OPTIONS,
"(whp_symlink) .htaccess Options remap; the core "
@@ -431,10 +378,8 @@ static const command_rec cmds[] = {
"On|Off: remap FollowSymLinks/Includes/ExecCGI/All in .htaccess Options"),
AP_INIT_TAKE1("WHPOwnerGuard", cmd_guard, NULL, RSRC_CONF | ACCESS_CONF,
"On|Log|Off: served file owner must equal DocumentRoot owner"),
AP_INIT_TAKE1("WHPSymlinkWalk", cmd_walk, NULL, RSRC_CONF | ACCESS_CONF,
"On|Log|Off: post-walk symlink owner check"),
AP_INIT_TAKE1("WHPOwnerGuardRoot", cmd_root, NULL, RSRC_CONF | ACCESS_CONF,
"path prefix the guard/walk apply to, e.g. /mnt/users/"),
"path prefix the guard applies to, e.g. /mnt/users/"),
{ NULL }
};
@@ -443,7 +388,6 @@ static void register_hooks(apr_pool_t *p)
ap_register_output_filter("WHP_OWNER_GUARD", guard_filter, NULL,
AP_FTYPE_RESOURCE - 1);
ap_hook_insert_filter(guard_insert, NULL, NULL, APR_HOOK_LAST);
ap_hook_fixups(walk_fixup, NULL, NULL, APR_HOOK_FIRST);
}
AP_DECLARE_MODULE(whp_symlink) = {