2026-11-19 06:55:56 -08:00
|
|
|
#!/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.
|
2026-11-19 12:01:11 -08:00
|
|
|
## Plain loop, not a grep|grep|head pipeline: an early-exit reader under pipefail
|
|
|
|
|
## can SIGPIPE its writer (see lsphp-info-probe.test.sh structural scan).
|
|
|
|
|
SEDLINE=""
|
|
|
|
|
while IFS= read -r line; do
|
|
|
|
|
case "$line" in *'session\.upload_progress\.enabled'*) ;; *) continue ;; esac
|
|
|
|
|
case "$line" in ' '*'sed -i'*|'sed -i'*) SEDLINE="$line"; break ;; esac
|
|
|
|
|
done <"$S"
|
2026-11-19 06:55:56 -08:00
|
|
|
[ -n "$SEDLINE" ] || { echo "FAIL: sed line not found in script"; exit 1; }
|
2026-11-19 12:01:11 -08:00
|
|
|
export SRC="$T" # referenced by the eval'd sed line
|
|
|
|
|
sed() { command sed "$@"; }
|
2026-11-19 06:55:56 -08:00
|
|
|
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
|