From f90a37225c521b9f03f7c2f46e58fe5aae87f920 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sun, 15 Sep 2024 15:57:36 +0100 Subject: [PATCH] Log: more info in ACL "warn statement skipped" message. Bug 2897 --- src/src/acl.c | 16 ++++++++++++---- test/log/0023 | 2 +- test/stderr/0023 | 2 +- test/stderr/2610 | 6 +++--- test/stderr/2620 | 12 ++++++------ 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/src/acl.c b/src/src/acl.c index 45438eca9..ab05b13a9 100644 --- a/src/src/acl.c +++ b/src/src/acl.c @@ -4807,10 +4807,18 @@ while ((acl_current = acl)) if (cond == OK) acl_warn(where, *user_msgptr, *log_msgptr); else if (cond == DEFER && LOGGING(acl_warn_skipped)) - log_write(0, LOG_MAIN, "%s Warning: ACL \"warn\" statement skipped: " - "condition test deferred%s%s", host_and_ident(TRUE), - *log_msgptr ? US": " : US"", - *log_msgptr ? *log_msgptr : US""); + if (config_lineno > 0) + log_write(0, LOG_MAIN, + "%s Warning: ACL 'warn' statement skipped (in %s at line %d of %s):" + " condition test deferred%s%s", + host_and_ident(TRUE), acl_name, config_lineno, config_filename, + *log_msgptr ? US": " : US"", *log_msgptr ? *log_msgptr : US""); + else + log_write(0, LOG_MAIN, + "%s Warning: ACL 'warn' statement skipped (in %s):" + " condition test deferred%s%s", + host_and_ident(TRUE), acl_name, + *log_msgptr ? US": " : US"", *log_msgptr ? *log_msgptr : US""); *log_msgptr = *user_msgptr = NULL; /* In case implicit DENY follows */ break; diff --git a/test/log/0023 b/test/log/0023 index 96540424c..80161e07d 100644 --- a/test/log/0023 +++ b/test/log/0023 @@ -19,7 +19,7 @@ 1999-03-02 09:44:33 10HmbD-000000005vi-0000 <= userx@test.ex H=(test) [56.56.56.56] U=CALLER P=smtp S=sss 1999-03-02 09:44:33 10HmbD-000000005vi-0000 => cond-true R=r1 T=t1 1999-03-02 09:44:33 10HmbD-000000005vi-0000 Completed -1999-03-02 09:44:33 H=(test) [56.56.56.56] U=CALLER Warning: ACL "warn" statement skipped: condition test deferred: invalid "condition" value "rhubarb" +1999-03-02 09:44:33 H=(test) [56.56.56.56] U=CALLER Warning: ACL 'warn' statement skipped (in ACL acl_56_56_56 at line 204 of TESTSUITE/test-config): condition test deferred: invalid "condition" value "rhubarb" 1999-03-02 09:44:33 10HmbE-000000005vi-0000 <= userx@test.ex H=(test) [56.56.56.56] U=CALLER P=smtp S=sss 1999-03-02 09:44:33 10HmbE-000000005vi-0000 => cond-rhubarb R=r1 T=t1 1999-03-02 09:44:33 10HmbE-000000005vi-0000 Completed diff --git a/test/stderr/0023 b/test/stderr/0023 index 18113e6e1..fc1709c3e 100644 --- a/test/stderr/0023 +++ b/test/stderr/0023 @@ -1852,7 +1852,7 @@ LOG: DNS list lookup defer (probably timeout) for 1.44.44.44.test.again.dns: ass >>> dnslists: using result of previous lookup LOG: DNS list lookup defer (probably timeout) for 1.44.44.44.test.again.dns: returned DEFER >>> warn: condition test deferred in ACL acl_44_44_44 -LOG: H=(test) [44.44.44.1] Warning: ACL "warn" statement skipped: condition test deferred +LOG: H=(test) [44.44.44.1] Warning: ACL 'warn' statement skipped (in ACL acl_44_44_44 at line 195 of TESTSUITE/test-config): condition test deferred >>> processing ACL acl_44_44_44 "accept" (TESTSUITE/test-config 196) >>> accept: condition test succeeded in ACL acl_44_44_44 >>> end of ACL acl_44_44_44: ACCEPT diff --git a/test/stderr/2610 b/test/stderr/2610 index e964a6fba..0addebc69 100644 --- a/test/stderr/2610 +++ b/test/stderr/2610 @@ -512,7 +512,7 @@ close MYSQL connection: 127.0.0.1:PORT_N/test/root 01:01:01 p1235 ╰───error message: lookup of "servers=127.0.0.1::PORT_N/test/root/pass; select name from them where id = 'c'" gave DEFER: MySQL server "127.0.0.1:1223/test" is tainted 01:01:01 p1235 warn: condition test deferred in ACL check_recipient 01:01:01 p1235 LOG: MAIN -01:01:01 p1235 H=(test) [10.0.0.0] Warning: ACL "warn" statement skipped: condition test deferred: MySQL server "127.0.0.1:PORT_N/test" is tainted +01:01:01 p1235 H=(test) [10.0.0.0] Warning: ACL 'warn' statement skipped (in ACL check_recipient at line 31 of TESTSUITE/test-config): condition test deferred: MySQL server "127.0.0.1:PORT_N/test" is tainted 01:01:01 p1235 processing ACL check_recipient "warn" (TESTSUITE/test-config 39) 01:01:01 p1235 ╭considering: FAIL3:░${lookup░mysql░░░░░{servers=127.0.0.1::PORT_N;░select░name░from░them░where░id░=░'$local_part'}} 01:01:01 p1235 ├───────text: FAIL3:░ @@ -632,7 +632,7 @@ close MYSQL connection: 127.0.0.1:PORT_N/test/root 01:01:01 p1235 host in "<& net-mysql;servers=127.0.0.1::PORT_N/test/root/pass; select * from them where id='c'"? list match deferred for net-mysql;servers=127.0.0.1::1223/test/root/pass; select * from them where id='c' 01:01:01 p1235 warn: condition test deferred in ACL check_recipient 01:01:01 p1235 LOG: MAIN -01:01:01 p1235 H=(test) [10.0.0.0] Warning: ACL "warn" statement skipped: condition test deferred: MySQL server "127.0.0.1:PORT_N/test" is tainted +01:01:01 p1235 H=(test) [10.0.0.0] Warning: ACL 'warn' statement skipped (in ACL check_recipient at line 45 of TESTSUITE/test-config): condition test deferred: MySQL server "127.0.0.1:PORT_N/test" is tainted 01:01:01 p1235 processing ACL check_recipient "warn" (TESTSUITE/test-config 50) 01:01:01 p1235 check set acl_m0 = FAIL5: hostlist 01:01:01 p1235 check hosts = <& net-mysql,servers=127.0.0.1::PORT_N/test/root/pass; select * from them where id='${quote_mysql:$local_part}' @@ -669,7 +669,7 @@ close MYSQL connection: 127.0.0.1:PORT_N/test/root 01:01:01 p1235 host in "<& net-mysql,servers=127.0.0.1::PORT_N/test/root/pass; select * from them where id='c'"? list match deferred for net-mysql,servers=127.0.0.1::1223/test/root/pass; select * from them where id='c' 01:01:01 p1235 warn: condition test deferred in ACL check_recipient 01:01:01 p1235 LOG: MAIN -01:01:01 p1235 H=(test) [10.0.0.0] Warning: ACL "warn" statement skipped: condition test deferred: MySQL server "127.0.0.1:PORT_N/test" is tainted +01:01:01 p1235 H=(test) [10.0.0.0] Warning: ACL 'warn' statement skipped (in ACL check_recipient at line 50 of TESTSUITE/test-config): condition test deferred: MySQL server "127.0.0.1:PORT_N/test" is tainted 01:01:01 p1235 processing ACL check_recipient "accept" (TESTSUITE/test-config 53) 01:01:01 p1235 check domains = +local_domains 01:01:01 p1235 d in "+local_domains"? diff --git a/test/stderr/2620 b/test/stderr/2620 index dd6466bc4..fc3e76f2e 100644 --- a/test/stderr/2620 +++ b/test/stderr/2620 @@ -354,7 +354,7 @@ LOG: MAIN lookup deferred: PostgreSQL server "localhost:PORT_N/test" is tainted warn: condition test deferred in ACL check_recipient LOG: MAIN - H=(test) [10.0.0.0] Warning: ACL "warn" statement skipped: condition test deferred: PostgreSQL server "localhost:PORT_N/test" is tainted + H=(test) [10.0.0.0] Warning: ACL 'warn' statement skipped (in ACL check_recipient at line 32 of TESTSUITE/test-config): condition test deferred: PostgreSQL server "localhost:PORT_N/test" is tainted processing ACL check_recipient "warn" (TESTSUITE/test-config 41) check set acl_m0 = ok: hostlist check hosts = net-pgsql;select * from them where id='${quote_pgsql:$local_part}' @@ -398,7 +398,7 @@ LOG: MAIN host in "<& net-pgsql;servers=localhost::PORT_N/test/CALLER/; select * from them where id='c'"? list match deferred for net-pgsql;servers=localhost::1223/test/CALLER/; select * from them where id='c' warn: condition test deferred in ACL check_recipient LOG: MAIN - H=(test) [10.0.0.0] Warning: ACL "warn" statement skipped: condition test deferred: PostgreSQL server "localhost:PORT_N/test" is tainted + H=(test) [10.0.0.0] Warning: ACL 'warn' statement skipped (in ACL check_recipient at line 44 of TESTSUITE/test-config): condition test deferred: PostgreSQL server "localhost:PORT_N/test" is tainted processing ACL check_recipient "warn" (TESTSUITE/test-config 49) check set acl_m0 = FAIL: hostlist check hosts = <& net-pgsql,servers=localhost::PORT_N/test/CALLER/; select * from them where id='${quote_pgsql:$local_part}' @@ -418,7 +418,7 @@ host in "<& net-pgsql,servers=localhost::PORT_N/test/CALLER/; select * from them host in "<& net-pgsql,servers=localhost::PORT_N/test/CALLER/; select * from them where id='c'"? list match deferred for net-pgsql,servers=localhost::1223/test/CALLER/; select * from them where id='c' warn: condition test deferred in ACL check_recipient LOG: MAIN - H=(test) [10.0.0.0] Warning: ACL "warn" statement skipped: condition test deferred: PostgreSQL server "localhost:PORT_N/test" is tainted + H=(test) [10.0.0.0] Warning: ACL 'warn' statement skipped (in ACL check_recipient at line 49 of TESTSUITE/test-config): condition test deferred: PostgreSQL server "localhost:PORT_N/test" is tainted processing ACL check_recipient "accept" (TESTSUITE/test-config 52) check domains = +local_domains d in "+local_domains"? @@ -550,7 +550,7 @@ LOG: MAIN lookup deferred: PostgreSQL server "localhost:PORT_N/test" is tainted warn: condition test deferred in ACL check_recipient LOG: MAIN - H=(test) [10.0.0.0] Warning: ACL "warn" statement skipped: condition test deferred: PostgreSQL server "localhost:PORT_N/test" is tainted + H=(test) [10.0.0.0] Warning: ACL 'warn' statement skipped (in ACL check_recipient at line 32 of TESTSUITE/test-config): condition test deferred: PostgreSQL server "localhost:PORT_N/test" is tainted processing ACL check_recipient "warn" (TESTSUITE/test-config 41) check set acl_m0 = ok: hostlist check hosts = net-pgsql;select * from them where id='${quote_pgsql:$local_part}' @@ -589,7 +589,7 @@ LOG: MAIN host in "<& net-pgsql;servers=localhost::PORT_N/test/CALLER/; select * from them where id='c'"? list match deferred for net-pgsql;servers=localhost::1223/test/CALLER/; select * from them where id='c' warn: condition test deferred in ACL check_recipient LOG: MAIN - H=(test) [10.0.0.0] Warning: ACL "warn" statement skipped: condition test deferred: PostgreSQL server "localhost:PORT_N/test" is tainted + H=(test) [10.0.0.0] Warning: ACL 'warn' statement skipped (in ACL check_recipient at line 44 of TESTSUITE/test-config): condition test deferred: PostgreSQL server "localhost:PORT_N/test" is tainted processing ACL check_recipient "warn" (TESTSUITE/test-config 49) check set acl_m0 = FAIL: hostlist check hosts = <& net-pgsql,servers=localhost::PORT_N/test/CALLER/; select * from them where id='${quote_pgsql:$local_part}' @@ -609,7 +609,7 @@ host in "<& net-pgsql,servers=localhost::PORT_N/test/CALLER/; select * from them host in "<& net-pgsql,servers=localhost::PORT_N/test/CALLER/; select * from them where id='c'"? list match deferred for net-pgsql,servers=localhost::1223/test/CALLER/; select * from them where id='c' warn: condition test deferred in ACL check_recipient LOG: MAIN - H=(test) [10.0.0.0] Warning: ACL "warn" statement skipped: condition test deferred: PostgreSQL server "localhost:PORT_N/test" is tainted + H=(test) [10.0.0.0] Warning: ACL 'warn' statement skipped (in ACL check_recipient at line 49 of TESTSUITE/test-config): condition test deferred: PostgreSQL server "localhost:PORT_N/test" is tainted processing ACL check_recipient "accept" (TESTSUITE/test-config 52) check domains = +local_domains d in "+local_domains"? -- 2.30.2