Re: Transaction IDs (was: Re: helper scripts)

2007-09-02 Thread Peter J. Holzer
On 2007-08-23 18:50:33 +0200, Hanno Hecker wrote:
 But it would be easy to add / generate a transaction id after every
 reset_transaction() call. This could be logged instead of (or as
 addition to) the PID.
[...]

 Index: lib/Qpsmtpd/SMTP.pm
 ===
 --- lib/Qpsmtpd/SMTP.pm   (revision 774)
 +++ lib/Qpsmtpd/SMTP.pm   (working copy)
 @@ -388,8 +388,8 @@
  }
  else { # includes OK
$self-log(LOGINFO, getting mail from .$from-format);
 -  $self-respond(250, $from-format . , sender OK - how exciting to get 
 mail from you!);
$self-transaction-sender($from);
 +  $self-respond(250, $from-format . , sender OK - your transaction id 
 is .$self-transaction-id);
  }
  }
  

I like that, although I suspect that most clients will just discard it.

hp


-- 
   _  | Peter J. Holzer| I know I'd be respectful of a pirate 
|_|_) | Sysadmin WSR   | with an emu on his shoulder.
| |   | [EMAIL PROTECTED] |
__/   | http://www.hjp.at/ |-- Sam in Freefall


signature.asc
Description: Digital signature


Re: Transaction IDs (was: Re: helper scripts)

2007-09-02 Thread Hanno Hecker
On Sun, 2 Sep 2007 18:48:00 +0200
Peter J. Holzer [EMAIL PROTECTED] wrote:


  +  $self-respond(250, $from-format . , sender OK - your transaction 
  id is .$self-transaction-id);
 I like that, although I suspect that most clients will just discard it.
But some clients show the transaction log in case of errors. This would
help to identify the transaction easier.

Hanno


Transaction IDs (was: Re: helper scripts)

2007-08-23 Thread Hanno Hecker
On Wed, 22 Aug 2007 12:48:09 -0700
JT Moree [EMAIL PROTECTED] wrote:
 Sydney Bogaert wrote:
  You assume here that the process numbers are different for each message.
  While it will work for forkserver and tcpserver, that is not the case
  with prefork or Apache (also preforking).
 
 Is there a message ID that is unique to each message?
Not until the sending client has submitted a 'Message-ID' header ;-)

But it would be easy to add / generate a transaction id after every
reset_transaction() call. This could be logged instead of (or as
addition to) the PID.
...something like the attached diff would do. If it's OK, I'll submit
to svn trunk.
Hmm, the spool filename should also include this transaction id, then
it's easier to figure which session was incomplete or is currently
running.

Hanno
Index: lib/Qpsmtpd/Transaction.pm
===
--- lib/Qpsmtpd/Transaction.pm	(revision 774)
+++ lib/Qpsmtpd/Transaction.pm	(working copy)
@@ -207,6 +207,14 @@
   return shift-{_body_file};
 }
 
+sub id {
+  my $self = shift;
+  unless ($self-{_transaction_id}) {
+$self-{_transaction_id} = sprintf(%08X, rand(2**32 - 1));
+  }
+  return $self-{_transaction_id};
+}
+
 sub DESTROY {
   my $self = shift;
   # would we save some disk flushing if we unlinked the file before
Index: plugins/logging/warn
===
--- plugins/logging/warn	(revision 774)
+++ plugins/logging/warn	(working copy)
@@ -31,7 +31,8 @@
   return DECLINED if defined $plugin and $plugin eq $self-plugin_name; 
 
   warn 
-join( , $$ .
+join( , $$ . 
+ ($transaction-sender ? $transaction-id : ),
  (defined $plugin ?  $plugin plugin: :
   defined $hook   ?  running plugin ($hook):  : ),
  @log), \n
Index: plugins/logging/file
===
--- plugins/logging/file	(revision 774)
+++ plugins/logging/file	(working copy)
@@ -274,7 +274,9 @@
 
 my $f = $self-{_f};
 print $f strftime($self-{_tsformat}, localtime), ' ',
- hostname(), '[', $$, ']: ', @log, \n;
+ hostname(), '[', $$, ']: ',
+ ($txn-sender ? $txn-id : ''),' ',
+ @log, \n;
 return DECLINED;
 }
 
Index: lib/Qpsmtpd/SMTP.pm
===
--- lib/Qpsmtpd/SMTP.pm	(revision 774)
+++ lib/Qpsmtpd/SMTP.pm	(working copy)
@@ -388,8 +388,8 @@
 }
 else { # includes OK
   $self-log(LOGINFO, getting mail from .$from-format);
-  $self-respond(250, $from-format . , sender OK - how exciting to get mail from you!);
   $self-transaction-sender($from);
+  $self-respond(250, $from-format . , sender OK - your transaction id is .$self-transaction-id);
 }
 }
 


RE: helper scripts

2007-08-22 Thread Sydney Bogaert
 
 I wrote some small helper scripts for parsing logs.  Would they be
 useful enough to include in qpsmtpd?
 
 
 --
 JT Moree

You assume here that the process numbers are different for each message.
While it will work for forkserver and tcpserver, that is not the case
with prefork or Apache (also preforking).

Sydney.


Re: helper scripts

2007-08-22 Thread JT Moree
Sydney Bogaert wrote:
 I wrote some small helper scripts for parsing logs.  Would they be
 useful enough to include in qpsmtpd?

 You assume here that the process numbers are different for each message.
 While it will work for forkserver and tcpserver, that is not the case
 with prefork or Apache (also preforking).

Is there a message ID that is unique to each message?

-- 
JT Moree


RE: helper scripts

2007-08-22 Thread Guy Hulbert
On Wed, 2007-08-22 at 13:06 -0700, James W. Abendschan wrote:
 On Wed, 22 Aug 2007, Sydney Bogaert wrote:
 
  You assume here that the process numbers are different for each message.
  While it will work for forkserver and tcpserver, that is not the case
  with prefork or Apache (also preforking).
 
 related: is there any work being done on standardizing qpsmtpd log messages
  levels?

As far as standardization, I think this is a non-starter.  There seem to
be arbitrary ways to do logging via plugins and I'm pretty sure there
are at least 3 different formats being used.

As to levels, there are constants defined in Qpsmtpd::Constants (iirc),
which match the usual syslog levels.

If I am wrong about standardization, I would love to hear it ;-).

 
 James
 
 

-- 
--gh