[packages/exim] Rel 3; for*_json fix from upstream (26ce72dd), smoke test of the built binary

arekm arekm at pld-linux.org
Wed Nov 25 19:50:55 CET 2026


commit c9747ca19b58b69cc36d428bd5f0da8520c15588
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Wed Nov 25 19:50:05 2026 +0100

    Rel 3; for*_json fix from upstream (26ce72dd), smoke test of the built binary

 exim-forall-json-unwrap.patch |  39 +++++++-------
 exim-smoke-test.sh            | 123 ++++++++++++++++++++++++++++++++++++++++++
 exim.spec                     |   8 ++-
 3 files changed, 151 insertions(+), 19 deletions(-)
---
diff --git a/exim.spec b/exim.spec
index 410367a..c57ffeb 100644
--- a/exim.spec
+++ b/exim.spec
@@ -12,6 +12,7 @@
 %bcond_without	dmarc	# DMARC support (Exim-native)
 %bcond_without	lmdb	# LMDB support
 %bcond_without	json	# JSON lookup support
+%bcond_without	tests	# smoke test of the built binary
 
 %if "%{pld_release}" == "ac"
 # hiredis build segfaults on ac-alpha
@@ -23,7 +24,7 @@ Summary(pl.UTF-8):	Agent Transferu Poczty Uniwersytetu w Cambridge
 Summary(pt_BR.UTF-8):	Servidor de correio eletrônico exim
 Name:		exim
 Version:	4.100.2
-Release:	2
+Release:	3
 Epoch:		2
 License:	GPL v2+
 Group:		Networking/Daemons/SMTP
@@ -47,6 +48,7 @@ Source14:	https://ftp.exim.org/pub/exim/exim4/old/config.samples.tar.bz2
 # Source14-md5:	4b93321938a800caa6127c48ad60a42b
 Source15:	%{name}4-smtp.pamd
 Source16:	%{name}on.png
+Source17:	%{name}-smoke-test.sh
 # sh branch.sh
 #Patch100:	%{name}-git.patch
 ## Patch100-md5:	fe575d6725ea2f58a423f51d20c33f71
@@ -324,6 +326,10 @@ cp -f exim_monitor/EDITME Local/eximon.conf
 %{__make} -e \
 	FULLECHO=''
 
+%if %{with tests}
+sh %{SOURCE17} build-Linux-*/exim %{version}
+%endif
+
 %install
 rm -rf $RPM_BUILD_ROOT
 install -d $RPM_BUILD_ROOT%{_sysconfdir}/{exim,mail}
diff --git a/exim-forall-json-unwrap.patch b/exim-forall-json-unwrap.patch
index baf6e04..9e5a251 100644
--- a/exim-forall-json-unwrap.patch
+++ b/exim-forall-json-unwrap.patch
@@ -1,27 +1,30 @@
-Expansions: fix crash in forall_json/forany_json on an unwrappable list
+From: Jeremy Harris <jgh146exb at wizmail.org>
+Subject: Expansions: harden forall (etc.)
 
-dewrap() returns NULL for a list without its [ ], and json_nextinlist()
-then dereferences it.  An empty list, e.g. $h_ of a missing header, or
-any skipped condition, ${if or{{true}{forany_json{[1]}{...}}}}, hit this.
-Treat an empty list as having no items, like the non-json forms, and
-fail the expansion for a malformed one.
+dewrap() returns NULL for an empty or unbracketed list, which
+forall_json/forany_json then dereferenced (segfault).
+
+Upstream: https://code.exim.org/exim/exim/commit/26ce72dd5b4b78659629abbbe6013e8b6b7bb8f6
 ---
 diff --git a/src/expand.c b/src/expand.c
-index 266b664..8b8d2e8 100644
+index 266b664..da3eed0 100644
 --- a/src/expand.c
 +++ b/src/expand.c
-@@ -3549,7 +3549,13 @@ switch(cond_type = identify_operator(&s, &opname))
- 
+@@ -3550,7 +3550,7 @@ switch(cond_type = identify_operator(&s, &opname))
      if (yield) *yield = !testfor;
      list = sub[0];
--    if (is_json) list = dewrap(string_copy(list), US"[]");
-+    /* An empty list (also what a skipped condition expands to) has no items */
-+    if (is_json && yield && *list && !(list = dewrap(string_copy(list), US"[]")))
-+      {
-+      expand_string_message = string_sprintf("%s wrapping list for %s",
-+	expand_string_message, opname);
-+      goto failout;
-+      }
-     while ((iterate_item = is_json
+     if (is_json) list = dewrap(string_copy(list), US"[]");
+-    while ((iterate_item = is_json
++    if (list) while ((iterate_item = is_json
        ? json_nextinlist(&list) : string_nextinlist(&list, &sep, NULL, 0)))
        {
+       if (is_jsons)
+@@ -3572,7 +3572,7 @@ switch(cond_type = identify_operator(&s, &opname))
+         goto failout;
+         }
+       DEBUG(expand) debug_printf_indent("%s: condition evaluated to %s\n", opname,
+-        tempcond? "true":"false");
++        tempcond ? "true":"false");
+ 
+       if (yield) *yield = (tempcond == testfor);
+       if (tempcond == is_forany) break;
diff --git a/exim-smoke-test.sh b/exim-smoke-test.sh
new file mode 100644
index 0000000..472555e
--- /dev/null
+++ b/exim-smoke-test.sh
@@ -0,0 +1,123 @@
+#!/bin/sh
+# Smoke test of a freshly built exim binary, run unprivileged from %build.
+# Usage: exim-smoke-test.sh path/to/exim version
+#
+# Exim drops privileges for a -C config, so the config names the calling user
+# as exim_user, says it is meant to run unprivileged (deliver_drop_privilege)
+# and keeps spool, log and mailboxes in a scratch directory.
+
+exim=$(cd "$(dirname "$1")" && pwd)/$(basename "$1")
+version=$2
+failed=0
+
+if [ "$(id -u)" = 0 ]; then
+	echo "exim-smoke-test: skipped, exim_user cannot be root" >&2
+	exit 0
+fi
+
+T=$(mktemp -d "${TMPDIR:-/tmp}/exim-test.XXXXXX") || exit 1
+trap 'rm -rf "$T"' EXIT
+mkdir "$T/spool" "$T/log" "$T/mail"
+
+cat > "$T/exim.conf" <<EOF
+exim_path = $exim
+primary_hostname = test.example.com
+exim_user = $(id -un)
+exim_group = $(id -gn)
+spool_directory = $T/spool
+log_file_path = $T/log/%slog
+deliver_drop_privilege = true
+keep_environment =
+
+begin routers
+
+local:
+  driver = accept
+  domains = test.example.com
+  local_parts = user
+  transport = mbox
+
+begin transports
+
+mbox:
+  driver = appendfile
+  file = $T/mail/\$local_part_data
+  user = $(id -un)
+EOF
+
+run() {
+	"$exim" -C "$T/exim.conf" "$@" 2>&1
+}
+
+# fail WHAT DETAIL...: report a failed test, detail cut to a few lines
+fail() {
+	echo "FAIL: $1"
+	shift
+	printf '%s\n' "$@" | head -n 6 | sed 's/^/  /'
+	failed=$((failed + 1))
+}
+
+# expand STRING EXPECTED: exim -be prints the result or "Failed: <reason>"
+expand() {
+	got=$(run -be "$1")
+	[ "$got" = "$2" ] || fail "$1" "expected: $2" "got:      $got"
+}
+
+# exim -bV
+got=$(run -bV)
+case "$got" in
+"Exim version $version "*) ;;
+*) fail "-bV" "$got" ;;
+esac
+
+# Expansions
+expand '${if bool{0}{yes}{no}} ${if !bool{0}{yes}{no}}' 'no yes'
+expand '${sha256:abc}' 'BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD'
+
+# ${extract} and ${listextract} field numbers (exim-extract-*.patch)
+expand '${extract{2fa}{2fa=on 3x=off}}' 'on'
+expand '${extract{99999abc}{a=1}{wups}{expected-notfound}}' 'expected-notfound'
+expand '${extract{10000}{:}{a:b:c:d:e}{yes}{no}}' 'no'
+expand '${extract{10001}{:}{a:b:c:d:e}{yes}{no}}' 'Failed: extract: field number too large'
+expand '${extract{-4294967296}{:}{a:b:c:d:e}{yes}{no}}' 'Failed: extract: field number too large'
+expand '${listextract{10000}{a:b:c:d:e}{ouch}{expected-notfound}}' 'expected-notfound'
+expand '${listextract{10001}{a:b:c:d:e}{bad1}{bad2}}' 'Failed: listextract: field number too large'
+
+# ${eval} overflow (exim-eval-overflow-check.patch)
+expand '${eval:4611686018427387904+1}' '4611686018427387905'
+expand '${eval:9223372036854775807+1}' \
+	'Failed: error in expression evaluation: overflow in sum (after processing "9223372036854775807+1")'
+expand '${eval:-9223372036854775807-2}' \
+	'Failed: error in expression evaluation: overflow in difference (after processing "-9223372036854775807-2")'
+
+# forall_json/forany_json (exim-forall-json-unwrap.patch)
+expand '${if forany_json{[1,2]}{eq{$item}{2}}{yes}{no}}' 'yes'
+expand '${if forany_json{}{eq{$item}{1}}{yes}{no}}' 'no'
+# the spec leaves an empty forall open; the json form must match the plain one
+expand '${if forall_json{}{eq{$item}{1}}{yes}{no}}' \
+	"$(run -be '${if forall{}{eq{$item}{1}}{yes}{no}}')"
+expand '${if forany_json{1}{eq{$item}{1}}{yes}{no}}' 'no'
+expand '${if or{{eq{1}{1}}{forany_json{[1]}{eq{$item}{1}}}}{yes}{no}}' 'yes'
+
+# Routing and local delivery
+got=$(run -bt user at test.example.com)
+case "$got" in
+*"router = local, transport = mbox"*) ;;
+*) fail "-bt user at test.example.com" "$got" ;;
+esac
+
+got=$(run -odf -oi -f sender at example.com user at test.example.com <<EOF
+Subject: smoke test
+
+delivered body
+EOF
+)
+[ -z "$got" ] || fail "delivery" "$got"
+grep -qx 'delivered body' "$T/mail/user" 2>/dev/null ||
+	fail "delivery: body not in mailbox" "$(cat "$T/log/mainlog" 2>/dev/null)"
+
+if [ $failed -gt 0 ]; then
+	echo "exim-smoke-test: $failed test(s) failed"
+	exit 1
+fi
+echo "exim-smoke-test: all tests passed"
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/exim.git/commitdiff/c9747ca19b58b69cc36d428bd5f0da8520c15588



More information about the pld-cvs-commit mailing list