]> git.ipfire.org Git - thirdparty/postfix.git/commitdiff
postfix-3.12-20260403
authorWietse Z Venema <wietse@porcupine.org>
Fri, 3 Apr 2026 05:00:00 +0000 (00:00 -0500)
committerViktor Dukhovni <ietf-dane@dukhovni.org>
Sun, 5 Apr 2026 14:49:24 +0000 (00:49 +1000)
14 files changed:
postfix/HISTORY
postfix/Makefile.in
postfix/makedefs
postfix/proto/index.html
postfix/src/dns/Makefile.in
postfix/src/global/mail_version.h
postfix/src/postalias/Makefile.in
postfix/src/postcat/Makefile.in
postfix/src/postmap/Makefile.in
postfix/src/smtpd/Makefile.in
postfix/src/smtpd/smtpd_check.c
postfix/src/util/Makefile.in
postfix/src/util/dict_open.c
postfix/src/util/dynamicmaps.c

index 528b3363704047bcadfd0aa05545c05598f538bf..7562757c681dceb64a3f1a29c1d6ff2a8ce01e35 100644 (file)
@@ -30795,6 +30795,15 @@ Apologies for any names omitted.
        Renamed dict_test.c to dict_cli.c, stream_test.c to
        sunos5_stream_test.c.
 
+20260403
+
+       Testing: 'make test' supports builds with "dynamicmaps=yes".
+       Some tests may still be non-hermetic. That will be addressed
+       in the course of time. Files: makedefs, Makefile.in,
+       dns/Makefile.in, postalias/Makefile.in, postmap/Makefile.in,
+       smtpd/Makefile.in, smtpd/smtpd_check.c, util/dict_open.c,
+       util/dynamicmaps.c, util/Makefile.in.
+
 TODO
 
        Reorganize PTEST_LIB, PMOCK_LIB, TESTLIB, TESTLIBS, etc.
index 9f78020190a695935f148b790660a057d21972d4..12575a6b3c7edc87a6de2b27d1ae632c323b9fac 100644 (file)
@@ -20,6 +20,7 @@ LIBEXEC       = libexec/post-install libexec/postfix-script libexec/postfix-wrapper \
 PLUGINS        = meta/dynamicmaps.cf
 META   = meta/main.cf.proto meta/master.cf.proto meta/postfix-files \
        meta/makedefs.out $(PLUGINS)
+TESTING        = testing/main.cf
 EXPAND = sed -e "s;\$${LIB_PREFIX};$(LIB_PREFIX);" \
            -e "s;\$${LIB_SUFFIX};$(LIB_SUFFIX);"
 SHLIB_DIR_OVERRIDE = \
@@ -50,7 +51,7 @@ update tests root_tests:
         (set -e; echo "[$$i]"; cd $$i; $(MAKE) $(OPTS) $@ MAKELEVEL=) || exit 1; \
        done
 
-update: $(META) $(LIBEXEC)
+update: $(META) $(TESTING) $(LIBEXEC)
 
 libexec/post-install: conf/post-install
        rm -f $@ && ln -f $? $@
@@ -99,6 +100,12 @@ libexec/postfix-wrapper: conf/postfix-wrapper
 meta/main.cf.proto: conf/main.cf
        rm -f $@ && ln -f $? $@
 
+testing/main.cf:
+       rm -f $@
+       mkdir -p testing
+       echo 'meta_directory = $(BUILD_ROOT)/meta' >> $@
+       echo 'shlib_directory = $(BUILD_ROOT)/lib' >> $@
+
 meta/master.cf.proto: conf/master.cf
        rm -f $@ && ln -f $? $@
 
@@ -243,6 +250,7 @@ tidy:       clean
            make.err */make.err */*/make.err \
            *.gmon */*.gmon */*/*.gmon \
            conf/main.cf.default conf/bounce.cf.default meta/*
+       rm -rf testing
        find . -type s -print | xargs rm -f
        find . -type d -print | xargs chmod 755
        find . -type f -print | xargs chmod a+r
index 96f22ccefc3b0a90a602187cc90db0212770c25f..79f32656a24afa9f24ecb8e4479cea4b1a66d740 100644 (file)
@@ -1439,6 +1439,7 @@ EXPORT    = CCARGS='$CCARGS' OPT='$OPT' DEBUG='$DEBUG'
 WARN   = $WARN
 DEFINED_MAP_TYPES = $DEFINED_MAP_TYPES
 MAKE_FIX = $MAKE_FIX
+BUILD_ROOT = `pwd`
 # Switch between Postfix static and dynamically-linked libraries.
 AR     = $AR
 RANLIB = $RANLIB
index 00a7d0404a586689b87aac2aa9a872ed10fcd98d..1f7507619235cb8da24ccac5c2a23f35ceb56fb4 100644 (file)
@@ -223,6 +223,14 @@ Recipients </a>
 
 </ul>
 
+<p><strong> For maintainers and contributors </strong></p>
+
+<ul>
+
+<li> <a href="PTEST_README.html"> Writing Postfix unit tests </a>
+
+</ul>
+
 </td>
 
 </table>
index 59b515baa25c94bc156dd1f823688b2355e5f3c4..6b165d404bac9c3e9f810329135a55b99cf2d050 100644 (file)
@@ -30,11 +30,13 @@ Makefile: Makefile.in
 
 test:  $(TESTPROG)
 
-tests: update test dns_rr_to_pa_test dns_rr_to_sa_test dns_sa_to_rr_test \
-       dns_rr_eq_sa_test no-a-test no-aaaa-test no-mx-test \
+tests: update test dns_rr_to_pa_test dns_rr_to_sa_test \
+       no-a-test no-aaaa-test no-mx-test \
        error-filter-test nullmx_test nxdomain_test mxonly_test \
        dnsbl_tests test_dns_rr test_dns_lookup_types
 
+broken_tests: dns_sa_to_rr_test dns_rr_eq_sa_test
+
 dnsbl_tests: \
        dnsbl_ttl_127.0.0.2_bind_plain_test \
        dnsbl_ttl_127.0.0.2_bind_ncache_test \
index 4b7939447524faff1bbc777f7bab883423f8bcda..2603ec1eb46396fac372c8542f8a823896123699 100644 (file)
@@ -20,7 +20,7 @@
   * Patches change both the patchlevel and the release date. Snapshots have no
   * patchlevel; they change the release date only.
   */
-#define MAIL_RELEASE_DATE      "20260402"
+#define MAIL_RELEASE_DATE      "20260403"
 #define MAIL_VERSION_NUMBER    "3.12"
 
 #ifdef SNAPSHOT
index c21bdeea18b1c4d69c895021c37012ff18a1a7f9..c6ea1d0f8d82fb5edf0bba5789065303ab32284b 100644 (file)
@@ -29,7 +29,9 @@ tests:        test1 test2 fail_test mode_conflict_test json_tests
 root_tests:
 
 test1: $(PROG) map.in map-abc1.ref map-ghi1.ref map-uABC1.ref
+       @echo ; echo RUN test1
        rm -f main.cf
+       cp ../../testing/main.cf .
        touch -t 197101010000 main.cf
        ${SHLIB_ENV} ${VALGRIND} ./$(PROG) -c . map.in
        for key in abc ghi; \
@@ -42,9 +44,12 @@ test1:       $(PROG) map.in map-abc1.ref map-ghi1.ref map-uABC1.ref
            ${SHLIB_ENV} ${VALGRIND} ./$(PROG) -c . -fq $${key} map.in | diff map-u$${key}1.ref -; \
        done
        rm -f map.in.db main.cf
+       @echo PASS test1
 
 test2: $(PROG) map.in map-abc2.ref map-ghi2.ref map-uABC2.ref
+       @echo ; echo RUN test2
        rm -f main.cf
+       cp ../../testing/main.cf .
        touch -t 197101010000 main.cf
        ${SHLIB_ENV} ${VALGRIND} ./$(PROG) -c . map.in
        for key in abc ghi; \
@@ -57,56 +62,69 @@ test2:      $(PROG) map.in map-abc2.ref map-ghi2.ref map-uABC2.ref
            echo $${key} | ${SHLIB_ENV} ${VALGRIND} ./$(PROG) -c . -fq - map.in | diff map-u$${key}2.ref -; \
        done
        rm -f map.in.db main.cf
+       @echo PASS test2
 
 fail_test: $(PROG) aliases fail_test.in fail_test.ref
+       @echo ; echo RUN fail_test
        rm -f main.cf
+       cp ../../testing/main.cf .
        touch -t 197101010000 main.cf
        -(${SHLIB_ENV} MAIL_CONFIG=. $(NOSLEEP) sh fail_test.in 2>&1 || exit 0) | sed \
            -e 's/No error:/Unknown error:/' \
            -e 's/Success/Unknown error: 0/' > fail_test.tmp
        diff fail_test.ref fail_test.tmp
        rm -f fail_test.tmp main.cf
+       @echo PASS fail_test
 
 mode_conflict_test: $(PROG) mode_conflict_test.in mode_conflict_test.ref
+       @echo ; echo RUN mode_conflict_test
        rm -f main.cf
+       cp ../../testing/main.cf .
        touch -t 197101010000 main.cf
        $(SHLIB_ENV) MAIL_CONFIG=. $(NOSLEEP) sh -x mode_conflict_test.in >mode_conflict_test.tmp 2>&1
        diff mode_conflict_test.ref mode_conflict_test.tmp
        rm -f mode_conflict_test.tmp main.cf
+       @echo PASS mode_conflict_test
 
 json_tests: json_query_test json_queries_test json_sequence_test
 
 json_query_test: $(PROG)
        # Exercise code in postalias_query().
        @echo ; echo RUN json_query_test
+       rm -f main.cf
+       cp ../../testing/main.cf .
        echo '{"postmaster": "root"}' >json_query.tmp
        $(SHLIB_ENV) ${VALGRIND} ./$(PROG)  -jq postmaster \
                'inline:{{postmaster = root}}' | diff json_query.tmp -
        ($(SHLIB_ENV) ${VALGRIND} ./$(PROG)  -jq other \
                'inline:{{postmaster = root}}' || exit 0) | diff /dev/null -
-       rm -f json_query.tmp
+       rm -f json_query.tmp main.cf
        @echo PASS json_query_test
 
 json_queries_test: $(PROG)
        # Exercise json formatting in postalias_queries().
        @echo ; echo RUN json_queries_test
+       rm -f main.cf
+       cp ../../testing/main.cf .
        echo '{"postmaster": "root"}' >json_queries.tmp
        (echo postmaster; echo other) | $(SHLIB_ENV) ${VALGRIND} \
                ./$(PROG) -jq - 'inline:{{postmaster = root}}' | \
                diff json_queries.tmp -
-       rm -f json_queries.tmp 
+       rm -f json_queries.tmp main.cf
        @echo PASS json_queries_test
 
 json_sequence_test: $(PROG)
        # Exercise json formatting in postalias_seq().
        @echo ; echo RUN json_sequence_test
+       rm -f main.cf
+       cp ../../testing/main.cf .
        rm -f json_sequence.tmp
        (echo '{"postmaster": "root"}'; echo '{"root": "real-user"}') |\
                sort >json_sequence.tmp
        $(SHLIB_ENV) ${VALGRIND} ./$(PROG) -js \
                'inline:{{postmaster = root} {root=real-user}}' | sort | \
                diff json_sequence.tmp -
-       rm -f json_sequence.tmp
+       rm -f json_sequence.tmp main.cf
        @echo PASS json_sequence_test
 
 ../../bin/$(PROG): $(PROG)
index 125b738915196f074e57d413478b1336e102fe54..770b1426f202a1688398df3ce8662dc485c474c0 100644 (file)
@@ -38,44 +38,58 @@ clean:
 tidy:  clean
 
 default_test: test-queue-file default_test.ref
-       ./postcat test-queue-file >postcat.tmp 2>&1
+       $(VALGRIND) $(SHLIB_ENV) ./postcat test-queue-file >postcat.tmp 2>&1
        diff default_test.ref postcat.tmp
        rm -f postcat.tmp
 
 ebh_test: test-queue-file default_test.ref
-       ./postcat -ebh test-queue-file >postcat.tmp 2>&1
+       rm -f main.cf
+       touch -t 197101010000 main.cf
+       $(VALGRIND) $(SHLIB_ENV) ./postcat -ebhc. test-queue-file >postcat.tmp 2>&1
        diff default_test.ref postcat.tmp
-       rm -f postcat.tmp
+       rm -f postcat.tmp main.cf
 
 e_test: test-queue-file e_test.ref
-       ./postcat -e test-queue-file >postcat.tmp 2>&1
+       rm -f main.cf
+       touch -t 197101010000 main.cf
+       $(VALGRIND) $(SHLIB_ENV) ./postcat -ec. test-queue-file >postcat.tmp 2>&1
        diff e_test.ref postcat.tmp
-       rm -f postcat.tmp
+       rm -f postcat.tmp main.cf
 
 b_test: test-queue-file b_test.ref
-       ./postcat -b test-queue-file >postcat.tmp 2>&1
+       rm -f main.cf
+       touch -t 197101010000 main.cf
+       $(VALGRIND) $(SHLIB_ENV) ./postcat -bc. test-queue-file >postcat.tmp 2>&1
        diff b_test.ref postcat.tmp
-       rm -f postcat.tmp
+       rm -f postcat.tmp main.cf
 
 h_test: test-queue-file h_test.ref
-       ./postcat -h test-queue-file >postcat.tmp 2>&1
+       rm -f main.cf
+       touch -t 197101010000 main.cf
+       $(VALGRIND) $(SHLIB_ENV) ./postcat -hc. test-queue-file >postcat.tmp 2>&1
        diff h_test.ref postcat.tmp
-       rm -f postcat.tmp
+       rm -f postcat.tmp main.cf
 
 eb_test: test-queue-file eb_test.ref
-       ./postcat -eb test-queue-file >postcat.tmp 2>&1
+       rm -f main.cf
+       touch -t 197101010000 main.cf
+       $(VALGRIND) $(SHLIB_ENV) ./postcat -ebc. test-queue-file >postcat.tmp 2>&1
        diff eb_test.ref postcat.tmp
-       rm -f postcat.tmp
+       rm -f postcat.tmp main.cf
 
 eh_test: test-queue-file eh_test.ref
-       ./postcat -eh test-queue-file >postcat.tmp 2>&1
+       rm -f main.cf
+       touch -t 197101010000 main.cf
+       $(VALGRIND) $(SHLIB_ENV) ./postcat -ehc. test-queue-file >postcat.tmp 2>&1
        diff eh_test.ref postcat.tmp
-       rm -f postcat.tmp
+       rm -f postcat.tmp main.cf
 
 bh_test: test-queue-file bh_test.ref
-       ./postcat -bh test-queue-file >postcat.tmp 2>&1
+       rm -f main.cf
+       touch -t 197101010000 main.cf
+       $(VALGRIND) $(SHLIB_ENV) ./postcat -bhc. test-queue-file >postcat.tmp 2>&1
        diff bh_test.ref postcat.tmp
-       rm -f postcat.tmp
+       rm -f postcat.tmp main.cf
 
 depend: $(MAKES)
        (sed '1,/^# do not edit/!d' Makefile.in; \
index adb33f2c2ac4d40907ec69f4208462d924509fb9..a4f5f7e8c2bfa53e7334a7f2f0d78abd54c31ebe 100644 (file)
@@ -34,7 +34,9 @@ tests:        test1 test2 fail_test quote_test file_test lmdb_abb_test \
 root_tests:
 
 test1: $(PROG) map.in map-abc1.ref map-ghi1.ref map-uABC1.ref
+       @echo ; echo RUN test1
        rm -f main.cf
+       cp ../../testing/main.cf .
        touch -t 197101010000 main.cf
        $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -c . map.in
        for key in abc ghi; \
@@ -47,9 +49,12 @@ test1:       $(PROG) map.in map-abc1.ref map-ghi1.ref map-uABC1.ref
            $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -c . -fq $${key} map.in | diff map-u$${key}1.ref -; \
        done
        rm -f map.in.db main.cf
+       @echo PASS test1
 
 test2: $(PROG) map.in map-abc2.ref map-ghi2.ref map-uABC2.ref
+       @echo ; echo RUN test2
        rm -f main.cf
+       cp ../../testing/main.cf .
        touch -t 197101010000 main.cf
        $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -c . map.in
        for key in abc ghi; \
@@ -62,40 +67,55 @@ test2:      $(PROG) map.in map-abc2.ref map-ghi2.ref map-uABC2.ref
            echo $${key} | $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -c . -fq - map.in | diff map-u$${key}2.ref -; \
        done
        rm -f map.in.db main.cf
+       @echo PASS test2
 
 fail_test: $(PROG) aliases fail_test.in fail_test.ref
+       @echo ; echo RUN fail_test
        rm -f main.cf
+       cp ../../testing/main.cf .
        touch -t 197101010000 main.cf
        -($(SHLIB_ENV) MAIL_CONFIG=. $(NOSLEEP) sh fail_test.in || exit 0) >fail_test.tmp 2>&1
        diff fail_test.ref fail_test.tmp
        rm -f fail_test.tmp main.cf
+       @echo PASS fail_test
 
 quote_test: $(PROG) aliases quote_test.in quote_test.ref
+       @echo ; echo RUN quote_test
        rm -f main.cf
+       cp ../../testing/main.cf .
        touch -t 197101010000 main.cf
        rm -f quote_test_map.*
        $(SHLIB_ENV) MAIL_CONFIG=. sh quote_test.in >quote_test.tmp 2>&1
        diff quote_test.ref quote_test.tmp
        rm -f quote_test.tmp quote_test_map.* main.cf
+       @echo PASS quote_test
 
 file_test: $(PROG) file_test.in file_test.ref
+       @echo ; echo RUN file_test
        rm -f main.cf
+       cp ../../testing/main.cf .
        touch -t 197101010000 main.cf
        rm -f file_test_map.* postmap-file-1 postmap-file-2
        $(SHLIB_ENV) MAIL_CONFIG=. $(NOSLEEP) sh file_test.in >file_test.tmp 2>&1
        diff file_test.ref file_test.tmp
        rm -f file_test.tmp file_test_map.* postmap-file-1 postmap-file-2 \
            main.cf
+       @echo PASS file_test
 
 mode_conflict_test: $(PROG) mode_conflict_test.in mode_conflict_test.ref
+       @echo ; echo RUN mode_conflict_test
        rm -f main.cf
+       cp ../../testing/main.cf .
        touch -t 197101010000 main.cf
        $(SHLIB_ENV) MAIL_CONFIG=. $(NOSLEEP) sh -x mode_conflict_test.in >mode_conflict_test.tmp 2>&1
        diff mode_conflict_test.ref mode_conflict_test.tmp
        rm -f mode_conflict_test.tmp main.cf
+       @echo PASS mode_conflict_test
 
 cdb_bulk_test: $(PROG)
+       @echo ; echo RUN cdb_bulk_test
        rm -f cdb_bulk.cdb main.cf
+       cp ../../testing/main.cf .
        tr A-Z a-z < /usr/share/dict/words| \
            sed -e 's/.*/&      &/' -e 10000q| LANG=C sort -u >cdb_bulk
        touch -t 197101010000 main.cf
@@ -104,94 +124,119 @@ cdb_bulk_test: $(PROG)
            LANG=C sort > cdb_bulk.tmp)
        cmp cdb_bulk cdb_bulk.tmp
        rm -f cdb_bulk cdb_bulk.tmp cdb_bulk.cdb main.cf
+       @echo PASS cdb_bulk_test
 
 lmdb_abb_test: $(PROG) lmdb_abb lmdb_abb.ref
+       @echo ; echo RUN lmdb_abb_test
        rm -f main.cf
+       cp ../../testing/main.cf .
        touch -t 197101010000 main.cf
        rm -f lmdb_abb.lmdb
        ($(SHLIB_ENV) $(VALGRIND) ./postmap -c . lmdb:lmdb_abb; \
        $(SHLIB_ENV) $(VALGRIND) ./postmap -c . -s lmdb:lmdb_abb | sort) >lmdb_abb.tmp 2>&1
        diff lmdb_abb.ref lmdb_abb.tmp
        rm -f lmdb_abb.tmp lmdb_abb.lmdb
+       @echo PASS lmdb_abb_test
 
 lmdb_bulk_test: $(PROG)
+       @echo ; echo RUN lmdb_bulk_test
        rm -f lmdb_retry.lmdb main.cf
+       cp ../../testing/main.cf .
        tr A-Z a-z < /usr/share/dict/words| \
            sed -e 's/.*/&      &/' -e 10000q| LANG=C sort -u >lmdb_retry
-       echo lmdb_map_size=10240 >main.cf
+       echo lmdb_map_size=10240 >>main.cf
        touch -t 197101010000 main.cf
        ($(SHLIB_ENV) $(VALGRIND) ./postmap -c . lmdb:lmdb_retry; \
        $(SHLIB_ENV) $(VALGRIND) ./postmap -c . -s lmdb:lmdb_retry | \
            LANG=C sort > lmdb_retry.tmp)
        cmp lmdb_retry lmdb_retry.tmp
        rm -f lmdb_retry lmdb_retry.tmp lmdb_retry.lmdb main.cf
+       @echo PASS lmdb_bulk_test
 
 lmdb_incr_test: $(PROG)
+       @echo ; echo RUN lmdb_incr_test
        rm -f lmdb_retry.lmdb main.cf
+       cp ../../testing/main.cf .
        tr A-Z a-z < /usr/share/dict/words| \
            sed -e 's/.*/&      &/' -e 1000q| LANG=C sort -u >lmdb_retry
-       echo lmdb_map_size=10240 >main.cf
+       echo lmdb_map_size=10240 >>main.cf
        touch -t 197101010000 main.cf
        ($(SHLIB_ENV) $(VALGRIND) ./postmap -ic . lmdb:lmdb_retry <lmdb_retry; \
        $(SHLIB_ENV) $(VALGRIND) ./postmap -c . -s lmdb:lmdb_retry | \
            LANG=C sort > lmdb_retry.tmp)
        cmp lmdb_retry lmdb_retry.tmp
        rm -f lmdb_retry lmdb_retry.tmp lmdb_retry.lmdb main.cf
+       @echo PASS lmdb_incr_test
 
 json_tests: json_query_test json_queries_test json_sequence_test \
        json_header_test json_body_test
 
 json_query_test: $(PROG)
-       # Exercise code in postmap_query().
        @echo ; echo RUN json_query_test
+       rm -f main.cf
+       cp ../../testing/main.cf .
+       touch -t 197101010000 main.cf
+       # Exercise code in postmap_query().
        echo '{"foo": "fooval"}' >json_query.tmp
        $(SHLIB_ENV) ${VALGRIND} ./$(PROG)  -jq foo \
                'inline:{{foo = fooval}}' | diff json_query.tmp -
        ($(SHLIB_ENV) ${VALGRIND} ./$(PROG)  -jq bar \
                'inline:{{foo = fooval}}' || exit 0) | diff /dev/null -
-       rm -f json_query.tmp
+       rm -f json_query.tmp main.cf
        @echo PASS json_query_test
 
 json_queries_test: $(PROG)
-       # Exercise json formatting in postmap_queries() with non-message input.
        @echo ; echo RUN json_queries_test
+       # Exercise json formatting in postmap_queries() with non-message input.
+       rm -f main.cf
+       cp ../../testing/main.cf .
+       touch -t 197101010000 main.cf
        echo '{"foo": "fooval"}' >json_queries.tmp
        (echo foo; echo bar) | $(SHLIB_ENV) ${VALGRIND} \
                ./$(PROG) -jq - 'inline:{{foo = fooval}}' | \
                diff json_queries.tmp -
-       rm -f json_queries.tmp 
+       rm -f json_queries.tmp main.cf
        @echo PASS json_queries_test
 
 json_sequence_test: $(PROG)
        # Exercise json formatting in postmap_seq().
        @echo ; echo RUN json_sequence_test
+       rm -f main.cf
+       cp ../../testing/main.cf .
+       touch -t 197101010000 main.cf
        rm -f json_sequence.tmp
        (echo '{"bar": "barval"}'; echo '{"foo": "fooval"}') |\
                sort >json_sequence.tmp
        $(SHLIB_ENV) ${VALGRIND} ./$(PROG) -js \
                'inline:{{foo = fooval} {bar = barval}}' | sort | \
                diff json_sequence.tmp -
-       rm -f json_sequence.tmp
+       rm -f json_sequence.tmp main.cf
        @echo PASS json_sequence_test
 
 json_header_test: $(PROG)
        # Exercise json formatting in postmap_queries() in 'header' mode.
        @echo ; echo RUN json_header_test
+       rm -f main.cf
+       cp ../../testing/main.cf .
+       touch -t 197101010000 main.cf
        echo '{"Subject: test": "got subject"}' > json_header.tmp
        (echo Subject: test; echo body) | $(SHLIB_ENV) ${VALGRIND} ./$(PROG) \
                -hjq - 'regexp:{{ /Subject/ got subject} { /./ got other }}' | \
                diff json_header.tmp -
-       rm -f json_header.tmp
+       rm -f json_header.tmp main.cf
        @echo PASS json_header_test
 
 json_body_test: $(PROG)
        # Exercise json formatting in postmap_queries() in 'body' mode.
        @echo ; echo RUN json_body_test
+       rm -f main.cf
+       cp ../../testing/main.cf .
+       touch -t 197101010000 main.cf
        echo '{"body": "got other"}' > json_body.tmp
        (echo Subject: test; echo body) | $(SHLIB_ENV) ${VALGRIND} ./$(PROG) \
                -bjq - 'regexp:{{ /Subject/ got subject} { /./ got other }}' | \
                diff json_body.tmp -
-       rm -f json_body.tmp
+       rm -f json_body.tmp main.cf
        @echo PASS json_body_test
 
 clean:
index 7d130a822ff74389aa2a0103b31133baec4dd4b1..4f5e2f988223578ad789ccdcb4d9017de88942ab 100644 (file)
@@ -77,30 +77,50 @@ root_tests:
 # This requires that the DNS server can query porcupine.org.
 
 smtpd_check_test: smtpd_check smtpd_check.in smtpd_check.ref smtpd_check_access
-       $(SHLIB_ENV) $(VALGRIND) ../postmap/postmap hash:smtpd_check_access
+       @echo ; echo RUN smtpd_check_test
+       rm -f main.cf
+       cp ../../testing/main.cf .
+       touch -t 197101010000 main.cf
+       $(SHLIB_ENV) $(VALGRIND) ../postmap/postmap -c. hash:smtpd_check_access
        $(SHLIB_ENV) $(VALGRIND) ./smtpd_check <smtpd_check.in >smtpd_check.tmp 2>&1
        diff smtpd_check.ref smtpd_check.tmp
-       rm -f smtpd_check.tmp smtpd_check_access.*
+       rm -f smtpd_check.tmp smtpd_check_access.* main.cf
+       @echo PASS smtpd_check_test
 
 # This requires that the DNS server can query porcupine.org.
 
 smtpd_check_test2: smtpd_check smtpd_check.in2 smtpd_check.ref2 smtpd_check_access
-       $(SHLIB_ENV) $(VALGRIND) ../postmap/postmap hash:smtpd_check_access
+       @echo ; echo RUN smtpd_check_test2
+       rm -f main.cf
+       cp ../../testing/main.cf .
+       touch -t 197101010000 main.cf
+       $(SHLIB_ENV) $(VALGRIND) ../postmap/postmap -c. hash:smtpd_check_access
        $(SHLIB_ENV) $(VALGRIND) ./smtpd_check <smtpd_check.in2 >smtpd_check.tmp 2>&1
        diff smtpd_check.ref2 smtpd_check.tmp
-       rm -f smtpd_check.tmp smtpd_check_access.*
+       rm -f smtpd_check.tmp smtpd_check_access.* main.cf
+       @echo PASS smtpd_check_test2
 
 smtpd_check_test4: smtpd_check smtpd_check.in4 smtpd_check.ref4 smtpd_check_access
-       $(SHLIB_ENV) $(VALGRIND) ../postmap/postmap hash:smtpd_check_access
+       @echo ; echo RUN smtpd_check_test4
+       rm -f main.cf
+       cp ../../testing/main.cf .
+       touch -t 197101010000 main.cf
+       $(SHLIB_ENV) $(VALGRIND) ../postmap/postmap -c. hash:smtpd_check_access
        $(SHLIB_ENV) $(VALGRIND) ./smtpd_check <smtpd_check.in4 >smtpd_check.tmp 2>&1
        diff smtpd_check.ref4 smtpd_check.tmp
-       rm -f smtpd_check.tmp smtpd_check_access.*
+       rm -f smtpd_check.tmp smtpd_check_access.* main.cf
+       @echo PASS smtpd_check_test4
 
 smtpd_acl_test: smtpd_check smtpd_acl.in smtpd_acl.ref smtpd_check_access
-       $(SHLIB_ENV) $(VALGRIND) ../postmap/postmap hash:smtpd_check_access
+       @echo ; echo RUN smtpd_acl_test
+       rm -f main.cf
+       cp ../../testing/main.cf .
+       touch -t 197101010000 main.cf
+       $(SHLIB_ENV) $(VALGRIND) ../postmap/postmap -c. hash:smtpd_check_access
        $(SHLIB_ENV) $(VALGRIND) ./smtpd_check <smtpd_acl.in >smtpd_check.tmp 2>&1
        diff smtpd_acl.ref smtpd_check.tmp
-       rm -f smtpd_check.tmp smtpd_check_access.*
+       rm -f smtpd_check.tmp smtpd_check_access.* main.cf
+       @echo PASS smtpd_acl_test
 
 smtpd_addr_valid_test: smtpd_check smtpd_addr_valid.in smtpd_addr_valid.ref
        $(SHLIB_ENV) $(VALGRIND) ./smtpd_check <smtpd_addr_valid.in >smtpd_check.tmp 2>&1
@@ -113,66 +133,97 @@ ADDRINFO_FIX = sed -e 's/No address associated with hostname/hostname nor servna
                -e 's/Name or service not known/hostname nor servname provided, or not known/'
 
 smtpd_exp_test: smtpd_check smtpd_exp.in smtpd_exp.ref
-       $(SHLIB_ENV) $(VALGRIND) ../postmap/postmap hash:smtpd_check_access
+       @echo ; echo RUN smtpd_acl_test
+       rm -f main.cf
+       cp ../../testing/main.cf .
+       touch -t 197101010000 main.cf
+       $(SHLIB_ENV) $(VALGRIND) ../postmap/postmap -c. hash:smtpd_check_access
        $(SHLIB_ENV) $(VALGRIND) ./smtpd_check <smtpd_exp.in >smtpd_exp.tmp 2>&1
        diff smtpd_exp.ref smtpd_exp.tmp
-       rm -f smtpd_exp.tmp smtpd_check_access.*
+       rm -f smtpd_exp.tmp smtpd_check_access.* main.cf
+       @echo PASS smtpd_exp_test
 
 smtpd_server_test: smtpd_check smtpd_server.in smtpd_server.ref
+       @echo ; echo RUN smtpd_server_test
        $(SHLIB_ENV) $(VALGRIND) ./smtpd_check <smtpd_server.in >smtpd_server.tmp 2>&1
        $(ADDRINFO_FIX) smtpd_server.tmp | diff smtpd_server.ref -
        rm -f smtpd_server.tmp smtpd_check_access.*
+       @echo PASS smtpd_server_test
 
 smtpd_nullmx_test: smtpd_check smtpd_nullmx.in smtpd_nullmx.ref
-       $(SHLIB_ENV) $(VALGRIND) ../postmap/postmap hash:smtpd_check_access
+       @echo ; echo RUN smtpd_nullmx_test
+       rm -f main.cf
+       cp ../../testing/main.cf .
+       touch -t 197101010000 main.cf
+       $(SHLIB_ENV) $(VALGRIND) ../postmap/postmap -c. hash:smtpd_check_access
        $(SHLIB_ENV) $(VALGRIND) ./smtpd_check <smtpd_nullmx.in >smtpd_nullmx.tmp 2>&1
        $(ADDRINFO_FIX) smtpd_nullmx.tmp | diff smtpd_nullmx.ref -
-       rm -f smtpd_nullmx.tmp smtpd_check_access.*
+       rm -f smtpd_nullmx.tmp smtpd_check_access.* main.cf
+       @echo PASS smtpd_nullmx_test
 
 smtpd_dns_filter_test: smtpd_check smtpd_dns_filter.in smtpd_dns_filter.ref \
        ../dns/no-mx.reg ../dns/no-a.reg ../dns/error.reg
+       @echo ; echo smtpd_dns_filter_test
        $(SHLIB_ENV) $(VALGRIND) ./smtpd_check <smtpd_dns_filter.in 2>&1 | \
            sed 's/\. [0-9]* IN/. TTL IN/' >smtpd_dns_filter.tmp
        diff smtpd_dns_filter.ref smtpd_dns_filter.tmp
        rm -f smtpd_dns_filter.tmp
+       @echo PASS smtpd_dns_filter_test
 
 smtpd_check_dsn_test: smtpd_check smtpd_check_dsn.in smtpd_check_dsn.ref smtpd_check_access
-       $(SHLIB_ENV) $(VALGRIND) ../postmap/postmap hash:smtpd_check_access
+       @echo ; echo RUN smtpd_check_dsn_test
+       rm -f main.cf
+       cp ../../testing/main.cf .
+       touch -t 197101010000 main.cf
+       $(SHLIB_ENV) $(VALGRIND) ../postmap/postmap -c. hash:smtpd_check_access
        $(SHLIB_ENV) $(VALGRIND) ./smtpd_check <smtpd_check_dsn.in >smtpd_check.tmp 2>&1
        diff smtpd_check_dsn.ref smtpd_check.tmp
-       rm -f smtpd_check.tmp smtpd_check_access.*
+       rm -f smtpd_check.tmp smtpd_check_access.* main.cf
+       @echo PASS smtpd_check_dsn_test
 
 # This requires that 168.100.3.7 is a local or virtual interface.
 
 smtpd_check_backup_test: smtpd_check smtpd_check_backup.in smtpd_check_backup.ref
+       @echo ; echo RUN smtpd_check_backup_test
        $(SHLIB_ENV) $(VALGRIND) ./smtpd_check <smtpd_check_backup.in >smtpd_check.tmp 2>&1
        diff smtpd_check_backup.ref smtpd_check.tmp
        rm -f smtpd_check.tmp
+       @echo PASS smtpd_check_backup_test
 
 smtpd_token_test: smtpd_token smtpd_token.in smtpd_token.ref
+       @echo ; echo RUN smtpd_token_test
        $(SHLIB_ENV) $(VALGRIND) ./smtpd_token <smtpd_token.in >smtpd_token.tmp 2>&1
        diff smtpd_token.ref smtpd_token.tmp
        rm -f smtpd_token.tmp
+       @echo PASS smtpd_token_test
 
 # This requires that the DNS server can query porcupine.org and rfc-ignorant.org
 
 smtpd_dnswl_test: smtpd_check smtpd_dnswl.in smtpd_dnswl.ref
+       @echo ; echo RUN smtpd_dnswl_test
        $(SHLIB_ENV) $(VALGRIND) ./smtpd_check <smtpd_dnswl.in >smtpd_dnswl.tmp 2>&1
        diff smtpd_dnswl.ref smtpd_dnswl.tmp
        rm -f smtpd_dnswl.tmp
+       @echo PASS smtpd_dnswl_test
 
 smtpd_error_test: smtpd_check smtpd_error.in smtpd_error.ref
+       @echo ; echo RUN smtpd_error_test
        $(SHLIB_ENV) $(VALGRIND) ./smtpd_check <smtpd_error.in >smtpd_check.tmp 2>&1
        diff smtpd_error.ref smtpd_check.tmp
        rm -f smtpd_check.tmp
+       @echo PASS smtpd_error_test
 
 smtpd_deprecated_test: smtpd_check smtpd_deprecated.in smtpd_deprecated.ref
+       @echo ; echo RUN smtpd_deprecated_test
        $(SHLIB_ENV) $(VALGRIND) ./smtpd_check <smtpd_deprecated.in >smtpd_check.tmp 2>&1
        diff smtpd_deprecated.ref smtpd_check.tmp
        rm -f smtpd_check.tmp
+       @echo PASS smtpd_deprecated_test
 
 test_smtpd_peer: smtpd_peer_test
+       @echo ; echo RUN test_smtpd_peer
        $(SHLIB_ENV) $(VALGRIND) ./smtpd_peer_test
+       @echo PASS test_smtpd_peer
 
 depend: $(MAKES)
        (sed '1,/^# do not edit/!d' Makefile.in; \
index 4525448a0a0b1c42ad879829352c05bf6b4ec38e..6f48e4e69098aea9d190d84cb1c50d64711dd119 100644 (file)
@@ -5651,6 +5651,7 @@ char   *smtpd_check_eod(SMTPD_STATE *state)
 
 #include <mail_conf.h>
 #include <rewrite_clnt.h>
+#include <mail_dict.h>
 #include <dns.h>
 
 #include <smtpd_chat.h>
@@ -5712,6 +5713,8 @@ char   *var_unk_addr_tf_act;
 char   *var_unv_rcpt_tf_act;
 char   *var_unv_from_tf_act;
 char   *var_smtpd_acl_perm_log;
+char   *var_meta_dir;
+char   *shlib_dir;
 
 typedef struct {
     char   *name;
@@ -5771,6 +5774,8 @@ static const STRING_TABLE string_table[] = {
     /* XXX No static initialization with "", because owned by a library. */
     VAR_MYNETWORKS, "", &var_mynetworks,
     VAR_RELAY_DOMAINS, "", &var_relay_domains,
+    VAR_META_DIR, "../../meta", &var_meta_dir,
+    VAR_SHLIB_DIR, "../../lib", &var_shlib_dir,
     0,
 };
 
@@ -6170,6 +6175,7 @@ int     main(int argc, char **argv)
     string_init();
     int_init();
     bool_init();
+    mail_dict_init();
     smtpd_check_init();
     smtpd_expand_init();
     (void) inet_proto_init(argv[0], INET_PROTO_NAME_IPV4);
index 0a0b023af9eb485ef52ac73f4be39f3522bceb18..84ce4124ec9ce0683c718e9f8b4d305d874977d4 100644 (file)
@@ -740,6 +740,7 @@ attr_scan0_test: attr_print0 attr_scan0 attr_scan0.ref
 
 dict_test: dict_open testdb dict_test.in dict_test.ref
        rm -f testdb.db testdb.dir testdb.pag main.cf
+       cp ../../testing/main.cf .
        touch -t 197601010000 main.cf
        $(SHLIB_ENV) ../postmap/postmap -Nc. hash:testdb
        $(SHLIB_ENV) ${VALGRIND} ./dict_open hash:testdb write < dict_test.in 2>&1 | sed 's/uid=[0-9][0-9][0-9]*/uid=USER/' >dict_test.tmp
@@ -942,6 +943,7 @@ base32_code_test: base32_code
 
 dict_thash_test: ../postmap/postmap dict_thash.map dict_thash.in dict_thash.ref
        rm -f main.cf
+       cp ../../testing/main.cf .
        touch -t 197601010000 main.cf
        $(SHLIB_ENV) ${VALGRIND} ../postmap/postmap -fsc. texthash:dict_thash.map 2>&1 | \
            LANG=C sort | diff dict_thash.map -
index 0790bb0f21e5b6720d9126ed1404413d7492d19b..80b621780d614109827b5dc2770f27f7d69a7a2e 100644 (file)
@@ -674,11 +674,49 @@ void    dict_type_override(DICT *dict, const char *type)
 
 #ifdef TEST
 
+#ifdef USE_DYNAMIC_MAPS
+#include <dynamicmaps.h>
+
+ /*
+  * Get the meta_directory and shlib_directory settings from a test main.cf
+  * file, without using the mail_conf(3) or mail_params(3) infrastructure.
+  */
+#define TEST_CONF_PATH "../../testing/main.cf"
+#define TEST_DICT      "test_dict"
+#define META_DIR_KEY   "meta_directory"
+#define SHLIB_DIR_KEY  "shlib_directory"
+
+static void init_dynamic_maps(void)
+{
+    const char *meta_dir;
+    const char *shlib_dir;
+    char   *path;
+
+    if (dict_load_file_xt(TEST_DICT, TEST_CONF_PATH) == 0)
+       msg_fatal("open %s: %m", TEST_CONF_PATH);
+    if ((meta_dir = dict_lookup(TEST_DICT, META_DIR_KEY)) == 0
+        || (shlib_dir = dict_lookup(TEST_DICT, SHLIB_DIR_KEY)) == 0)
+        msg_fatal("unusable file: %s", TEST_CONF_PATH);
+    path = concatenate(meta_dir, "/", "dynamicmaps.cf",
+#ifdef SHLIB_VERSION
+                      ".", SHLIB_VERSION,
+#endif
+                      (char *) 0);
+    dymap_init(path, shlib_dir);
+    myfree(path);
+    dict_unregister(TEST_DICT);
+}
+
+#endif
+
  /*
   * Proof-of-concept test program.
   */
 int     main(int argc, char **argv)
 {
+#ifdef USE_DYNAMIC_MAPS
+    init_dynamic_maps();
+#endif
     dict_cli(argc, argv);
     return (0);
 }
index 52c17bb1a0d7b24a3dfd11c9321afdcf6d081d49..9aa7779d659fbd60a313c624892d2339356d993f 100644 (file)
@@ -149,14 +149,15 @@ static const DICT_OPEN_INFO *dymap_dict_lookup(const char *dict_type)
                 dict_type, dict_type);
        return (0);
     }
-    if (stat(dp->soname, &st) < 0) {
+    if (stat (dp->soname, &st) < 0) {
        msg_warn("unsupported dictionary type: %s (%s: %m)",
                 dict_type, dp->soname);
        return (0);
     }
-    if (st.st_uid != 0 || (st.st_mode & (S_IWGRP | S_IWOTH)) != 0) {
+    if ((st.st_uid != geteuid() && st.st_uid != 0)
+       || (st.st_mode & (S_IWGRP | S_IWOTH)) != 0) {
        msg_warn("unsupported dictionary type: %s "
-                "(%s: file is owned or writable by non-root users)",
+                "(%s: file is owned or writable by other users)",
                 dict_type, dp->soname);
        return (0);
     }
@@ -235,8 +236,9 @@ static void dymap_read_conf(const char *path, const char *path_base)
     if ((fp = vstream_fopen(path, O_RDONLY, 0)) != 0) {
        if (fstat(vstream_fileno(fp), &st) < 0)
            msg_fatal("%s: fstat failed; %m", path);
-       if (st.st_uid != 0 || (st.st_mode & (S_IWGRP | S_IWOTH)) != 0) {
-           msg_warn("%s: file is owned or writable by non-root users"
+       if ((st.st_uid != geteuid() && st.st_uid != 0)
+           || (st.st_mode & (S_IWGRP | S_IWOTH)) != 0) {
+           msg_warn("%s: file is owned or writable by other users"
                     " -- skipping this file", path);
        } else {
            buf = vstring_alloc(100);