From: Wietse Z Venema Date: Fri, 3 Apr 2026 05:00:00 +0000 (-0500) Subject: postfix-3.12-20260403 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=763fa7f1eeeb0808cecca4a8cb11cf99f8bab53d;p=thirdparty%2Fpostfix.git postfix-3.12-20260403 --- diff --git a/postfix/HISTORY b/postfix/HISTORY index 528b33637..7562757c6 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -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. diff --git a/postfix/Makefile.in b/postfix/Makefile.in index 9f7802019..12575a6b3 100644 --- a/postfix/Makefile.in +++ b/postfix/Makefile.in @@ -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 diff --git a/postfix/makedefs b/postfix/makedefs index 96f22ccef..79f32656a 100644 --- a/postfix/makedefs +++ b/postfix/makedefs @@ -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 diff --git a/postfix/proto/index.html b/postfix/proto/index.html index 00a7d0404..1f7507619 100644 --- a/postfix/proto/index.html +++ b/postfix/proto/index.html @@ -223,6 +223,14 @@ Recipients +

For maintainers and contributors

+ + + diff --git a/postfix/src/dns/Makefile.in b/postfix/src/dns/Makefile.in index 59b515baa..6b165d404 100644 --- a/postfix/src/dns/Makefile.in +++ b/postfix/src/dns/Makefile.in @@ -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 \ diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index 4b7939447..2603ec1eb 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -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 diff --git a/postfix/src/postalias/Makefile.in b/postfix/src/postalias/Makefile.in index c21bdeea1..c6ea1d0f8 100644 --- a/postfix/src/postalias/Makefile.in +++ b/postfix/src/postalias/Makefile.in @@ -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) diff --git a/postfix/src/postcat/Makefile.in b/postfix/src/postcat/Makefile.in index 125b73891..770b1426f 100644 --- a/postfix/src/postcat/Makefile.in +++ b/postfix/src/postcat/Makefile.in @@ -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; \ diff --git a/postfix/src/postmap/Makefile.in b/postfix/src/postmap/Makefile.in index adb33f2c2..a4f5f7e8c 100644 --- a/postfix/src/postmap/Makefile.in +++ b/postfix/src/postmap/Makefile.in @@ -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.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: diff --git a/postfix/src/smtpd/Makefile.in b/postfix/src/smtpd/Makefile.in index 7d130a822..4f5e2f988 100644 --- a/postfix/src/smtpd/Makefile.in +++ b/postfix/src/smtpd/Makefile.in @@ -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.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.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.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_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_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.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.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.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 &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.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.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.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.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_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_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; \ diff --git a/postfix/src/smtpd/smtpd_check.c b/postfix/src/smtpd/smtpd_check.c index 4525448a0..6f48e4e69 100644 --- a/postfix/src/smtpd/smtpd_check.c +++ b/postfix/src/smtpd/smtpd_check.c @@ -5651,6 +5651,7 @@ char *smtpd_check_eod(SMTPD_STATE *state) #include #include +#include #include #include @@ -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); diff --git a/postfix/src/util/Makefile.in b/postfix/src/util/Makefile.in index 0a0b023af..84ce4124e 100644 --- a/postfix/src/util/Makefile.in +++ b/postfix/src/util/Makefile.in @@ -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 - diff --git a/postfix/src/util/dict_open.c b/postfix/src/util/dict_open.c index 0790bb0f2..80b621780 100644 --- a/postfix/src/util/dict_open.c +++ b/postfix/src/util/dict_open.c @@ -674,11 +674,49 @@ void dict_type_override(DICT *dict, const char *type) #ifdef TEST +#ifdef USE_DYNAMIC_MAPS +#include + + /* + * 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); } diff --git a/postfix/src/util/dynamicmaps.c b/postfix/src/util/dynamicmaps.c index 52c17bb1a..9aa7779d6 100644 --- a/postfix/src/util/dynamicmaps.c +++ b/postfix/src/util/dynamicmaps.c @@ -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);