feat(shared-httpd): mod_whp_symlink - .htaccess Options remap + served-file owner guard
Tenant .htaccess files that say `Options +FollowSymLinks` / `All` / `Includes` (stock CodeIgniter 4, Joomla, OpenCart, Magento) answer 500 on the shared tier since the AllowOverride Options= lockdown. A small loadable module, built against the distribution httpd-devel (stock AlmaLinux httpd RPMs stay): - WHPHtaccessOptionsRemap On: rewrites the Options line in .htaccess before the core parses it (FollowSymLinks -> SymLinksIfOwnerMatch, Includes -> IncludesNOEXEC, positive ExecCGI dropped), so those files work while the core's own owner-match symlink check stays in charge. Covers nested <If>. - WHPOwnerGuard Log|On: fstat() owner check on the file descriptor actually served (the Bluehost/cPanel SymlinkProtect idea, as an output filter); closes the SymLinksIfOwnerMatch check-then-open race and the swapped public_html case. Ships in Log mode. DRAFT: measured locally only, see the WHP-side write-up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
This commit is contained in:
1 parent
d4ec8b526c
commit
5fbc2e315e
3 files changed
+435
No files matched your search
@@ -3,6 +3,23 @@
|
||||
# so the pkg-cache registry mirror can only serve content-addressed blobs.
|
||||
# Local builds use the tag. docs/pkg-cache.md "Base-image digest pinning".
|
||||
ARG BASE_IMAGE=almalinux/10-base
|
||||
|
||||
# Build stage for mod_whp_symlink (src/mod_whp_symlink/): compiled against the
|
||||
# distribution httpd-devel, so the runtime keeps the stock AlmaLinux httpd RPMs
|
||||
# and their security updates. Nothing from this stage but the .so (and the
|
||||
# httpd version it was built against) reaches the image.
|
||||
FROM ${BASE_IMAGE} AS modbuild
|
||||
ARG PKG_CACHE=
|
||||
COPY ./scripts/pkg-cache-repos.sh /usr/local/sbin/pkg-cache-repos.sh
|
||||
COPY ./keys/pkg-cache/ /usr/local/share/pkg-cache/
|
||||
COPY ./src/mod_whp_symlink/mod_whp_symlink.c /src/mod_whp_symlink.c
|
||||
RUN /usr/local/sbin/pkg-cache-repos.sh rpm && \
|
||||
dnf update -y && \
|
||||
dnf install -y httpd-devel gcc redhat-rpm-config && \
|
||||
/usr/local/sbin/pkg-cache-repos.sh restore && \
|
||||
cd /src && apxs -Wc,-Wall -Wc,-Werror -c mod_whp_symlink.c && \
|
||||
rpm -q --qf '%{VERSION}-%{RELEASE}' httpd-devel > /src/built-against
|
||||
|
||||
FROM ${BASE_IMAGE}
|
||||
|
||||
# OPTIONAL internal package cache, e.g. --build-arg PKG_CACHE=https://192.168.1.40
|
||||
@@ -44,6 +61,16 @@ RUN openssl req -newkey rsa:2048 -nodes \
|
||||
COPY ./configs/remote_ip.conf /etc/httpd/conf.d/
|
||||
COPY ./configs/default-index.conf /etc/httpd/conf.d/
|
||||
|
||||
# mod_whp_symlink: tenant .htaccess Options remap + served-file owner guard
|
||||
# (configs/whp-symlink.conf). The build fails if the runtime httpd differs from
|
||||
# the httpd-devel it was compiled against, or if the module does not load.
|
||||
COPY --from=modbuild /src/.libs/mod_whp_symlink.so /usr/lib64/httpd/modules/mod_whp_symlink.so
|
||||
COPY --from=modbuild /src/built-against /usr/lib64/httpd/modules/mod_whp_symlink.built-against
|
||||
COPY ./configs/whp-symlink.conf /etc/httpd/conf.d/whp-symlink.conf
|
||||
RUN echo 'LoadModule whp_symlink_module modules/mod_whp_symlink.so' > /etc/httpd/conf.modules.d/99-whp-symlink.conf && \
|
||||
test "$(rpm -q --qf '%{VERSION}-%{RELEASE}' httpd)" = "$(cat /usr/lib64/httpd/modules/mod_whp_symlink.built-against)" && \
|
||||
httpd -t && httpd -M 2>/dev/null | grep -q ' whp_symlink_module '
|
||||
|
||||
# Create vhosts directory (will be volume-mounted from host)
|
||||
RUN mkdir -p /etc/httpd/conf.d/vhosts
|
||||
|
||||
|
||||
Reference in new issue
Block a user