diff --git a/.gitea/workflows/build-push.yaml b/.gitea/workflows/build-push.yaml index 38354af..ca7295d 100644 --- a/.gitea/workflows/build-push.yaml +++ b/.gitea/workflows/build-push.yaml @@ -79,6 +79,7 @@ jobs: scripts/tests/image-label-amd64.test.sh \ scripts/tests/index-platforms.test.sh \ scripts/tests/lsphp-abi-gate.test.sh \ + scripts/tests/lsphp-src-upload-progress.test.sh \ .gitea/scripts/resolve-base-image.sh \ .gitea/scripts/plan-legs.sh @@ -95,6 +96,9 @@ jobs: - name: multi-arch workflow wiring test run: python3 -I scripts/tests/multiarch-workflow.test.py + - name: lsphp-src session defaults patch test + run: ./scripts/tests/lsphp-src-upload-progress.test.sh + - name: lsphp probe regression test run: ./scripts/tests/lsphp-info-probe.test.sh diff --git a/scripts/lsphp-src-build.sh b/scripts/lsphp-src-build.sh index e5d390e..7289714 100755 --- a/scripts/lsphp-src-build.sh +++ b/scripts/lsphp-src-build.sh @@ -173,6 +173,21 @@ if [ -n "$PKG_SAVE_PATH" ]; then log "compiled-in session.save_path default set to '$PKG_SAVE_PATH' (as the packaged lsphp${PHPVER})" fi +## Measured 2026-11-19 (emergency from-source run 5683, all 4 versions): the +## packaged lsphp82-85 report session.upload_progress.enabled='1' under `php -n`; +## php.net's source default is "0" (the value sits on the line AFTER the name in +## ext/session/session.c). That was the ONLY difference the 4b gate listed. Follow +## the packaged binary; per-site php.ini hardening can still turn it off. +PKG_UP=$("$P/bin/php" -n -r 'echo ini_get("session.upload_progress.enabled");') +if [ "$PKG_UP" = "1" ]; then + sed -i -E '/STD_PHP_INI_BOOLEAN\("session\.upload_progress\.enabled",/{n;s/"0"/"1"/}' "$SRC/ext/session/session.c" + grep -A1 -F '"session.upload_progress.enabled"' "$SRC/ext/session/session.c" | grep -F '"1"' >/dev/null \ + || die "could not apply the packaged session.upload_progress.enabled default '1' to ext/session/session.c (source layout changed?)." + log "compiled-in session.upload_progress.enabled default set to '1' (as the packaged lsphp${PHPVER})" +elif [ "$PKG_UP" != "0" ]; then + die "unexpected packaged session.upload_progress.enabled default '$PKG_UP'." +fi + ## ---- 3. replay the packaged configure line ----------------------------------- CFG_LINE=$("$P/bin/php" -i | awk -F' => ' '$1 == "Configure Command " || $1 == "Configure Command" {sub(/^[^=]*=> /, ""); print}') [ -n "$CFG_LINE" ] || die "could not read 'Configure Command' from the packaged $P/bin/php -i." diff --git a/scripts/tests/lsphp-src-upload-progress.test.sh b/scripts/tests/lsphp-src-upload-progress.test.sh new file mode 100755 index 0000000..4b8fc43 --- /dev/null +++ b/scripts/tests/lsphp-src-upload-progress.test.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +## Fixture test: the step-2c upload_progress patch in lsphp-src-build.sh flips only +## session.upload_progress.enabled (value on the line after the name), is a no-op +## when already "1", and the script keeps its 4b gate + fails closed if not found. +set -euo pipefail +HERE=$(cd "$(dirname "$0")/.." && pwd) +S="$HERE/lsphp-src-build.sh" +T=$(mktemp -d); trap 'rm -rf "$T"' EXIT +fail=0 +chk() { if [ "$2" = "$3" ]; then echo "ok $1"; else echo "FAIL $1: got '$2' want '$3'"; fail=1; fi; } +cat >"$T/session.c" <<'EOT' + STD_PHP_INI_BOOLEAN("session.upload_progress.enabled", + "0", ZEND_INI_PERDIR, OnUpdateBool, rfc1867_enabled, php_ps_globals, ps_globals) + STD_PHP_INI_BOOLEAN("session.upload_progress.cleanup", + "0", ZEND_INI_PERDIR, OnUpdateBool, rfc1867_cleanup, php_ps_globals, ps_globals) +EOT +## Run the exact sed expression from the script. +SEDLINE=$(grep -F "session\\.upload_progress\\.enabled" "$S" | grep '^ *sed -i' | head -n1) +[ -n "$SEDLINE" ] || { echo "FAIL: sed line not found in script"; exit 1; } +SRC="$T"; sed() { command sed "$@"; } +eval "${SEDLINE//\$SRC\/ext\/session\/session.c/$T/session.c}" +chk "enabled flipped to 1" "$(grep -A1 'upload_progress.enabled' "$T/session.c" | grep -c '"1"')" 1 +chk "cleanup untouched" "$(grep -A1 'upload_progress.cleanup' "$T/session.c" | grep -c '"0"')" 1 +eval "${SEDLINE//\$SRC\/ext\/session\/session.c/$T/session.c}" +chk "idempotent" "$(grep -A1 'upload_progress.enabled' "$T/session.c" | grep -c '"1"')" 1 +grep -q 'ini defaults differ from the packaged' "$S" && echo "ok 4b gate still present" || { echo "FAIL 4b gate missing"; fail=1; } +grep -q 'could not apply the packaged session.upload_progress.enabled' "$S" && echo "ok fail-closed verify present" || { echo "FAIL verify missing"; fail=1; } +exit $fail