[svn:qpsmtpd] rev 471 - in trunk: . lib/Qpsmtpd

[email protected] 6 Jul 2005 20:30:14 -0000
Newsgroups perl.cvs.qpsmtpd
Message-ID <[email protected]>
Author: msergeant
Date: Wed Jul  6 13:30:14 2005
New Revision: 471

Modified:
   trunk/README.plugins
   trunk/lib/Qpsmtpd/SMTP.pm
Log:
Fix plugin docs to reflect reality
Re-order plugin docs to appear in the order things generally get called
Fix SMTP.pm to reflect what's documented in README.plugins :-)


Modified: trunk/README.plugins
==============================================================================
--- trunk/README.plugins	(original)
+++ trunk/README.plugins	Wed Jul  6 13:30:14 2005
@@ -32,10 +32,15 @@ Action denied
 
 Action denied; return a temporary rejection code (say 450 instead of 550).
 
-=item DENYHARD
+=item DENY_DISCONNECT
 
 Action denied; return a permanent rejection code and disconnect the client.
-Use this for "rude" clients.
+Use this for "rude" clients. Note that you're not supposed to do this
+according to the SMTP specs, but bad clients don't listen sometimes.
+
+=item DENYSOFT_DISCONNECT
+
+Action denied; return a temporary rejection code and disconnect the client.
 
 =item DECLINED
 
@@ -68,6 +73,43 @@ completely finished (e.g. after the chil
 The hook doesn't have a predefined additional input value, but one can be
 passed as a hash of name/value pairs.
 
+
+=head2 connect
+
+Allowed return codes:
+
+  OK       - Stop processing plugins, give the default response
+  DECLINED - Process the next plugin
+  DONE     - Stop processing plugins and don't give the default response
+  DENY     - Return hard failure code and disconnect
+  DENYSOFT - Return soft failure code and disconnect
+
+Note: DENY_DISCONNECT and DENYSOFT_DISCONNECT are not supported here due to
+them having no meaning beyond what DENY and DENYSOFT already do.
+
+
+=head2 helo
+
+Called on "helo" from the client.
+
+  DENY     - Return a 550 code
+  DENYSOFT - Return a 450 code
+  DENY_DISCONNECT & DENYSOFT_DISCONNECT - as above but with disconnect
+  DONE     - Qpsmtpd won't do anything; the plugin sent the message
+  DECLINED - Qpsmtpd will send the standard HELO message
+
+
+=head2 ehlo
+
+Called on "ehlo" from the client.
+
+  DENY     - Return a 550 code
+  DENYSOFT - Return a 450 code
+  DENY_DISCONNECT & DENYSOFT_DISCONNECT - as above but with disconnect
+  DONE     - Qpsmtpd won't do anything; the plugin sent the message
+  DECLINED - Qpsmtpd will send the standard HELO message
+
+
 =head2 mail
 
 Called right after the envelope sender address is passed.  The plugin
@@ -76,11 +118,11 @@ recipient.
 
 Allowed return codes
 
-  OK       - sender allowed
-  DENY     - Return a hard failure code
-  DENYSOFT - Return a soft failure code
-  DENYHARD - Return a hard failure code and disconnect
-  DONE     - skip further processing
+  OK              - sender allowed
+  DENY            - Return a hard failure code
+  DENYSOFT        - Return a soft failure code
+  DENY_DISCONNECT & DENYSOFT_DISCONNECT - as above but with disconnect
+  DONE            - skip further processing
 
 
 =head2 rcpt
@@ -90,11 +132,12 @@ error code.
 
 Allowed return codes
 
-  OK       - recipient allowed
-  DENY     - Return a hard failure code
-  DENYSOFT - Return a soft failure code
-  DENYHARD - Return a hard failure code and disconnect
-  DONE     - skip further processing
+  OK              - recipient allowed
+  DENY            - Return a hard failure code
+  DENYSOFT        - Return a soft failure code
+  DENY_DISCONNECT & DENYSOFT_DISCONNECT - as above but with disconnect
+  DONE            - skip further processing
+
 
 =head2 data
 
@@ -102,43 +145,35 @@ Hook for the "data" command.  Defaults t
 
   DENY     - Return a hard failure code
   DENYSOFT - Return a soft failure code
-  DENYHARD - Return a hard failure code and disconnect
+  DENY_DISCONNECT & DENYSOFT_DISCONNECT - as above but with disconnect
   DONE     - Plugin took care of receiving data and calling the queue (not
              recommended)
 
+
 =head2 data_post
 
 Hook after receiving all data; just before the message is queued.
 
   DENY     - Return a hard failure code
   DENYSOFT - Return a soft failure code
-  DENYHARD - Return a hard failure code and disconnect
+  DENY_DISCONNECT & DENYSOFT_DISCONNECT - as above but with disconnect
   DONE     - skip further processing (message will not be queued)
 
 All other codes and the message will be queued normally
 
+
 =head2 queue
 
-Called on completion of the DATA command.
+Called on completion of the DATA command, after the data_post hook.
 
    DONE     - skip further processing (plugin gave response code)
    OK       - Return success message 
    DENY     - Return hard failure code
    DENYSOFT - Return soft failure code
-  DENYHARD - Return a hard failure code and disconnect
 
 Any other code will return a soft failure code.
 
 
-=head2 connect
-
-Allowed return codes:
-
-  OK       - Stop processing plugins, give the default response
-  DECLINED - Process the next plugin
-  DONE     - Stop processing plugins and don't give the default response
-
-
 =head2 quit
 
 Called on the "quit" command.
@@ -149,16 +184,6 @@ Allowed return codes:
 
 Works like the "connect" hook.
 
-=head2 helo
-
-Called on "helo" from the client.
-
-  DENY - Return a 550 code
-  DENYSOFT - Return a 450 code
-  DENYHARD - Return a hard failure code and disconnect
-  DONE - Qpsmtpd won't do anything; the plugin sent the message
-  DECLINED - Qpsmtpd will send the standard HELO message
-
 
 =head2 unrecognized_command
 

Modified: trunk/lib/Qpsmtpd/SMTP.pm
==============================================================================
--- trunk/lib/Qpsmtpd/SMTP.pm	(original)
+++ trunk/lib/Qpsmtpd/SMTP.pm	Wed Jul  6 13:30:14 2005
@@ -142,6 +142,12 @@ sub helo {
     $self->respond(550, $msg);
   } elsif ($rc == DENYSOFT) {
     $self->respond(450, $msg);
+  } elsif ($rc == DENY_DISCONNECT) {
+      $self->respond(550, $msg);
+      $self->disconnect;
+  } elsif ($rc == DENYSOFT_DISCONNECT) {
+      $self->respond(450, $msg);
+      $self->disconnect;
   } else {
     $conn->hello("helo");
     $conn->hello_host($hello_host);
@@ -164,6 +170,12 @@ sub ehlo {
     $self->respond(550, $msg);
   } elsif ($rc == DENYSOFT) {
     $self->respond(450, $msg);
+  } elsif ($rc == DENY_DISCONNECT) {
+      $self->respond(550, $msg);
+      $self->disconnect;
+  } elsif ($rc == DENYSOFT_DISCONNECT) {
+      $self->respond(450, $msg);
+      $self->disconnect;
   } else {
     $conn->hello("ehlo");
     $conn->hello_host($hello_host);