Hi all

I have gone through the qpsmtpd prefork code and fixed some problems,
one was with the issue where qpsmtpd responded that the sender already
said hallo. This was solved by flushing stdin. The flush is needed but
my current solution (located in qpsmtpd-prefork) is somewhat ugly so
if anyone knows a better way please speak up.

This patch also contains Leonardo's Prefork.pm updates.


--
Lars Roland
Index: qpsmtpd-prefork
===================================================================
--- qpsmtpd-prefork	(revision 658)
+++ qpsmtpd-prefork	(working copy)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/perl 
 # High performance pre-forking qpsmtpd daemon, Copyright (C) 2006 SoftScan
 # http://www.softscan.co.uk
 #
@@ -74,7 +74,7 @@
 --children int      : Max number of children that can be spawned (default: $max_children)
 --idle-children int : Number of idle children to spawn (default: $idle_children, 0 to disable)
 --user username     : User the daemon should run as
---pid-file path	    : Path to pid file
+--pid-file path	    : Path to pid file (default: $PID)
 --renice-parent int : Subtract value from parent process nice level (default: $re_nice)
 --help              : This message
 EOT
@@ -92,10 +92,13 @@
     'children=i'      => \$max_children,
     'idle-children=i' => \$idle_children,
     'user=s'          => \$user,
+    'pid-file'        => \$PID,
     'renice-parent=i' => \$re_nice,
     'help'            => \&usage,
   ) || &usage;
 
+if ($user =~ /^([\w\-]+)$/) { $user = $1 } else { &usage }
+
 # set max from ip to max number of children if option is set to disabled
 $maxconnip = $max_children if ($maxconnip == 0);
 
@@ -357,7 +360,11 @@
 
         # close connection and cleanup
         $client->shutdown(2);
-
+	while(<STDIN>) {
+		chomp;
+		info("clear unneeded data left in STDIN: <$_>");
+	}
+	
         # unset block and receive pending signals
         unblock_signal($sigset);
     }
Index: lib/Qpsmtpd/SMTP/Prefork.pm
===================================================================
--- lib/Qpsmtpd/SMTP/Prefork.pm	(revision 658)
+++ lib/Qpsmtpd/SMTP/Prefork.pm	(working copy)
@@ -1,5 +1,6 @@
 package Qpsmtpd::SMTP::Prefork;
 use Qpsmtpd::SMTP;
+use Qpsmtpd::Constants;
 @ISA = qw(Qpsmtpd::SMTP);
 
 sub dispatch {
Index: lib/Qpsmtpd/TcpServer/Prefork.pm
===================================================================
--- lib/Qpsmtpd/TcpServer/Prefork.pm	(revision 658)
+++ lib/Qpsmtpd/TcpServer/Prefork.pm	(working copy)
@@ -1,6 +1,7 @@
 package Qpsmtpd::TcpServer::Prefork;
 use Qpsmtpd::TcpServer;
 use Qpsmtpd::SMTP::Prefork;
+use Qpsmtpd::Constants;
 
 @ISA = qw(Qpsmtpd::SMTP::Prefork Qpsmtpd::TcpServer);
 
@@ -12,7 +13,7 @@
     #reset info
     $self->{_connection} = Qpsmtpd::Connection->new(); #reset connection
     $self->{_transaction} = Qpsmtpd::Transaction->new(); #reset transaction
-    $self->SUPER::start_connection();
+    $self->SUPER::start_connection(@_);
 }
 
 sub read_input {
@@ -53,4 +54,12 @@
   return 1;
 }
 
+sub disconnect {
+  my $self = shift;
+  $self->log(LOGDEBUG,"click, disconnecting");
+  $self->SUPER::disconnect(@_);
+  $self->run_hooks("post-connection");
+  die "disconnect_tcpserver";
+}
+
 1;

Reply via email to