From: Wietse Z Venema Date: Fri, 8 May 2026 05:00:00 +0000 (-0500) Subject: postfix-3.12-20260508 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b4839d9c651ee4382bcd75b54d36fb537f4b00b;p=thirdparty%2Fpostfix.git postfix-3.12-20260508 --- diff --git a/postfix/HISTORY b/postfix/HISTORY index b1a98282e..aea6e426e 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -31077,7 +31077,32 @@ Apologies for any names omitted. directory to "test-conf". On MacOS, "rm -rf testing" deleted the TESTING text file. Files: Makefile.in, postalias/Makefile.in, postmap/Makefile.in, smtpd/Makefile.in, util/Makefile.in. - + +20260507 + + Fix for 'uninitialized value' error. Viktor Dukhovni. File: + auxiliary/collate/collate.pl. + + Tech debt: restructured initialization of $service_name. + Also enforced that Postfix daemons ignore $process_name and + $service_name parameter settings in main.cf or master.cf + (parameters are read-only). Files: master/dgram_server.c, + master/event_server.c, master/multi_server.c, + master/single_server.c, master/trigger_server.c, + postconf/postconf_builtin.c. + +20260508 + + Claude AI findings, bought to our attention by Robert Sayre. + Deleted an obsolete __MAXINT__ definition (util/timecmp.c); + fixed a signed integer overshift operation (util/vstring.h). + + Testing: Ptest usability: don't require expectations for + msg_info() logging, to facilitate debugging; pass through + expected logging to make test output more informative. + Files: proto/PTEST_README.html, ptest/ptest_log.c, + ptest/ptest_log_test.c, ptest/ptest_run.c. + TODO Reorganize PTEST_LIB, PMOCK_LIB, TESTLIB, TESTLIBS, etc. diff --git a/postfix/README_FILES/PTEST_README b/postfix/README_FILES/PTEST_README index 522c5e862..580f1608a 100644 --- a/postfix/README_FILES/PTEST_README +++ b/postfix/README_FILES/PTEST_README @@ -74,9 +74,13 @@ To run the test: LD_LIBRARY_PATH=/path/to/postfix-source/lib ./mymalloc_test RUN mymalloc + myfree normal case PASS mymalloc + myfree normal case + RUN mymalloc panic for too small request + LOG (expected) panic: mymalloc: requested length 0 PASS mymalloc panic for too small request + ... results for myrealloc(), mystrdup(), mymemdup()... + mymalloc_test: PASS: 22, SKIP: 0, FAIL: 0 This simple example already shows several key features of the ptest framework. @@ -97,12 +101,14 @@ This simple example already shows several key features of the ptest framework. requested amount of memory is too small. But in this test the msg_panic () call will not terminate the process like it normally would. The Ptest framework changes the control flow of msg_panic() and msg_fatal() - such that these functions will terminate their test, instead of their - process. + such that these functions will terminate their test, instead of + terminating the entire test process. o The expect_ptest_log_event() call sets up an expectation that msg_panic () will produce a specific error message; the test would fail if the - expectation remains unsatisfied. + expectation remains unsatisfied. When an error message is logged as + expected, it shows up in output as "LOG (expected) ...content of + expected message.... o The ptest_fatal() call at the end of the second test is not needed; this call can only be reached if mymalloc() does not call msg_panic(). @@ -239,6 +245,7 @@ A test run looks like this: ... RUN propagates notfound and found PASS propagates notfound and found + RUN error propagation: static map + fail map PASS error propagation: static map + fail map ... @@ -331,11 +338,15 @@ This is what a test run looks like: LD_LIBRARY_PATH=/path/to/postfix-source/lib ./map_search_test RUN test_map_search RUN test_map_search/test 0 + LOG (expected) warning: malformed map specification: 'type' + LOG (expected) warning: expected maptype:mapname instead of 'type' PASS test_map_search/test 0 + RUN test_map_search/test 1 PASS test_map_search/test 1 .... PASS test_map_search + map_search_test: PASS: 13, SKIP: 0, FAIL: 0 This shows that the subtest name is appended to the parent test name, formatted @@ -390,12 +401,14 @@ vvooiidd pptteesstt__ffaattaall((PPTTEESSTT__CCTTXX ** Called from inside a test, to report an unexpected test result, to flag the test as failed, and to terminate the test. This call cannot be ignored with expect_ptest_error(). + For convenience, Ptest can also report non-error information. vvooiidd pptteesstt__iinnffoo((PPTTEESSTT__CCTTXX **tt,, ccoonnsstt cchhaarr **ffoorrmmaatt,, ......)) Called from inside a test, to report a non-error condition without terminating the test. This call cannot be ignored with expect_ptest_error (). + Finally, Ptest has support to test ptest_error() itself, to verify that an intentional error is reported as expected. @@ -412,20 +425,35 @@ MMaannaaggiinngg lloogg eevveennttss Ptest integrates with Postfix msg(3) logging. * Ptest changes the control flow of msg_fatal() and msg_panic(). When these - functions are called during a test, Ptest flags a test as failed and - terminates the test instead of the process. + functions are called during a test, they will terminate the test instead of + terminating the entire test process. + + * Ptest installs a log event listener to monitor Postfix logging with + msg_info() etc. Examples of what logging may look like: - * Ptest silences the output from msg_info() and other msg(3) calls, and - installs a log event listener to monitor Postfix logging. + RUN name-of-test + LOG (expected) warning: some text... + LOG (expected) panic: some text... + LOG (info) some text... + Unexpected non-info event: some text.... + FAIL name-of-test Ptest provides the following API to manage log events: vvooiidd eexxppeecctt__pptteesstt__lloogg__eevveenntt((PPTTEESSTT__CCTTXX **tt,, ccoonnsstt cchhaarr **tteexxtt)) Called from inside a test, to expect exactly one msg(3) call with the - specified text. To expect multiple events, call expect_ptest_log_event() - multiple times. A test is flagged as failed when expected text is not - logged, or when text is logged that is not expected with - expect_ptest_log_event(). + specified text including any warning, error, fatal, or panic prefix. To + expect multiple events, call expect_ptest_log_event() multiple times. A + test is flagged as failed when a warning or higher-severity message was + logged but not expected, or when such a message was expected but not + logged. + + There is no need to call expect_ptest_log_event() for msg_info() logging; + such text will be displayed whether or not it is expected. Allowing + arbitrary msg_info() calls makes bug hunting easier. + + There also is no need to match an entire logging message; a substring match + will be sufficient. It only needs to be specific enough. MMaannaaggiinngg tteesstt eexxeeccuuttiioonn diff --git a/postfix/auxiliary/collate/collate.pl b/postfix/auxiliary/collate/collate.pl index 62d08b972..e00284ec1 100755 --- a/postfix/auxiliary/collate/collate.pl +++ b/postfix/auxiliary/collate/collate.pl @@ -122,8 +122,7 @@ while (<>) { if (defined($transaction{$qid})) { $transaction{$qid} .= $_; } - $transaction{$newid} = - $_ . $transaction{$newid}; + $transaction{$newid} = $_ . ($transaction{$newid} // ""); $seqno{$newid} = ++$i if (! exists $seqno{$newid}); } next; diff --git a/postfix/html/PTEST_README.html b/postfix/html/PTEST_README.html index 165590613..5969541da 100644 --- a/postfix/html/PTEST_README.html +++ b/postfix/html/PTEST_README.html @@ -102,9 +102,13 @@ $ make test_mymalloc LD_LIBRARY_PATH=/path/to/postfix-source/lib ./mymalloc_test RUN mymalloc + myfree normal case PASS mymalloc + myfree normal case + RUN mymalloc panic for too small request +LOG (expected) panic: mymalloc: requested length 0 PASS mymalloc panic for too small request + ... results for myrealloc(), mystrdup(), mymemdup()... + mymalloc_test: PASS: 22, SKIP: 0, FAIL: 0 @@ -136,11 +140,13 @@ small. But in this test the msg_panic() call will not terminate the process like it normally would. The Ptest framework changes the control flow of msg_panic() and msg_fatal() such that these functions will terminate their test, instead of -their process.

+terminating the entire test process.

  • The expect_ptest_log_event() call sets up an expectation that msg_panic() will produce a specific error message; the test would fail if the expectation remains unsatisfied. +When an error message is logged as expected, it shows up in output +as "LOG (expected) ...content of expected message....

  • The ptest_fatal() call at the end of the second @@ -305,6 +311,7 @@ LD_LIBRARY_PATH=/path/to/postfix-source/lib ./dict_union_test ... RUN propagates notfound and found PASS propagates notfound and found + RUN error propagation: static map + fail map PASS error propagation: static map + fail map ... @@ -413,11 +420,15 @@ $ make test_map_search LD_LIBRARY_PATH=/path/to/postfix-source/lib ./map_search_test RUN test_map_search RUN test_map_search/test 0 +LOG (expected) warning: malformed map specification: 'type' +LOG (expected) warning: expected maptype:mapname instead of 'type' PASS test_map_search/test 0 + RUN test_map_search/test 1 PASS test_map_search/test 1 .... PASS test_map_search + map_search_test: PASS: 13, SKIP: 0, FAIL: 0 @@ -486,16 +497,16 @@ results as errors.

    void ptest_error(PTEST_CTX *t, const char *format, ...)
    -
    Called from inside a test, to report an unexpected test result, +

    Called from inside a test, to report an unexpected test result, and to flag the test as failed without terminating the test. This -call can be ignored with expect_ptest_error().

    +call can be ignored with expect_ptest_error().

    void ptest_fatal(PTEST_CTX *t, const char *format, ...)
    -
    Called from inside a test, to report an unexpected test result, +

    Called from inside a test, to report an unexpected test result, to flag the test as failed, and to terminate the test. This call -cannot be ignored with expect_ptest_error().

    +cannot be ignored with expect_ptest_error().

    @@ -507,9 +518,9 @@ cannot be ignored with expect
    void ptest_info(PTEST_CTX *t, const char *format, ...)
    -
    Called from inside a test, to report a non-error condition +

    Called from inside a test, to report a non-error condition without terminating the test. This call cannot be ignored with -expect_ptest_error().

    +expect_ptest_error().

    @@ -522,13 +533,13 @@ to verify that an intentional error is reported as expected.

    expect_ptest_error(PTEST_CTX *t, const char *text)
    -
    Called from inside a test, to expect exactly one ptest_error() +

    Called from inside a test, to expect exactly one ptest_error() call with the specified text, and to ignore that ptest_error() call (i.e. don't flag the test as failed). To ignore multiple calls, call expect_ptest_error() multiple times. A test is flagged as failed when an expected error is not reported (and of course when an error is reported that is not expected with -expect_ptest_error()).

    +expect_ptest_error()).

    @@ -540,12 +551,21 @@ when an error is reported that is not expected with
  • Ptest changes the control flow of msg_fatal() and msg_panic(). When these functions are called during a test, -Ptest flags a test as failed and terminates the test instead of the +they will terminate the test instead of terminating the entire test process.

    -
  • Ptest silences the output from msg_info() and -other msg(3) calls, and installs a log event listener to -monitor Postfix logging.

    +
  • Ptest installs a log event listener to monitor Postfix +logging with msg_info() etc. Examples of what logging +may look like:

    + +
    +RUN  name-of-test
    +LOG  (expected) warning: some text...
    +LOG  (expected) panic: some text...
    +LOG  (info) some text...
    +Unexpected non-info event: some text....
    +FAIL name-of-test
    +
    @@ -557,11 +577,22 @@ monitor Postfix logging.

    expect_ptest_log_event(PTEST_CTX *t, const char *text) -
    Called from inside a test, to expect exactly one msg(3) -call with the specified text. To expect multiple events, call -expect_ptest_log_event() multiple times. A test is flagged -as failed when expected text is not logged, or when text is logged -that is not expected with expect_ptest_log_event().
    +

    Called from inside a test, to expect exactly one msg(3) +call with the specified text including any warning, +error, fatal, or panic prefix. To expect +multiple events, call expect_ptest_log_event() multiple +times. A test is flagged as failed when a warning or +higher-severity message was logged but not expected, or when such +a message was expected but not logged.

    + +

    There is no need to call expect_ptest_log_event() for +msg_info() logging; such text will be displayed whether or not it +is expected. Allowing arbitrary msg_info() calls makes bug hunting +easier.

    + +

    There also is no need to match an entire logging message; a +substring match will be sufficient. It only needs to be specific +enough.

    @@ -575,51 +606,51 @@ that is not expected with void PTEST_RUN(PTEST_CTX *t, const char *test_name, { code in braces }) -
    Called from inside a test, to run the { code in braces +

    Called from inside a test, to run the { code in braces } in it own subtest environment. In the test progress report, the subtest name is appended to the parent test name, formatted as -parent-name/child-name.

    NOTE: because PTEST_RUN() +parent-name/child-name.

    NOTE: because PTEST_RUN() is a macro, the { code in braces } MUST NOT contain a return statement; use ptest_return() instead. It is OK for { code in braces } to call a function that -uses return.

    +uses return.

    void PTEST_TRY(PTEST_CTX *t, const char *test_name, { code in braces })
    -
    Called from inside a test, to run the { code in braces +

    Called from inside a test, to run the { code in braces } without entering a new subtest environment. The purpose is to continue running the current test after the { code in braces } calls msg_fatal*() or msg_panic(). The { code in braces } should set a variable to indicate that PTEST_TRY() executed -"normally".

    NOTE: because PTEST_TRY() is a macro, the +"normally".

    NOTE: because PTEST_TRY() is a macro, the { code in braces } MUST NOT contain a return statement; use ptest_return() instead. It is OK for { code in braces } to call a function that uses return. -

    +

    NORETURN ptest_skip(PTEST_CTX *t)
    -
    Called from inside a test, to flag a test as skipped, and to +

    Called from inside a test, to flag a test as skipped, and to terminate the test without terminating the process. Use this to disable tests that are not applicable for a specific system type -or build configuration.

    +or build configuration.

    NORETURN ptest_return(PTEST_CTX *t)
    -
    Used inside a { code in braces } block to terminate -a PTEST_RUN subtest.

    +

    Used inside a { code in braces } block to terminate +a PTEST_RUN subtest.

    void ptest_defer(PTEST_CTX *t, void (*defer_fn)(void *), void *defer_ctx)
    -
    Called once from inside a test, to call defer_fn(defer_ctx) +

    Called once from inside a test, to call defer_fn(defer_ctx) after the test completes. This is typically used to eliminate a -resource leak in tests that terminate the test early.

    +resource leak in tests that terminate the test early.

    NOTE: The deferred function is designed to run outside a test, and -therefore it must not call Ptest functions.

    +therefore it must not call Ptest functions.

    @@ -630,9 +661,9 @@ therefore it must not call Ptest functions.
    PTEST_CTX *ptest_ctx_current(void)
    -
    Returns the PTEST_CTX pointer for the current test or subtest. +

    Returns the PTEST_CTX pointer for the current test or subtest. This can be used to handle a test error in a mock function or helper -function that has no PTEST_CTX argument.

    +function that has no PTEST_CTX argument.

    diff --git a/postfix/proto/PTEST_README.html b/postfix/proto/PTEST_README.html index 4d5259fca..2d944065e 100644 --- a/postfix/proto/PTEST_README.html +++ b/postfix/proto/PTEST_README.html @@ -102,9 +102,13 @@ $ make test_mymalloc LD_LIBRARY_PATH=/path/to/postfix-source/lib ./mymalloc_test RUN mymalloc + myfree normal case PASS mymalloc + myfree normal case + RUN mymalloc panic for too small request +LOG (expected) panic: mymalloc: requested length 0 PASS mymalloc panic for too small request + ... results for myrealloc(), mystrdup(), mymemdup()... + mymalloc_test: PASS: 22, SKIP: 0, FAIL: 0 @@ -136,11 +140,13 @@ small. But in this test the msg_panic() call will not terminate the process like it normally would. The Ptest framework changes the control flow of msg_panic() and msg_fatal() such that these functions will terminate their test, instead of -their process.

    +terminating the entire test process.

  • The expect_ptest_log_event() call sets up an expectation that msg_panic() will produce a specific error message; the test would fail if the expectation remains unsatisfied. +When an error message is logged as expected, it shows up in output +as "LOG (expected) ...content of expected message....

  • The ptest_fatal() call at the end of the second @@ -305,6 +311,7 @@ LD_LIBRARY_PATH=/path/to/postfix-source/lib ./dict_union_test ... RUN propagates notfound and found PASS propagates notfound and found + RUN error propagation: static map + fail map PASS error propagation: static map + fail map ... @@ -413,11 +420,15 @@ $ make test_map_search LD_LIBRARY_PATH=/path/to/postfix-source/lib ./map_search_test RUN test_map_search RUN test_map_search/test 0 +LOG (expected) warning: malformed map specification: 'type' +LOG (expected) warning: expected maptype:mapname instead of 'type' PASS test_map_search/test 0 + RUN test_map_search/test 1 PASS test_map_search/test 1 .... PASS test_map_search + map_search_test: PASS: 13, SKIP: 0, FAIL: 0 @@ -486,16 +497,16 @@ results as errors.

    void ptest_error(PTEST_CTX *t, const char *format, ...)
    -
    Called from inside a test, to report an unexpected test result, +

    Called from inside a test, to report an unexpected test result, and to flag the test as failed without terminating the test. This -call can be ignored with expect_ptest_error().

    +call can be ignored with expect_ptest_error().

    void ptest_fatal(PTEST_CTX *t, const char *format, ...)
    -
    Called from inside a test, to report an unexpected test result, +

    Called from inside a test, to report an unexpected test result, to flag the test as failed, and to terminate the test. This call -cannot be ignored with expect_ptest_error().

    +cannot be ignored with expect_ptest_error().

    @@ -507,9 +518,9 @@ cannot be ignored with expect_ptest_error().
    void ptest_info(PTEST_CTX *t, const char *format, ...)
    -
    Called from inside a test, to report a non-error condition +

    Called from inside a test, to report a non-error condition without terminating the test. This call cannot be ignored with -expect_ptest_error().

    +expect_ptest_error().

    @@ -522,13 +533,13 @@ to verify that an intentional error is reported as expected.

    expect_ptest_error(PTEST_CTX *t, const char *text)
    -
    Called from inside a test, to expect exactly one ptest_error() +

    Called from inside a test, to expect exactly one ptest_error() call with the specified text, and to ignore that ptest_error() call (i.e. don't flag the test as failed). To ignore multiple calls, call expect_ptest_error() multiple times. A test is flagged as failed when an expected error is not reported (and of course when an error is reported that is not expected with -expect_ptest_error()).

    +expect_ptest_error()).

    @@ -540,12 +551,21 @@ when an error is reported that is not expected with
  • Ptest changes the control flow of msg_fatal() and msg_panic(). When these functions are called during a test, -Ptest flags a test as failed and terminates the test instead of the +they will terminate the test instead of terminating the entire test process.

    -
  • Ptest silences the output from msg_info() and -other msg(3) calls, and installs a log event listener to -monitor Postfix logging.

    +
  • Ptest installs a log event listener to monitor Postfix +logging with msg_info() etc. Examples of what logging +may look like:

    + +
    +RUN  name-of-test
    +LOG  (expected) warning: some text...
    +LOG  (expected) panic: some text...
    +LOG  (info) some text...
    +Unexpected non-info event: some text....
    +FAIL name-of-test
    +
    @@ -557,11 +577,22 @@ monitor Postfix logging.

    expect_ptest_log_event(PTEST_CTX *t, const char *text)
    -
    Called from inside a test, to expect exactly one msg(3) -call with the specified text. To expect multiple events, call -expect_ptest_log_event() multiple times. A test is flagged -as failed when expected text is not logged, or when text is logged -that is not expected with expect_ptest_log_event().
    +

    Called from inside a test, to expect exactly one msg(3) +call with the specified text including any warning, +error, fatal, or panic prefix. To expect +multiple events, call expect_ptest_log_event() multiple +times. A test is flagged as failed when a warning or +higher-severity message was logged but not expected, or when such +a message was expected but not logged.

    + +

    There is no need to call expect_ptest_log_event() for +msg_info() logging; such text will be displayed whether or not it +is expected. Allowing arbitrary msg_info() calls makes bug hunting +easier.

    + +

    There also is no need to match an entire logging message; a +substring match will be sufficient. It only needs to be specific +enough.

    @@ -575,51 +606,51 @@ that is not expected with expect_ptest_log_event().
    void PTEST_RUN(PTEST_CTX *t, const char *test_name, { code in braces })
    -
    Called from inside a test, to run the { code in braces +

    Called from inside a test, to run the { code in braces } in it own subtest environment. In the test progress report, the subtest name is appended to the parent test name, formatted as -parent-name/child-name.

    NOTE: because PTEST_RUN() +parent-name/child-name.

    NOTE: because PTEST_RUN() is a macro, the { code in braces } MUST NOT contain a return statement; use ptest_return() instead. It is OK for { code in braces } to call a function that -uses return.

    +uses return.

    void PTEST_TRY(PTEST_CTX *t, const char *test_name, { code in braces })
    -
    Called from inside a test, to run the { code in braces +

    Called from inside a test, to run the { code in braces } without entering a new subtest environment. The purpose is to continue running the current test after the { code in braces } calls msg_fatal*() or msg_panic(). The { code in braces } should set a variable to indicate that PTEST_TRY() executed -"normally".

    NOTE: because PTEST_TRY() is a macro, the +"normally".

    NOTE: because PTEST_TRY() is a macro, the { code in braces } MUST NOT contain a return statement; use ptest_return() instead. It is OK for { code in braces } to call a function that uses return. -

    +

    NORETURN ptest_skip(PTEST_CTX *t)
    -
    Called from inside a test, to flag a test as skipped, and to +

    Called from inside a test, to flag a test as skipped, and to terminate the test without terminating the process. Use this to disable tests that are not applicable for a specific system type -or build configuration.

    +or build configuration.

    NORETURN ptest_return(PTEST_CTX *t)
    -
    Used inside a { code in braces } block to terminate -a PTEST_RUN subtest.

    +

    Used inside a { code in braces } block to terminate +a PTEST_RUN subtest.

    void ptest_defer(PTEST_CTX *t, void (*defer_fn)(void *), void *defer_ctx)
    -
    Called once from inside a test, to call defer_fn(defer_ctx) +

    Called once from inside a test, to call defer_fn(defer_ctx) after the test completes. This is typically used to eliminate a -resource leak in tests that terminate the test early.

    +resource leak in tests that terminate the test early.

    NOTE: The deferred function is designed to run outside a test, and -therefore it must not call Ptest functions.

    +therefore it must not call Ptest functions.

    @@ -630,9 +661,9 @@ therefore it must not call Ptest functions.
    PTEST_CTX *ptest_ctx_current(void)
    -
    Returns the PTEST_CTX pointer for the current test or subtest. +

    Returns the PTEST_CTX pointer for the current test or subtest. This can be used to handle a test error in a mock function or helper -function that has no PTEST_CTX argument.

    +function that has no PTEST_CTX argument.

    diff --git a/postfix/src/global/mail_params.c b/postfix/src/global/mail_params.c index eed53bfde..d7079dd2a 100644 --- a/postfix/src/global/mail_params.c +++ b/postfix/src/global/mail_params.c @@ -783,7 +783,6 @@ void mail_params_init() static const CONFIG_STR_TABLE first_str_defaults[] = { /* $mail_version may appear in other parameters. */ VAR_MAIL_VERSION, DEF_MAIL_VERSION, &var_mail_version, 1, 0, - VAR_SERVNAME, DEF_SERVNAME, &var_servname, 1, 0, VAR_SYSLOG_FACILITY, DEF_SYSLOG_FACILITY, &var_syslog_facility, 1, 0, VAR_INET_PROTOCOLS, DEF_INET_PROTOCOLS, &var_inet_protocols, 0, 0, VAR_MULTI_CONF_DIRS, DEF_MULTI_CONF_DIRS, &var_multi_conf_dirs, 0, 0, diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index 1a8451963..4b2c242ca 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 "20260506" +#define MAIL_RELEASE_DATE "20260508" #define MAIL_VERSION_NUMBER "3.12" #ifdef SNAPSHOT diff --git a/postfix/src/master/dgram_server.c b/postfix/src/master/dgram_server.c index 32aaa9a9e..426fc7cd9 100644 --- a/postfix/src/master/dgram_server.c +++ b/postfix/src/master/dgram_server.c @@ -446,7 +446,10 @@ NORETURN dgram_server_main(int argc, char **argv, DGRAM_SERVER_FN service,...) break; } } - set_mail_conf_str(VAR_SERVNAME, service_name); + /* Read-only parameters must not be changed with '-o name=value'. + set_mail_conf_str(VAR_PROCNAME, var_procname); + var_servname = mystrdup(servname); + set_mail_conf_str(VAR_SERVNAME, var_servname); /* * Initialize generic parameters and re-initialize logging in case of a diff --git a/postfix/src/master/event_server.c b/postfix/src/master/event_server.c index ff280db57..f70f124a4 100644 --- a/postfix/src/master/event_server.c +++ b/postfix/src/master/event_server.c @@ -725,7 +725,10 @@ NORETURN event_server_main(int argc, char **argv, MULTI_SERVER_FN service,...) break; } } - set_mail_conf_str(VAR_SERVNAME, service_name); + /* Read-only parameters must not be changed with '-o name=value'. + set_mail_conf_str(VAR_PROCNAME, var_procname); + var_servname = mystrdup(servname); + set_mail_conf_str(VAR_SERVNAME, var_servname); /* * Initialize generic parameters and re-initialize logging in case of a diff --git a/postfix/src/master/multi_server.c b/postfix/src/master/multi_server.c index 4e744d4d1..33f0012e0 100644 --- a/postfix/src/master/multi_server.c +++ b/postfix/src/master/multi_server.c @@ -703,7 +703,10 @@ NORETURN multi_server_main(int argc, char **argv, MULTI_SERVER_FN service,...) break; } } - set_mail_conf_str(VAR_SERVNAME, service_name); + /* Read-only parameters must not be changed with '-o name=value'. + set_mail_conf_str(VAR_PROCNAME, var_procname); + var_servname = mystrdup(servname); + set_mail_conf_str(VAR_SERVNAME, var_servname); /* * Initialize generic parameters and re-initialize logging in case of a diff --git a/postfix/src/master/single_server.c b/postfix/src/master/single_server.c index 38f22b724..4c4559f60 100644 --- a/postfix/src/master/single_server.c +++ b/postfix/src/master/single_server.c @@ -577,7 +577,10 @@ NORETURN single_server_main(int argc, char **argv, SINGLE_SERVER_FN service,...) break; } } - set_mail_conf_str(VAR_SERVNAME, service_name); + /* Read-only parameters must not be changed with '-o name=value'. + set_mail_conf_str(VAR_PROCNAME, var_procname); + var_servname = mystrdup(servname); + set_mail_conf_str(VAR_SERVNAME, var_servname); /* * Initialize generic parameters. diff --git a/postfix/src/master/trigger_server.c b/postfix/src/master/trigger_server.c index c483a9ecc..4aca681f4 100644 --- a/postfix/src/master/trigger_server.c +++ b/postfix/src/master/trigger_server.c @@ -559,7 +559,10 @@ NORETURN trigger_server_main(int argc, char **argv, TRIGGER_SERVER_FN service,.. break; } } - set_mail_conf_str(VAR_SERVNAME, service_name); + /* Read-only parameters must not be changed with '-o name=value'. + set_mail_conf_str(VAR_PROCNAME, var_procname); + var_servname = mystrdup(servname); + set_mail_conf_str(VAR_SERVNAME, var_servname); /* * Initialize generic parameters and re-initialize logging in case of a diff --git a/postfix/src/postconf/postconf_builtin.c b/postfix/src/postconf/postconf_builtin.c index b8534beac..e0902862b 100644 --- a/postfix/src/postconf/postconf_builtin.c +++ b/postfix/src/postconf/postconf_builtin.c @@ -185,6 +185,7 @@ static const CONFIG_STR_FN_TABLE pcf_str_fn_table[] = { * effects, then those side effects must happen only once. */ static CONFIG_STR_TABLE pcf_adhoc_procname = {VAR_PROCNAME}; +static CONFIG_STR_TABLE pcf_adhoc_servname = {VAR_SERVNAME}; static CONFIG_INT_TABLE pcf_adhoc_pid = {VAR_PID}; #define STR(x) vstring_str(x) @@ -465,6 +466,10 @@ void pcf_register_builtin_parameters(const char *procname, pid_t pid) PCF_PARAM_TABLE_ENTER(pcf_param_table, pcf_adhoc_procname.name, PCF_PARAM_FLAG_BUILTIN | PCF_PARAM_FLAG_READONLY, (void *) &pcf_adhoc_procname, pcf_conv_str_parameter); + pcf_adhoc_servname.defval = mystrdup(""); + PCF_PARAM_TABLE_ENTER(pcf_param_table, pcf_adhoc_servname.name, + PCF_PARAM_FLAG_BUILTIN | PCF_PARAM_FLAG_READONLY, + (void *) &pcf_adhoc_servname, pcf_conv_str_parameter); pcf_adhoc_pid.defval = pid; PCF_PARAM_TABLE_ENTER(pcf_param_table, pcf_adhoc_pid.name, PCF_PARAM_FLAG_BUILTIN | PCF_PARAM_FLAG_READONLY, diff --git a/postfix/src/ptest/ptest_log.c b/postfix/src/ptest/ptest_log.c index c54112c98..b9cc959fb 100644 --- a/postfix/src/ptest/ptest_log.c +++ b/postfix/src/ptest/ptest_log.c @@ -101,15 +101,25 @@ static void ptest_log_event(int level, const char *text, void *context) } /* - * Handle expected versus unexpected text. + * Handle matched text. */ for (cpp = t->allow_logs->argv; *cpp; cpp++) { if (strstr(STR(t->log_buf), *cpp) != 0) { argv_delete(t->allow_logs, cpp - t->allow_logs->argv, 1); + ptest_info(t, "LOG (expected) %s", STR(t->log_buf)); return; } } - ptest_error(t, "Unexpected log event: got '%s'", STR(t->log_buf)); + + /* + * Pass through unmatched info logging. Flag other unmatched logging as + * an error. + */ + if (level == MSG_INFO) { + ptest_info(t, "LOG (info) %s", text); + } else { + ptest_error(t, "Unexpected non-info event: got '%s'", STR(t->log_buf)); + } } /* ptest_log_setup - install logging receiver */ diff --git a/postfix/src/ptest/ptest_log_test.c b/postfix/src/ptest/ptest_log_test.c index 275c700f1..fb72b92d6 100644 --- a/postfix/src/ptest/ptest_log_test.c +++ b/postfix/src/ptest/ptest_log_test.c @@ -34,7 +34,7 @@ static void ptest_log_non_error(PTEST_CTX *t, const PTEST_CASE *unused) static void ptest_log_flags_unexpected_message(PTEST_CTX *t, const PTEST_CASE *unused) { expect_ptest_error(t, "this is a forced 'Unexpected log event' error"); - msg_info("this is a forced 'Unexpected log event' error"); + msg_warn("this is a forced 'Unexpected log event' error"); } static void ptest_log_flags_missing_message(PTEST_CTX *t, const PTEST_CASE *unused) @@ -46,13 +46,13 @@ static void ptest_log_flags_missing_message(PTEST_CTX *t, const PTEST_CASE *unus static void ptest_nested_logging(PTEST_CTX * t, const PTEST_CASE * unused) { expect_ptest_log_event(t, "top-level"); - msg_info("this is a top-level event"); + msg_warn("this is a top-level event"); PTEST_RUN(t, "top-1 level", { expect_ptest_log_event(t, "top-1 level event"); - msg_info("this is a top-1 level event"); + msg_warn("this is a top-1 level event"); PTEST_RUN(t, "top-2 level", { expect_ptest_log_event(t, "top-2 level event"); - msg_info("this is a top-2 level event"); + msg_warn("this is a top-2 level event"); }); }); } diff --git a/postfix/src/ptest/ptest_run.c b/postfix/src/ptest/ptest_run.c index 52622bcd0..5e6ad9591 100644 --- a/postfix/src/ptest/ptest_run.c +++ b/postfix/src/ptest/ptest_run.c @@ -116,13 +116,13 @@ void ptest_run_epilog(PTEST_CTX *t, PTEST_CTX *parent) ptest_log_wrapup(t); pmock_expect_wrapup(t); if (ptest_error_wrapup(t) != 0 || t->sub_fail != 0) { - ptest_info(t, "FAIL %s", t->name); + ptest_info(t, "FAIL %s\n", t->name); parent->sub_fail += 1; } else if (t->flags & PTEST_CTX_FLAG_SKIP) { ptest_info(t, "SKIP %s", t->name); parent->sub_skip += 1; } else { - ptest_info(t, "PASS %s", t->name); + ptest_info(t, "PASS %s\n", t->name); parent->sub_pass += 1; } parent->sub_pass += t->sub_pass; diff --git a/postfix/src/util/Makefile.in b/postfix/src/util/Makefile.in index b41e3ed9c..9720b7da5 100644 --- a/postfix/src/util/Makefile.in +++ b/postfix/src/util/Makefile.in @@ -3144,6 +3144,7 @@ sunos5_stream_test.o: vbuf.h sunos5_stream_test.o: vstream.h sys_compat.o: sys_compat.c sys_compat.o: sys_defs.h +timecmp.o: sys_defs.h timecmp.o: timecmp.c timecmp.o: timecmp.h timed_connect.o: iostuff.h diff --git a/postfix/src/util/mymalloc_test.c b/postfix/src/util/mymalloc_test.c index d64836dae..4097b27ff 100644 --- a/postfix/src/util/mymalloc_test.c +++ b/postfix/src/util/mymalloc_test.c @@ -290,7 +290,7 @@ static const PTEST_CASE ptestcases[] = { }, {"mystrndup panic for null input", test_mystrndup_panic_null, }, - {"mystrndup panic for for too small size", test_mystrndup_panic_too_small, + {"mystrndup panic for too small size", test_mystrndup_panic_too_small, }, {"mystrndup static result for empty string", test_mystrndup_static_empty, }, diff --git a/postfix/src/util/timecmp.c b/postfix/src/util/timecmp.c index 607a9ae63..93f28511f 100644 --- a/postfix/src/util/timecmp.c +++ b/postfix/src/util/timecmp.c @@ -29,7 +29,15 @@ /* Viktor Dukhovni /*--*/ -#include "timecmp.h" + /* + * System library. + */ +#include + + /* + * Utility library. + */ +#include /* timecmp - wrap-safe time_t comparison */ @@ -57,17 +65,6 @@ int timecmp(time_t t1, time_t t2) #ifdef TEST #include - /* - * Bit banging!! There is no official constant that defines the INT_MAX - * equivalent of the off_t type. Wietse came up with the following macro - * that works as long as off_t is some two's complement number. - * - * Note, however, that C99 permits signed integer representations other than - * two's complement. - */ -#include -#define __MAXINT__(T) ((T) (((((T) 1) << ((sizeof(T) * CHAR_BIT) - 1)) ^ ((T) -1)))) - int main(void) { time_t now = time((time_t *) 0); diff --git a/postfix/src/util/vstring.h b/postfix/src/util/vstring.h index 49fd960aa..c478d02af 100644 --- a/postfix/src/util/vstring.h +++ b/postfix/src/util/vstring.h @@ -62,7 +62,7 @@ CHECK_VAL_HELPER_DCL(VSTRING_CTL, ssize_t); /* Flags 24..31 are reserved for VSTRING. */ #define VSTRING_FLAG_EXACT (1<<24) /* exact allocation for tests */ -#define VSTRING_FLAG_MASK (255 << 24) +#define VSTRING_FLAG_MASK (255U << 24) /* * Macros. Unsafe macros have UPPERCASE names.