Hi people, I've been looking the commited patches, and
still are missing some of them (maybe I didn't sent them)

The patches are:

* missing "use Qpsmtpd::Constants" here and there.

* plugins/count_unrecognized_commands only resets it's internal
  counter on init (this can't work well in preforking,
  I've seen a couple of other plugins broken for prefork, like
  the "delete $ENV{RELAYCLIENT};" in plugins/check_norelay)
  I'm sending patches only for count_unrecognized_commands


* qpsmtpd-prefork: fix for taint mode execution (I donÂ't remember
  if this module is with the -t switch or not, but I'm running
  with it)
  Setting $0 = 'qpsmtpd child'; is not a good idea, it doesnt work as
  intended in all *NIX flavours (maybe this is not a patch for all,
  but it's commented out in all of the other files)



* TcpServer/Prefork.pm It also lacks a "use Qpsmtpd::Constants;"
  $self->SUPER::start_connection(@_); must be called with the @_ (it was
  without them)

  Someone has fixed the split "defined $self->dispatch(split / +/, $_, 2)"
  in other module (the "2" thing was missing)

  missing the disconnect code and the connections are never closed


Please commit these changes


And a word of advise to writing plugins or switching to prefork version.
Beware with the initialization of the modules. In preforking (or other
the processes don't die, so don't assume the variables are reset automatically)
For this reason, (today) you must test very well all the plugins that you
are using, they are not written with a continuous running mode in mind (like
prefork).


Thanks for all the hard work

PD: I tried a memcached backend for saving data about each connection
for filtering purposes and it seems to work very well. When I have something
I'll post it here. (I've posted BerkeleyDB filtering plugins to the 
wiki once, but this seems to work better than the bdb version)



diff --exclude CVS --exclude .svn -ur 0.3x.20060912/lib/Qpsmtpd/SMTP/Prefork.pm 
BACKUPMILLI.PREFORK/app/qpsmtpd.prefork/lib/Qpsmtpd/SMTP/Prefork.pm
--- 0.3x.20060912/lib/Qpsmtpd/SMTP/Prefork.pm   Tue Sep 12 08:48:37 2006
+++ BACKUPMILLI.PREFORK/app/qpsmtpd.prefork/lib/Qpsmtpd/SMTP/Prefork.pm Wed Jul 
26 15:45:09 2006
@@ -1,5 +1,6 @@
 package Qpsmtpd::SMTP::Prefork;
 use Qpsmtpd::SMTP;
+use Qpsmtpd::Constants;
 @ISA = qw(Qpsmtpd::SMTP);
 
 sub dispatch {
diff --exclude CVS --exclude .svn -ur 
0.3x.20060912/plugins/count_unrecognized_commands 
BACKUPMILLI.PREFORK/app/qpsmtpd.prefork/plugins/count_unrecognized_commands
--- 0.3x.20060912/plugins/count_unrecognized_commands   Tue Sep 12 08:48:33 2006
+++ BACKUPMILLI.PREFORK/app/qpsmtpd.prefork/plugins/count_unrecognized_commands 
Tue Aug  1 17:01:56 2006
@@ -25,8 +25,13 @@
     $self->{_unrec_cmd_max} = 4;
   }
 
-  $qp->connection->notes('unrec_cmd_count', 0);
+}
+
+sub hook_connect {
+  my ($self, $transaction) = @_;
 
+  $self->qp->connection->notes('unrec_cmd_count', 0);
+  return DECLINED;
 }
 
 sub hook_unrecognized_command {
diff --exclude CVS --exclude .svn -ur 0.3x.20060912/qpsmtpd-prefork 
BACKUPMILLI.PREFORK/app/qpsmtpd.prefork/qpsmtpd-prefork
--- 0.3x.20060912/qpsmtpd-prefork       Tue Sep 12 08:48:39 2006
+++ BACKUPMILLI.PREFORK/app/qpsmtpd.prefork/qpsmtpd-prefork     Wed Aug  2 
16:18:42 2006
@@ -96,6 +97,8 @@
     'help'            => \&usage,
   ) || &usage;
 
+$user  = $1 if ($user  =~ /(\w+)/);
+
 # set max from ip to max number of children if option is set to disabled
 $maxconnip = $max_children if ($maxconnip == 0);
 
@@ -336,7 +339,7 @@
     # continue to accept connections until "old age" is reached
     for (my $i = 0 ; $i < $child_lifetime ; $i++) {
         # accept a connection
-        $0 = 'qpsmtpd child';    # set pretty child name in process listing
+        #$0 = 'qpsmtpd child';    # set pretty child name in process listing
         my ($client, $iinfo) = $d->accept()
           or die
           "failed to create new object - $!";  # wait here until client 
connects
diff --exclude CVS --exclude .svn -ur 
0.3x.20060912/lib/Qpsmtpd/TcpServer/Prefork.pm 
BACKUPMILLI.PREFORK/app/qpsmtpd.prefork/lib/Qpsmtpd/TcpServer/Prefork.pm
--- 0.3x.20060912/lib/Qpsmtpd/TcpServer/Prefork.pm      Tue Sep 12 08:48:37 2006
+++ BACKUPMILLI.PREFORK/app/qpsmtpd.prefork/lib/Qpsmtpd/TcpServer/Prefork.pm    
Fri Jul 28 11:21:42 2006
@@ -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 {
@@ -30,7 +31,7 @@
       $_ =~ s/\r?\n$//s; # advanced chomp
       $self->log(LOGDEBUG, "dispatching $_");
       $self->connection->notes('original_string', $_);
-      defined $self->dispatch(split / +/, $_)
+      defined $self->dispatch(split / +/, $_, 2)
         or $self->respond(502, "command unrecognized: '$_'");
       alarm $timeout;
     }
@@ -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