diff options
author | Tony Finch <dot@dotat.at> | 2015-08-13 15:16:51 +0100 |
---|---|---|
committer | Jeremy Harris <jgh146exb@wizmail.org> | 2015-08-14 16:10:56 +0100 |
commit | ac881e2749754fbe167b5f38784dd85b088571cf (patch) | |
tree | d26128087f98508693b35c59199c84b07fd01332 /src | |
parent | 6c6d6e483411af2c087ff258f4041d38eb65e775 (diff) |
Improve the consistency of logging incoming and outgoing interfaces.
The I= interface field on outgoing lines is now after the H= remote
host field, same as incoming lines. There is a separate outgoing_interface
log selector which allows you to disable the outgoing I= field.
(slight massaging by JH)
Diffstat (limited to 'src')
-rw-r--r-- | src/src/deliver.c | 86 | ||||
-rw-r--r-- | src/src/globals.c | 2 | ||||
-rw-r--r-- | src/src/log.c | 4 | ||||
-rw-r--r-- | src/src/macros.h | 3 |
4 files changed, 67 insertions, 28 deletions
diff --git a/src/src/deliver.c b/src/src/deliver.c index c796de040..0e7cea31d 100644 --- a/src/src/deliver.c +++ b/src/src/deliver.c @@ -676,39 +676,78 @@ while (addr->parent != NULL) +/************************************************* +* Delivery logging support functions * +*************************************************/ + +/* The LOGGING() checks in d_log_interface() are complicated for backwards +compatibility. When outgoing interface logging was originally added, it was +conditional on just incoming_interface (which is off by default). The +outgoing_interface option is on by default to preserve this behaviour, but +you can enable incoming_interface and disable outgoing_interface to get I= +fields on incoming lines only. + +Arguments: + s The log line buffer + sizep Pointer to the buffer size + ptrp Pointer to current index into buffer + addr The address to be logged + +Returns: New value for s +*/ static uschar * -d_hostlog(uschar * s, int * sizep, int * ptrp, address_item * addr) +d_log_interface(uschar *s, int *sizep, int *ptrp) { - s = string_append(s, sizep, ptrp, 5, US" H=", addr->host_used->name, - US" [", addr->host_used->address, US"]"); +if (LOGGING(incoming_interface) && LOGGING(outgoing_interface) + && sending_ip_address != NULL) + { + s = string_append(s, sizep, ptrp, 2, US" I=[", sending_ip_address); if (LOGGING(outgoing_port)) - s = string_append(s, sizep, ptrp, 2, US":", string_sprintf("%d", - addr->host_used->port)); - return s; + s = string_append(s, sizep, ptrp, 2, US"]:", + string_sprintf("%d", sending_port)); + else + s = string_cat(s, sizep, ptrp, "]", 1); + } +return s; } + + +static uschar * +d_hostlog(uschar *s, int *sizep, int *ptrp, address_item *addr) +{ +s = string_append(s, sizep, ptrp, 5, US" H=", addr->host_used->name, + US" [", addr->host_used->address, US"]"); +if (LOGGING(outgoing_port)) + s = string_append(s, sizep, ptrp, 2, US":", string_sprintf("%d", + addr->host_used->port)); +return d_log_interface(s, sizep, ptrp); +} + + + #ifdef SUPPORT_TLS static uschar * d_tlslog(uschar * s, int * sizep, int * ptrp, address_item * addr) { - if (LOGGING(tls_cipher) && addr->cipher != NULL) - s = string_append(s, sizep, ptrp, 2, US" X=", addr->cipher); - if (LOGGING(tls_certificate_verified) && addr->cipher != NULL) - s = string_append(s, sizep, ptrp, 2, US" CV=", - testflag(addr, af_cert_verified) - ? +if (LOGGING(tls_cipher) && addr->cipher != NULL) + s = string_append(s, sizep, ptrp, 2, US" X=", addr->cipher); +if (LOGGING(tls_certificate_verified) && addr->cipher != NULL) + s = string_append(s, sizep, ptrp, 2, US" CV=", + testflag(addr, af_cert_verified) + ? #ifdef EXPERIMENTAL_DANE - testflag(addr, af_dane_verified) - ? "dane" - : + testflag(addr, af_dane_verified) + ? "dane" + : #endif - "yes" - : "no"); - if (LOGGING(tls_peerdn) && addr->peerdn != NULL) - s = string_append(s, sizep, ptrp, 3, US" DN=\"", - string_printing(addr->peerdn), US"\""); - return s; + "yes" + : "no"); +if (LOGGING(tls_peerdn) && addr->peerdn != NULL) + s = string_append(s, sizep, ptrp, 3, US" DN=\"", + string_printing(addr->peerdn), US"\""); +return s; } #endif @@ -816,10 +855,6 @@ else s = string_append(s, &size, &ptr, 2, US"> ", log_address); } -if (LOGGING(incoming_interface) && sending_ip_address) - s = string_append(s, &size, &ptr, 3, US" I=[", sending_ip_address, US"]"); - /* for the port: string_sprintf("%d", sending_port) */ - if (LOGGING(sender_on_delivery) || msg) s = string_append(s, &size, &ptr, 3, US" F=<", #ifdef EXPERIMENTAL_INTERNATIONAL @@ -862,6 +897,7 @@ if (addr->transport->info->local) { if (addr->host_list) s = string_append(s, &size, &ptr, 2, US" H=", addr->host_list->name); + s = d_log_interface(s, &size, &ptr); if (addr->shadow_message != NULL) s = string_cat(s, &size, &ptr, addr->shadow_message, Ustrlen(addr->shadow_message)); diff --git a/src/src/globals.c b/src/src/globals.c index 1344b5aed..4188b4d84 100644 --- a/src/src/globals.c +++ b/src/src/globals.c @@ -827,6 +827,7 @@ int log_default[] = { /* for initializing log_selector */ Li_etrn, Li_host_lookup_failed, Li_lost_incoming_connection, + Li_outgoing_interface, /* see d_log_interface in deliver.c */ Li_queue_run, Li_rejected_header, Li_retry_defer, @@ -863,6 +864,7 @@ bit_table log_options[] = { /* must be in alphabetical order */ BIT_TABLE(L, incoming_interface), BIT_TABLE(L, incoming_port), BIT_TABLE(L, lost_incoming_connection), + BIT_TABLE(L, outgoing_interface), BIT_TABLE(L, outgoing_port), BIT_TABLE(L, pid), #ifdef EXPERIMENTAL_PROXY diff --git a/src/src/log.c b/src/src/log.c index b2d1fcfc1..558c000d7 100644 --- a/src/src/log.c +++ b/src/src/log.c @@ -753,8 +753,8 @@ DEBUG(D_any|D_v) for (i = 0; i < log_options_count; i++) { - unsigned int bit = log_options[i].bit; - if (bit < BITWORDSIZE && selector == BIT(bit)) + unsigned int bitnum = log_options[i].bit; + if (bitnum < BITWORDSIZE && selector == BIT(bitnum)) { *ptr++ = ' '; Ustrcpy(ptr, log_options[i].name); diff --git a/src/src/macros.h b/src/src/macros.h index d63025ec2..0ce24f8cb 100644 --- a/src/src/macros.h +++ b/src/src/macros.h @@ -474,8 +474,9 @@ enum { Li_8bitmime, Li_smtp_mailauth, Li_proxy, + Li_outgoing_interface, - log_selector_size = BITWORD(Li_proxy) + 1 + log_selector_size = BITWORD(Li_outgoing_interface) + 1 }; #define LOGGING(opt) BIT_TEST(log_selector, log_selector_size, Li_##opt) |