.vindex "&$config_file$&"
The name of the main configuration file Exim is using.
+.vitem &$connection_id$&
+.vindex "&$connection_id$&"
+.cindex connection "identifier logging"
+An identifier for the accepted connection, for use in custom logging.
+
.vitem &$dkim_verify_status$&
Results of DKIM verification.
For details see section &<<SECDKIMVFY>>&.
between the caller and Exim.
.next
.cindex log "connection identifier"
-.cindec connection "indentifier logging"
+.cindex connection "identifier logging"
&%connection_id%&: An identifier for the accepted connection is added to
connection start and end lines and to message accept lines.
The identifier is tagged by Ci=.
------------
1. A sieve_inbox option for redirect routers
+ 2. A "connection_id" variable
+
Version 4.98
------------
1. The dkim_status ACL condition may now be used in data ACLs
#endif
smtp_accept_count++; /* So that it includes this process */
- connection_id = getpid();
+ set_connection_id();
/* Log the connection if requested.
In order to minimize the cost (because this is going to happen for every
save_log_selector &= ~L_smtp_connection;
else if (LOGGING(connection_id))
log_write(L_smtp_connection, LOG_MAIN, "SMTP connection from %Y "
- "Ci=%lu (TCP/IP connection count = %d)",
+ "Ci=%s (TCP/IP connection count = %d)",
whofrom, connection_id, smtp_accept_count);
else
log_write(L_smtp_connection, LOG_MAIN, "SMTP connection from %Y "
"**** This is not for real!\n\n",
sender_host_address);
- connection_id = getpid();
+ set_connection_id();
memset(sender_host_cache, 0, sizeof(sender_host_cache));
if (verify_check_host(&hosts_connection_nolog) == OK)
{
(usually "connection refused: <reason>") and writing another one is
unnecessary clutter. */
-connection_id = getpid();
+set_connection_id();
if (smtp_input)
{
smtp_in = stdin;
{ "compile_number", vtype_stringptr, &version_cnumber },
{ "config_dir", vtype_stringptr, &config_main_directory },
{ "config_file", vtype_stringptr, &config_main_filename },
+ { "connection_id", vtype_stringptr, &connection_id },
{ "csa_status", vtype_stringptr, &csa_status },
#ifdef EXPERIMENTAL_DCC
{ "dcc_header", vtype_stringptr, &dcc_header },
/******************************************************************************/
# if !defined(COMPILE_UTILITY)
+
+/* We use the PID of the head process for a connection-id. Note that
+this is only for tracking a received connection and what it directly
+causes; there is no inttent to describe transport-initiated TCP connections.
+The value is intented to be a cookie usable for logging, and we might change
+the generator for it at any time. */
+
+static inline void
+set_connection_id(void)
+{
+connection_id = string_sprintf("%lu", (u_long)getpid());
+}
+
+
/* Process manipulation */
static inline pid_t
uid_t config_uid = 0;
#endif
-uint64_t connection_id = 0L;
+const uschar *connection_id = NULL;
int connection_max_messages= -1;
unsigned continue_flags = 0;
#ifndef DISABLE_ESMTP_LIMITS
extern int clmacro_count; /* Number of command line macros */
extern uschar *clmacros[]; /* Copy of them, for re-exec */
extern BOOL commandline_checks_require_admin; /* belt and braces for insecure setups */
-extern uint64_t connection_id; /* connection number */
+extern const uschar *connection_id; /* connection cookie for log */
extern int connection_max_messages;/* Max down one SMTP connection */
extern FILE *config_file; /* Configuration file */
extern const uschar *config_filename; /* Configuration file name */
g = string_fmt_append(g, " U=%s", sender_ident);
}
if (LOGGING(connection_id))
- g = string_fmt_append(g, " Ci=%lu", connection_id);
+ g = string_fmt_append(g, " Ci=%s", connection_id);
gstring_release_unused(g);
return string_from_gstring(g);
}
if (sender_ident)
g = string_append(g, 2, US" U=", sender_ident);
if (LOGGING(connection_id))
- g = string_fmt_append(g, " Ci=%lu", connection_id);
+ g = string_fmt_append(g, " Ci=%s", connection_id);
if (received_protocol)
g = string_append(g, 2, US" P=", received_protocol);
if (LOGGING(pipelining) && f.smtp_in_pipelining_advertised)
gstring * g = string_catn(NULL, US"SMTP connection", 15);
if (LOGGING(connection_id))
- g = string_fmt_append(g, " Ci=%lu", connection_id);
+ g = string_fmt_append(g, " Ci=%s", connection_id);
g = string_catn(g, US" from ", 6);
if (host_checking)
begin acl
connect0:
- accept
+ accept logwrite = connection_id: $connection_id
connect1:
deny hosts = <\n partial-lsearch;DIR/aux-fixed/0002.lsearch \n 1.2.3.4
# Lines with a leading pid. Only handle >= 4-digit PIDs to avoid converting SMTP respose codes
s/^\s*(\d{4,})\s(?!(?:previous message|in\s|bytes remain in|SMTP accept process running))/new_value($1, "p%s", \$next_pid) . ' '/e;
+ # Connection IDs
+ s/connection_id: \K(\d+)$/new_value($1, "conn%s", \$next_conn)/e;
+
# Debugging lines for Exim terminations and process-generation
next if /(?:postfork: | fork(?:ing|ed) for )/;
$next_msgid = "aX";
$next_pid = 1234;
$next_port = 1111;
+ $next_conn = 1111;
$message_skip = 0;
$msglog_skip = 0;
$munge_skip = 0;
****
exim -d -bh V4NET.0.0.2
****
-# Test $reply_address
+# Test $reply_address, $connection_id
exim -bh V4NET.0.0.0
helo test
mail from:<>
>>> host in helo_accept_junk_hosts? no (option unset)
>>> using ACL "connect0"
>>> processing "accept" (TESTSUITE/test-config 42)
+>>> check logwrite = connection_id: $connection_id
+>>> = connection_id: conn1111
+LOG: connection_id: conn1111
>>> accept: condition test succeeded in ACL "connect0"
>>> end of ACL "connect0": ACCEPT
>>> test in helo_lookup_domains?
>>> host in helo_accept_junk_hosts? no (option unset)
>>> using ACL "connect0"
>>> processing "accept" (TESTSUITE/test-config 42)
+>>> check logwrite = connection_id: $connection_id
+>>> = connection_id: conn1112
+LOG: connection_id: conn1112
>>> accept: condition test succeeded in ACL "connect0"
>>> end of ACL "connect0": ACCEPT
>>> test in helo_lookup_domains?
>>> host in helo_accept_junk_hosts? no (option unset)
>>> using ACL "connect0"
>>> processing "accept" (TESTSUITE/test-config 42)
+>>> check logwrite = connection_id: $connection_id
+>>> = connection_id: conn1113
+LOG: connection_id: conn1113
>>> accept: condition test succeeded in ACL "connect0"
>>> end of ACL "connect0": ACCEPT
>>> test in helo_lookup_domains?