[exim-cvs] Logging: fix lookups "obsolete syntax" message. …

Góra strony
Delete this message
Reply to this message
Autor: Exim Git Commits Mailing List
Data:  
Dla: exim-cvs
Temat: [exim-cvs] Logging: fix lookups "obsolete syntax" message. Bug 3112
Gitweb: https://git.exim.org/exim.git/commitdiff/3f96c3e750eb4e4dc63f53d783106aa5cf2498cb
Commit:     3f96c3e750eb4e4dc63f53d783106aa5cf2498cb
Parent:     84bc2d752a4aa3bc3a572dbeabe2a626889bdc27
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Tue Sep 10 10:29:45 2024 +0100
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Tue Sep 10 10:29:45 2024 +0100

    Logging: fix lookups "obsolete syntax" message.  Bug 3112
---
 doc/doc-txt/ChangeLog |  3 +++
 src/src/acl.c         |  9 +++++++--
 src/src/exim.c        | 12 +++++++++---
 src/src/globals.c     |  3 ++-
 src/src/globals.h     |  3 ++-
 src/src/log.c         | 14 +++++++++++++-
 src/src/readconf.c    |  1 +
 test/stderr/2610      | 16 ++++++++--------
 test/stderr/2620      | 16 ++++++++--------
 9 files changed, 53 insertions(+), 24 deletions(-)

diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index 22c934b82..1c8e060c1 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -56,6 +56,9 @@ JH/11 Lookups built as dynamic-load modules which support a single lookup
       modules present in the modules directory were loaded; this now applies
       only to those supporting multiple types.
 
+JH/12 Bug 3112: Fix logging of config-file position for "obsolete lookup
+      syntax". Previously, the end of the top-level file was reported.
+
 Exim version 4.98
 -----------------
 
diff --git a/src/src/acl.c b/src/src/acl.c
index 18d892ec5..9eb4c133f 100644
--- a/src/src/acl.c
+++ b/src/src/acl.c
@@ -4666,8 +4666,11 @@ while ((acl_current = acl))
   *log_msgptr = *user_msgptr = NULL;
   f.acl_temp_details = FALSE;
 
+  config_filename = acl->srcfile;
+  config_lineno = acl->srcline;
+
   HDEBUG(D_acl) debug_printf_indent("processing \"%s\" (%s %d)\n",
-    verbs[acl->verb], acl->srcfile, acl->srcline);
+    verbs[acl->verb], config_filename, config_lineno);
 
   /* Clear out any search error message from a previous check before testing
   this condition. */
@@ -4877,6 +4880,7 @@ while (i < 9)
 acl_level++;
 ret = acl_check_internal(where, addr, name, user_msgptr, log_msgptr);
 acl_level--;
+config_lineno = 0;
 
 acl_narg = sav_narg;
 for (i = 0; i < 9; i++) acl_arg[i] = sav_arg[i];
@@ -4922,6 +4926,7 @@ if (where == ACL_WHERE_RCPT)
 acl_level++;
 rc = acl_check_internal(where, addr, s, user_msgptr, log_msgptr);
 acl_level--;
+config_lineno = 0;
 return rc;
 }
 
@@ -4945,7 +4950,6 @@ Returns:       OK         access is granted by an ACCEPT verb
                DEFER      can't tell at the moment
                ERROR      disaster
 */
-int acl_where = ACL_WHERE_UNKNOWN;
 
 int
 acl_check(int where, const uschar * recipient, uschar * s,
@@ -4990,6 +4994,7 @@ acl_level = 0;
 rc = acl_check_internal(where, addr, s, user_msgptr, log_msgptr);
 acl_level = 0;
 acl_where = ACL_WHERE_UNKNOWN;
+config_lineno = 0;
 
 /* Cutthrough - if requested,
 and WHERE_RCPT and not yet opened conn as result of recipient-verify,
diff --git a/src/src/exim.c b/src/src/exim.c
index 9774281e4..3d1b7f1d9 100644
--- a/src/src/exim.c
+++ b/src/src/exim.c
@@ -5494,8 +5494,12 @@ if (expansion_test)
   /* Expand command line items */
 
   if (recipients_arg < argc)
-    while (recipients_arg < argc)
-      expansion_test_line(exim_str_fail_toolong(argv[recipients_arg++], EXIM_EMAILADDR_MAX, "recipient"));
+    {
+    config_filename = US"-be args";
+    for (config_lineno = 1; recipients_arg < argc; config_lineno++)
+      expansion_test_line(exim_str_fail_toolong(argv[recipients_arg++],
+                          EXIM_EMAILADDR_MAX, "-be arg"));
+    }
 
   /* Read stdin */
 
@@ -5509,7 +5513,9 @@ if (expansion_test)
     void *dlhandle = set_readline(&fn_readline, &fn_addhist);
 #endif
 
-    while (s = get_stdinput(fn_readline, fn_addhist))
+    config_filename = US"-be stdin";
+    for (config_lineno = 1; s = get_stdinput(fn_readline, fn_addhist);
+    config_lineno++)
       expansion_test_line(s);
 
 #ifdef USE_READLINE
diff --git a/src/src/globals.c b/src/src/globals.c
index c65ddf413..e887c2741 100644
--- a/src/src/globals.c
+++ b/src/src/globals.c
@@ -472,6 +472,7 @@ tree_node *acl_var_c           = NULL;
 tree_node *acl_var_m           = NULL;
 uschar *acl_verify_message     = NULL;
 string_item *acl_warn_logged   = NULL;
+int acl_where               = ACL_WHERE_UNKNOWN;
 
 /* Names of SMTP places for use in ACL error messages, and corresponding SMTP
 error codes (only those used) */
@@ -713,7 +714,7 @@ int     clmacro_count          = 0;
 uschar *clmacros[MAX_CLMACROS];
 FILE   *config_file            = NULL;
 const uschar *config_filename  = NULL;
-int     config_lineno          = 0;
+unsigned config_lineno         = 0;
 #ifdef CONFIGURE_GROUP
 gid_t   config_gid             = CONFIGURE_GROUP;
 #else
diff --git a/src/src/globals.h b/src/src/globals.h
index 2f2f023e3..a172d9abc 100644
--- a/src/src/globals.h
+++ b/src/src/globals.h
@@ -349,6 +349,7 @@ extern tree_node *acl_var_c;           /* ACL connection variables */
 extern tree_node *acl_var_m;           /* ACL message variables */
 extern uschar *acl_verify_message;     /* User message for verify failure */
 extern string_item *acl_warn_logged;   /* Logged lines */
+extern int acl_where;               /* Current running ACL */
 extern uschar *acl_wherecodes[];       /* Response codes for ACL fails */
 extern uschar *acl_wherenames[];       /* Names for messages */
 extern address_item *addr_duplicate;   /* Duplicate address list */
@@ -433,7 +434,7 @@ extern int     connection_max_messages;/* Max down one SMTP connection */
 extern FILE   *config_file;            /* Configuration file */
 extern const uschar *config_filename;  /* Configuration file name */
 extern gid_t   config_gid;             /* Additional group owner */
-extern int     config_lineno;          /* Line number */
+extern unsigned config_lineno;         /* Line number */
 extern const uschar *config_main_filelist; /* List of possible config files */
 extern uschar *config_main_filename;   /* File name actually used */
 extern uschar *config_main_directory;  /* Directory where the main config file was found */
diff --git a/src/src/log.c b/src/src/log.c
index 1b4cea155..a7bc2aab7 100644
--- a/src/src/log.c
+++ b/src/src/log.c
@@ -642,8 +642,20 @@ if (flags & (LOG_CONFIG_FOR & ~LOG_CONFIG))
 else
   {
   if (flags & (LOG_CONFIG_IN & ~LOG_CONFIG))
-    string_fmt_append_noextend(g, " in line %d of %s",
+    if (config_lineno > 0)
+      {
+      if (acl_where != ACL_WHERE_UNKNOWN)
+    string_fmt_append_noextend(g, " in ACL verb at");
+      else
+    string_fmt_append_noextend(g, " in");
+
+      string_fmt_append_noextend(g, " line %d of %s",
                   config_lineno, config_filename);
+      }
+    else if (router_name)
+      string_fmt_append_noextend(g, " in %s router", router_name);
+    else if (transport_name)
+      string_fmt_append_noextend(g, " in %s transport", transport_name);
 
   string_fmt_append_noextend(g, ":\n  ");
   }
diff --git a/src/src/readconf.c b/src/src/readconf.c
index 5aabd0194..3f49691e4 100644
--- a/src/src/readconf.c
+++ b/src/src/readconf.c
@@ -4621,6 +4621,7 @@ while(next_section[0] != 0)
   }
 
 (void)fclose(config_file);
+config_lineno = 0;        /* Ensure we don't log a spurious position */
 }
 
 /* Init the storage for the pre-parsed config lines */
diff --git a/test/stderr/2610 b/test/stderr/2610
index f253cac9d..f66ff8eae 100644
--- a/test/stderr/2610
+++ b/test/stderr/2610
@@ -137,7 +137,7 @@ dropping to exim gid; retaining priv uid
  database lookup required for servers=x:127.0.0.1::PORT_N; select name from them where id='ph10';
  MySQL query: "servers=x:127.0.0.1::PORT_N; select name from them where id='ph10';" opts 'NULL'
 LOG: MAIN
-  Exim configuration error in line 89 of TESTSUITE/test-config:
+  Exim configuration error in line 11 of -be stdin:
   WARNING: obsolete syntax used for lookup
  lookup deferred: MySQL server "x" not found in mysql_servers
  search_open: mysql "NULL"
@@ -150,7 +150,7 @@ LOG: MAIN
  database lookup required for servers=127.0.0.1::PORT_N:x; select name from them where id='ph10';
  MySQL query: "servers=127.0.0.1::PORT_N:x; select name from them where id='ph10';" opts 'NULL'
 LOG: MAIN
-  Exim configuration error in line 89 of TESTSUITE/test-config:
+  Exim configuration error in line 12 of -be stdin:
   WARNING: obsolete syntax used for lookup
  MYSQL using cached connection for 127.0.0.1:PORT_N/test/root
  creating new cache entry
@@ -165,7 +165,7 @@ LOG: MAIN
  database lookup required for servers=127.0.0.1::PORT_N/test/root/:x; select name from them where id='ph10';
  MySQL query: "servers=127.0.0.1::PORT_N/test/root/:x; select name from them where id='ph10';" opts 'NULL'
 LOG: MAIN
-  Exim configuration error in line 89 of TESTSUITE/test-config:
+  Exim configuration error in line 13 of -be stdin:
   WARNING: obsolete syntax used for lookup
  MYSQL using cached connection for 127.0.0.1:PORT_N/test/root
  creating new cache entry
@@ -180,7 +180,7 @@ LOG: MAIN
  database lookup required for servers=ip4.ip4.ip4.ip4::1223/test/root/:127.0.0.1::PORT_N; select name from them where id='ph10';
  MySQL query: "servers=ip4.ip4.ip4.ip4::1223/test/root/:127.0.0.1::PORT_N; select name from them where id='ph10';" opts 'NULL'
 LOG: MAIN
-  Exim configuration error in line 89 of TESTSUITE/test-config:
+  Exim configuration error in line 14 of -be stdin:
   WARNING: obsolete syntax used for lookup
  MYSQL new connection: host=ip4.ip4.ip4.ip4 port=PORT_N socket=NULL database=test user=root
  creating new cache entry
@@ -195,7 +195,7 @@ LOG: MAIN
  database lookup required for servers=localhost(TESTSUITE/mysql/sock)/test/root/pass; select name from them where id='ph10';
  MySQL query: "servers=localhost(TESTSUITE/mysql/sock)/test/root/pass; select name from them where id='ph10';" opts 'NULL'
 LOG: MAIN
-  Exim configuration error in line 89 of TESTSUITE/test-config:
+  Exim configuration error in line 15 of -be stdin:
   WARNING: obsolete syntax used for lookup
  MYSQL new connection: host=localhost port=0 socket=TESTSUITE/mysql/sock database=test user=root
  creating new cache entry
@@ -505,7 +505,7 @@ close MYSQL connection: 127.0.0.1:PORT_N/test/root
 01:01:01 p1235                                (tainted, quoted:mysql)
 01:01:01 p1235   MySQL query: "servers=127.0.0.1::PORT_N/test/root/pass; select name from them where id = 'c'" opts 'NULL'
 01:01:01 p1235  LOG: MAIN
-01:01:01 p1235    Exim configuration error in line 89 of TESTSUITE/test-config:
+01:01:01 p1235    Exim configuration error in ACL verb at line 31 of TESTSUITE/test-config:
 01:01:01 p1235    WARNING: obsolete syntax used for lookup
 01:01:01 p1235   lookup deferred: MySQL server "127.0.0.1:PORT_N/test" is tainted
 01:01:01 p1235   ├failed to expand: FAIL2: ${lookup mysql     {servers=127.0.0.1::PORT_N/test/root/pass; select name from them where id = '${quote_mysql:$local_part}'}}
@@ -543,7 +543,7 @@ close MYSQL connection: 127.0.0.1:PORT_N/test/root
 01:01:01 p1235   required_quoter_id (mysql) quoting -1 (NULL)
 01:01:01 p1235   MySQL query: "servers=127.0.0.1::PORT_N; select name from them where id = 'c'" opts 'NULL'
 01:01:01 p1235  LOG: MAIN
-01:01:01 p1235    Exim configuration error in line 89 of TESTSUITE/test-config:
+01:01:01 p1235    Exim configuration error in ACL verb at line 39 of TESTSUITE/test-config:
 01:01:01 p1235    WARNING: obsolete syntax used for lookup
 01:01:01 p1235   MYSQL using cached connection for 127.0.0.1:PORT_N/test/root
 01:01:01 p1235   MYSQL: no data found
@@ -626,7 +626,7 @@ close MYSQL connection: 127.0.0.1:PORT_N/test/root
 01:01:01 p1235                                (tainted, quoted:mysql)
 01:01:01 p1235   MySQL query: "servers=127.0.0.1::PORT_N/test/root/pass; select * from them where id='c'" opts 'NULL'
 01:01:01 p1235  LOG: MAIN
-01:01:01 p1235    Exim configuration error in line 89 of TESTSUITE/test-config:
+01:01:01 p1235    Exim configuration error in ACL verb at line 45 of TESTSUITE/test-config:
 01:01:01 p1235    WARNING: obsolete syntax used for lookup
 01:01:01 p1235   lookup deferred: MySQL server "127.0.0.1:PORT_N/test" is tainted
 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'
diff --git a/test/stderr/2620 b/test/stderr/2620
index 390427790..b770a6267 100644
--- a/test/stderr/2620
+++ b/test/stderr/2620
@@ -135,7 +135,7 @@ dropping to exim gid; retaining priv uid
  database lookup required for servers=x:localhost; select name from them where id='ph10';
  PostgreSQL query: "servers=x:localhost; select name from them where id='ph10';" opts 'NULL'
 LOG: MAIN
-  Exim configuration error in line 78 of TESTSUITE/test-config:
+  Exim configuration error in line 11 of -be stdin:
   WARNING: obsolete syntax used for lookup
  lookup deferred: PostgreSQL server "x" not found in pgsql_servers
  search_open: pgsql "NULL"
@@ -148,7 +148,7 @@ LOG: MAIN
  database lookup required for servers=localhost::PORT_N:x; select name from them where id='ph10';
  PostgreSQL query: "servers=localhost::PORT_N:x; select name from them where id='ph10';" opts 'NULL'
 LOG: MAIN
-  Exim configuration error in line 78 of TESTSUITE/test-config:
+  Exim configuration error in line 12 of -be stdin:
   WARNING: obsolete syntax used for lookup
  PGSQL using cached connection for localhost:PORT_N/test/CALLER
  creating new cache entry
@@ -163,7 +163,7 @@ LOG: MAIN
  database lookup required for servers=localhost::PORT_N/test/CALLER/:x; select name from them where id='ph10';
  PostgreSQL query: "servers=localhost::PORT_N/test/CALLER/:x; select name from them where id='ph10';" opts 'NULL'
 LOG: MAIN
-  Exim configuration error in line 78 of TESTSUITE/test-config:
+  Exim configuration error in line 13 of -be stdin:
   WARNING: obsolete syntax used for lookup
  PGSQL using cached connection for localhost:PORT_N/test/CALLER
  creating new cache entry
@@ -178,7 +178,7 @@ LOG: MAIN
  database lookup required for servers=(TESTSUITE/pgsql/.s.PGSQL.1223)/test/CALLER/:x; select name from them where id='ph10';
  PostgreSQL query: "servers=(TESTSUITE/pgsql/.s.PGSQL.1223)/test/CALLER/:x; select name from them where id='ph10';" opts 'NULL'
 LOG: MAIN
-  Exim configuration error in line 78 of TESTSUITE/test-config:
+  Exim configuration error in line 14 of -be stdin:
   WARNING: obsolete syntax used for lookup
  PGSQL new connection: socket=TESTSUITE/pgsql/.s.PGSQL.1223 database=test user=CALLER
  creating new cache entry
@@ -349,7 +349,7 @@ check set acl_m0 = ok:   ${lookup pgsql,servers=localhost::PORT_N    {select nam
                               (tainted, quoted:pgsql)
  PostgreSQL query: "servers=localhost::PORT_N/test/CALLER/; select name from them where id = 'c'" opts 'NULL'
 LOG: MAIN
-  Exim configuration error in line 78 of TESTSUITE/test-config:
+  Exim configuration error in ACL verb at line 32 of TESTSUITE/test-config:
   WARNING: obsolete syntax used for lookup
  lookup deferred: PostgreSQL server "localhost:PORT_N/test" is tainted
 warn: condition test deferred in ACL "check_recipient"
@@ -392,7 +392,7 @@ host in "<& net-pgsql;servers=localhost::PORT_N/test/CALLER/; select * from them
                               (tainted, quoted:pgsql)
  PostgreSQL query: "servers=localhost::PORT_N/test/CALLER/; select * from them where id='c'" opts 'NULL'
 LOG: MAIN
-  Exim configuration error in line 78 of TESTSUITE/test-config:
+  Exim configuration error in ACL verb at line 44 of TESTSUITE/test-config:
   WARNING: obsolete syntax used for lookup
  lookup deferred: PostgreSQL server "localhost:PORT_N/test" is tainted
 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'
@@ -545,7 +545,7 @@ check set acl_m0 = ok:   ${lookup pgsql,servers=localhost::PORT_N    {select nam
                               (tainted, quoted:pgsql)
  PostgreSQL query: "servers=localhost::PORT_N/test/CALLER/; select name from them where id = 'c'" opts 'NULL'
 LOG: MAIN
-  Exim configuration error in line 78 of TESTSUITE/test-config:
+  Exim configuration error in ACL verb at line 32 of TESTSUITE/test-config:
   WARNING: obsolete syntax used for lookup
  lookup deferred: PostgreSQL server "localhost:PORT_N/test" is tainted
 warn: condition test deferred in ACL "check_recipient"
@@ -583,7 +583,7 @@ host in "<& net-pgsql;servers=localhost::PORT_N/test/CALLER/; select * from them
                               (tainted, quoted:pgsql)
  PostgreSQL query: "servers=localhost::PORT_N/test/CALLER/; select * from them where id='c'" opts 'NULL'
 LOG: MAIN
-  Exim configuration error in line 78 of TESTSUITE/test-config:
+  Exim configuration error in ACL verb at line 44 of TESTSUITE/test-config:
   WARNING: obsolete syntax used for lookup
  lookup deferred: PostgreSQL server "localhost:PORT_N/test" is tainted
 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'


--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-cvs.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-cvs-unsubscribe@???
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/