From: Philip Hazel Date: Wed, 31 Jan 2007 16:52:12 +0000 (+0000) Subject: Heiko Schlitterman's patch for log_selector=+pid, plus appropriate X-Git-Tag: exim-4_67~52 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f3f065bbe8b7d7fdc4d46dbfa063ae4dfb05bfd7;p=exim.git Heiko Schlitterman's patch for log_selector=+pid, plus appropriate patches for eximstats and eximon (his patch dealt with exigrep). --- diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index e36d4bb50..4cb842c6d 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.466 2007/01/31 11:30:08 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.467 2007/01/31 16:52:12 ph10 Exp $ Change log file for Exim from version 4.21 ------------------------------------------- @@ -69,6 +69,8 @@ PH/12 Added $sending_ip_address and $sending_port (mostly Magnus Holmgren's PH/13 Added ${rfc2047d: to decoded RFC 2047 strings. +PH/14 Added log_selector = +pid. + Exim version 4.66 ----------------- diff --git a/doc/doc-txt/NewStuff b/doc/doc-txt/NewStuff index cfa846c48..ccd5989cb 100644 --- a/doc/doc-txt/NewStuff +++ b/doc/doc-txt/NewStuff @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/NewStuff,v 1.133 2007/01/31 11:30:08 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/NewStuff,v 1.134 2007/01/31 16:52:12 ph10 Exp $ New Features in Exim -------------------- @@ -228,6 +228,10 @@ Version 4.67 headers_charset. Overlong RFC 2047 "words" are not recognized unless check_rfc2047_length is set false. +10. There is a new log selector called "pid", which causes the current process + id to be added to every log line, in square brackets, immediately after the + time and date. + Version 4.66 ------------ diff --git a/src/ACKNOWLEDGMENTS b/src/ACKNOWLEDGMENTS index a855be12c..1a39046c3 100644 --- a/src/ACKNOWLEDGMENTS +++ b/src/ACKNOWLEDGMENTS @@ -1,4 +1,4 @@ -$Cambridge: exim/src/ACKNOWLEDGMENTS,v 1.70 2007/01/31 11:30:08 ph10 Exp $ +$Cambridge: exim/src/ACKNOWLEDGMENTS,v 1.71 2007/01/31 16:52:12 ph10 Exp $ EXIM ACKNOWLEDGEMENTS @@ -240,6 +240,7 @@ Jonathan Sambrook Suggested patch for expanding uid and gid lists Peter Savitch Diagnosis of FPE bug when statvfs() fails on spool Harald Schueler Patch for dn_expand() failure on truncated data Heiko Schlichting Diagnosis of intermittent daemon crash bug +Heiko Schlitterman Proposed patch for +pid Stephan Schulz Patch for $host_data caching error Lai Zit Seng Patch for radiusclient 0.4.9 interface bugs Tony Sheen Log files with datestamped names and auto rollover diff --git a/src/exim_monitor/em_log.c b/src/exim_monitor/em_log.c index e87d5207e..409f2daf6 100644 --- a/src/exim_monitor/em_log.c +++ b/src/exim_monitor/em_log.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/exim_monitor/em_log.c,v 1.4 2007/01/08 10:50:17 ph10 Exp $ */ +/* $Cambridge: exim/src/exim_monitor/em_log.c,v 1.5 2007/01/31 16:52:12 ph10 Exp $ */ /************************************************* * Exim Monitor * @@ -7,7 +7,7 @@ /* Copyright (c) University of Cambridge 1995 - 2007 */ /* See the file NOTICE for conditions of use and distribution. */ -/* This module contains code for scanning the smaill log, +/* This module contains code for scanning the main log, extracting information from it, and displaying a "tail". */ #include "em_hdr.h" @@ -250,14 +250,20 @@ if (LOG != NULL) } /* Munge the log entry and display shortened form on one line. - We omit the date and show only the time. Remove any time zone offset. */ + We omit the date and show only the time. Remove any time zone offset. + Take note of the presence of [pid]. */ if (pcre_exec(yyyymmdd_regex,NULL,CS buffer,length,0,PCRE_EOPT,NULL,0) >= 0) { + int pidlength = 0; if ((buffer[20] == '+' || buffer[20] == '-') && isdigit(buffer[21]) && buffer[25] == ' ') memmove(buffer + 20, buffer + 26, Ustrlen(buffer + 26) + 1); - id = string_copyn(buffer + 20, MESSAGE_ID_LENGTH); + if (buffer[20] == '[') + { + while (Ustrchr("[]0123456789", buffer[20+pidlength++]) != NULL); + } + id = string_copyn(buffer + 20 + pidlength, MESSAGE_ID_LENGTH); show_log("%s", buffer+11); } else diff --git a/src/exim_monitor/em_version.c b/src/exim_monitor/em_version.c index 871fbf199..4a6f3ce4e 100644 --- a/src/exim_monitor/em_version.c +++ b/src/exim_monitor/em_version.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/exim_monitor/em_version.c,v 1.4 2007/01/08 10:50:17 ph10 Exp $ */ +/* $Cambridge: exim/src/exim_monitor/em_version.c,v 1.5 2007/01/31 16:52:12 ph10 Exp $ */ /************************************************* * Exim Monitor * @@ -21,7 +21,7 @@ version_init(void) int i = 0; uschar today[20]; -version_string = US"2.05"; +version_string = US"2.06"; Ustrcpy(today, __DATE__); if (today[4] == ' ') i = 1; diff --git a/src/src/exigrep.src b/src/src/exigrep.src index c6ccbfdc5..f888984b0 100644 --- a/src/src/exigrep.src +++ b/src/src/exigrep.src @@ -1,9 +1,9 @@ #! PERL_COMMAND -w -# $Cambridge: exim/src/src/exigrep.src,v 1.3 2005/08/01 13:28:30 ph10 Exp $ +# $Cambridge: exim/src/src/exigrep.src,v 1.4 2007/01/31 16:52:12 ph10 Exp $ use strict; -# Copyright (c) 2004 University of Cambridge. +# Copyright (c) 2007 University of Cambridge. # See the file NOTICE for conditions of use and distribution. # Except when they appear in comments, the following placeholders in this @@ -68,9 +68,9 @@ return unless # Handle the case when the log line belongs to a specific message. We save # lines for specific messages until the message is complete. Then either print -# discard. +# or discard. -if (my($id) = $entry =~ /^(\w{6}\-\w{6}\-\w{2})/) +if (my($id) = $entry =~ /^(?:\[\d+\]\s)?(\w{6}\-\w{6}\-\w{2})/) { $saved{$id} = '' unless defined($saved{$id}); diff --git a/src/src/eximstats.src b/src/src/eximstats.src index 539c756d7..88eb69fe8 100644 --- a/src/src/eximstats.src +++ b/src/src/eximstats.src @@ -1,5 +1,5 @@ #!PERL_COMMAND -w -# $Cambridge: exim/src/src/eximstats.src,v 1.12 2007/01/22 15:14:01 steve Exp $ +# $Cambridge: exim/src/src/eximstats.src,v 1.13 2007/01/31 16:52:12 ph10 Exp $ # Copyright (c) 2001 University of Cambridge. # See the file NOTICE for conditions of use and distribution. @@ -260,6 +260,9 @@ # 2006-11-27 V1.52 Steve Campbell # Tally any reject message containing SpamAssassin. # +# 2007-01-31 V1.53 Philip Hazel +# Allow for [pid] after date in log lines +# # # # For documentation on the logfile format, see @@ -558,7 +561,7 @@ use vars qw($WEEK $DAY $HOUR $MINUTE); @days_per_month = (0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334); $gig = 1024 * 1024 * 1024; -$VERSION = '1.52'; +$VERSION = '1.53'; # How much space do we allow for the Hosts/Domains/Emails/Edomains column headers? $COLUMN_WIDTHS = 8; @@ -1821,7 +1824,7 @@ sub generate_parser { $length = length($_); next if ($length < 38); - next unless /^(\\d{4}\\-\\d\\d-\\d\\d\\s(\\d\\d):(\\d\\d):\\d\\d( [-+]\\d\\d\\d\\d)?)/o; + next unless /^(\\d{4}\\-\\d\\d-\\d\\d\\s(\\d\\d):(\\d\\d):\\d\\d( [-+]\\d\\d\\d\\d)?)( \\[\\d+\\])?/o; ($tod,$m_hour,$m_min) = ($1,$2,$3); @@ -1834,6 +1837,12 @@ sub generate_parser { $extra = 0; } + # PH - watch for PID added after the timestamp. + if (defined($5)) { + $extra += length($5); + next if ($length < 38 + $extra); + } + $id = substr($_, 20 + $extra, 16); $flag = substr($_, 37 + $extra, 2); diff --git a/src/src/globals.c b/src/src/globals.c index 880b99985..b030c7f7b 100644 --- a/src/src/globals.c +++ b/src/src/globals.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/globals.c,v 1.66 2007/01/30 15:10:59 ph10 Exp $ */ +/* $Cambridge: exim/src/src/globals.c,v 1.67 2007/01/31 16:52:12 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -668,6 +668,8 @@ top bit). They are never used in calls to log_write(), but are tested independently. This separation became necessary when the number of log selectors was getting close to filling a 32-bit word. */ +/* Note that this list must be in alphabetical order. */ + bit_table log_options[] = { { US"acl_warn_skipped", LX_acl_warn_skipped }, { US"address_rewrite", L_address_rewrite }, @@ -686,6 +688,7 @@ bit_table log_options[] = { { US"incoming_port", LX_incoming_port }, { US"lost_incoming_connection", L_lost_incoming_connection }, { US"outgoing_port", LX_outgoing_port }, + { US"pid", LX_pid }, { US"queue_run", L_queue_run }, { US"queue_time", LX_queue_time }, { US"queue_time_overall", LX_queue_time_overall }, diff --git a/src/src/log.c b/src/src/log.c index 2757ee0b4..5cc309287 100644 --- a/src/src/log.c +++ b/src/src/log.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/log.c,v 1.11 2007/01/08 10:50:18 ph10 Exp $ */ +/* $Cambridge: exim/src/src/log.c,v 1.12 2007/01/31 16:52:12 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -732,11 +732,21 @@ if (!write_rejectlog) flags &= ~LOG_REJECT; id except for the process log and when called by a utility. */ ptr = log_buffer; +sprintf(CS ptr, "%s ", tod_stamp(tod_log)); +while(*ptr) ptr++; + +if ((log_extra_selector & LX_pid) != 0) + { + sprintf(CS ptr, "[%d] ", (int)getpid()); + while (*ptr) ptr++; + } + if (really_exim && (flags & LOG_PROCESS) == 0 && message_id[0] != 0) - sprintf(CS ptr, "%s %s ", tod_stamp(tod_log), message_id); -else sprintf(CS ptr, "%s ", tod_stamp(tod_log)); + { + sprintf(CS ptr, "%s ", message_id); + while(*ptr) ptr++; + } -while(*ptr) ptr++; if ((flags & LOG_CONFIG) != 0) ptr = log_config_info(ptr, flags); va_start(ap, format); diff --git a/src/src/macros.h b/src/src/macros.h index 7b317e42d..f73ce63ac 100644 --- a/src/src/macros.h +++ b/src/src/macros.h @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/macros.h,v 1.30 2007/01/15 15:59:22 ph10 Exp $ */ +/* $Cambridge: exim/src/src/macros.h,v 1.31 2007/01/31 16:52:12 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -378,21 +378,22 @@ set all the bits in a multi-word selector. */ #define LX_incoming_interface 0x80000020 #define LX_incoming_port 0x80000040 #define LX_outgoing_port 0x80000080 -#define LX_queue_time 0x80000100 -#define LX_queue_time_overall 0x80000200 -#define LX_received_sender 0x80000400 -#define LX_received_recipients 0x80000800 -#define LX_rejected_header 0x80001000 -#define LX_return_path_on_delivery 0x80002000 -#define LX_sender_on_delivery 0x80004000 -#define LX_sender_verify_fail 0x80008000 -#define LX_smtp_confirmation 0x80010000 -#define LX_smtp_no_mail 0x80020000 -#define LX_subject 0x80040000 -#define LX_tls_certificate_verified 0x80080000 -#define LX_tls_cipher 0x80100000 -#define LX_tls_peerdn 0x80200000 -#define LX_unknown_in_list 0x80400000 +#define LX_pid 0x80000100 +#define LX_queue_time 0x80000200 +#define LX_queue_time_overall 0x80000400 +#define LX_received_sender 0x80000800 +#define LX_received_recipients 0x80001000 +#define LX_rejected_header 0x80002000 +#define LX_return_path_on_delivery 0x80004000 +#define LX_sender_on_delivery 0x80008000 +#define LX_sender_verify_fail 0x80010000 +#define LX_smtp_confirmation 0x80020000 +#define LX_smtp_no_mail 0x80040000 +#define LX_subject 0x80080000 +#define LX_tls_certificate_verified 0x80100000 +#define LX_tls_cipher 0x80200000 +#define LX_tls_peerdn 0x80400000 +#define LX_unknown_in_list 0x80800000 #define L_default (L_connection_reject | \ L_delay_delivery | \ diff --git a/test/README b/test/README index e1f8048f7..5c060974c 100644 --- a/test/README +++ b/test/README @@ -1,4 +1,4 @@ -$Cambridge: exim/test/README,v 1.6 2007/01/23 11:01:10 ph10 Exp $ +$Cambridge: exim/test/README,v 1.7 2007/01/31 16:52:12 ph10 Exp $ EXPORTABLE EXIM TEST SUITE -------------------------- @@ -6,7 +6,7 @@ EXPORTABLE EXIM TEST SUITE This document last updated for: Test Suite Version: 4.67 -Date: 23 January 2007 +Date: 31 January 2007 BACKGROUND @@ -637,6 +637,12 @@ The file remains locked with the following command (normally exim) is obeyed. This command runs the exinext utility with the given argument data. + exigrep + +This command runs the exigrep utility with the given data (the search pattern) +on the current mainlog file. + + gnutls This command is present at the start of all but one of the tests that use diff --git a/test/confs/0551 b/test/confs/0551 new file mode 100644 index 000000000..cecaae490 --- /dev/null +++ b/test/confs/0551 @@ -0,0 +1,36 @@ +# Exim test configuration 0551 + +LS=+pid + +exim_path = EXIM_PATH +host_lookup_order = bydns +primary_hostname = myhost.test.ex +rfc1413_query_timeout = 0s +spool_directory = DIR/spool +log_file_path = DIR/spool/log/%slog +gecos_pattern = "" +gecos_name = CALLER_NAME + +# ----- Main settings ----- + +log_selector = LS + +# ----- Routers ----- + +begin routers + +r1: + driver = accept + transport = t1 + + +# ----- Transports ----- + +begin transports + +t1: + driver = appendfile + user = CALLER + file = DIR/test-mail/$local_part + +# End diff --git a/test/log/0551 b/test/log/0551 new file mode 100644 index 000000000..831e11a89 --- /dev/null +++ b/test/log/0551 @@ -0,0 +1,11 @@ +1999-03-02 09:44:33 [1234] 10HmaX-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local S=sss +1999-03-02 09:44:33 [1235] 10HmaX-0005vi-00 => userx R=r1 T=t1 +1999-03-02 09:44:33 [1235] 10HmaX-0005vi-00 => usery R=r1 T=t1 +1999-03-02 09:44:33 [1235] 10HmaX-0005vi-00 Completed +1999-03-02 09:44:33 [1236] 10HmaY-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local S=sss +1999-03-02 09:44:33 [1237] 10HmaY-0005vi-00 => userx R=r1 T=t1 +1999-03-02 09:44:33 [1237] 10HmaY-0005vi-00 => userz R=r1 T=t1 +1999-03-02 09:44:33 [1237] 10HmaY-0005vi-00 Completed +1999-03-02 09:44:33 10HmaZ-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local S=sss +1999-03-02 09:44:33 10HmaZ-0005vi-00 => userx R=r1 T=t1 +1999-03-02 09:44:33 10HmaZ-0005vi-00 Completed diff --git a/test/mail/0551.userx b/test/mail/0551.userx new file mode 100644 index 000000000..01ca394c0 --- /dev/null +++ b/test/mail/0551.userx @@ -0,0 +1,31 @@ +From CALLER@myhost.test.ex Tue Mar 02 09:44:33 1999 +Received: from CALLER by myhost.test.ex with local (Exim x.yz) + (envelope-from ) + id 10HmaX-0005vi-00; Tue, 2 Mar 1999 09:44:33 +0000 +Message-Id: +From: CALLER_NAME +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +Message 1 + +From CALLER@myhost.test.ex Tue Mar 02 09:44:33 1999 +Received: from CALLER by myhost.test.ex with local (Exim x.yz) + (envelope-from ) + id 10HmaY-0005vi-00; Tue, 2 Mar 1999 09:44:33 +0000 +Message-Id: +From: CALLER_NAME +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +Message 2 + +From CALLER@myhost.test.ex Tue Mar 02 09:44:33 1999 +Received: from CALLER by myhost.test.ex with local (Exim x.yz) + (envelope-from ) + id 10HmaZ-0005vi-00 + for userx@test.ex; Tue, 2 Mar 1999 09:44:33 +0000 +Message-Id: +From: CALLER_NAME +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +Message 3 + diff --git a/test/mail/0551.usery b/test/mail/0551.usery new file mode 100644 index 000000000..e4d855b81 --- /dev/null +++ b/test/mail/0551.usery @@ -0,0 +1,10 @@ +From CALLER@myhost.test.ex Tue Mar 02 09:44:33 1999 +Received: from CALLER by myhost.test.ex with local (Exim x.yz) + (envelope-from ) + id 10HmaX-0005vi-00; Tue, 2 Mar 1999 09:44:33 +0000 +Message-Id: +From: CALLER_NAME +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +Message 1 + diff --git a/test/mail/0551.userz b/test/mail/0551.userz new file mode 100644 index 000000000..29b2f0da7 --- /dev/null +++ b/test/mail/0551.userz @@ -0,0 +1,10 @@ +From CALLER@myhost.test.ex Tue Mar 02 09:44:33 1999 +Received: from CALLER by myhost.test.ex with local (Exim x.yz) + (envelope-from ) + id 10HmaY-0005vi-00; Tue, 2 Mar 1999 09:44:33 +0000 +Message-Id: +From: CALLER_NAME +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +Message 2 + diff --git a/test/runtest b/test/runtest index 0d5b10504..328b89958 100755 --- a/test/runtest +++ b/test/runtest @@ -1,6 +1,6 @@ #! /usr/bin/perl -w -# $Cambridge: exim/test/runtest,v 1.22 2007/01/23 14:57:51 ph10 Exp $ +# $Cambridge: exim/test/runtest,v 1.23 2007/01/31 16:52:12 ph10 Exp $ ############################################################################### # This is the controlling script for the "new" test suite for Exim. It should # @@ -432,6 +432,10 @@ while() # Time on queue tolerance s/QT=1s/QT=0s/; + # Eximstats heading + s/Exim\sstatistics\sfrom\s\d{4}-\d\d-\d\d\s\d\d:\d\d:\d\d\sto\s + \d{4}-\d\d-\d\d\s\d\d:\d\d:\d\d/Exim statistics from