Author: hjp
Date: Tue Jun 12 14:27:42 2007
New Revision: 757

Added:
   contrib/hjp/rpm/
   contrib/hjp/rpm/in.qpsmtpd   (contents, props changed)
   contrib/hjp/rpm/qpsmtpd-0.31-config.patch
   contrib/hjp/rpm/qpsmtpd-0.31.1-queue.patch
   contrib/hjp/rpm/qpsmtpd-0.32-dns-random-id.patch
   contrib/hjp/rpm/qpsmtpd-0.32-dnsbl-checkanswer.patch
   contrib/hjp/rpm/qpsmtpd-0.33-af_inet6.patch
   contrib/hjp/rpm/qpsmtpd-0.33-hook-logdebug.patch
   contrib/hjp/rpm/qpsmtpd-0.33-smtp-loginfo.patch
   contrib/hjp/rpm/qpsmtpd-0.33-xinetd.patch
   contrib/hjp/rpm/qpsmtpd-forkserver.rc   (contents, props changed)
   contrib/hjp/rpm/qpsmtpd-forkserver.sysconfig
   contrib/hjp/rpm/qpsmtpd-plugin-file_connection
   contrib/hjp/rpm/qpsmtpd-xinetd
   contrib/hjp/rpm/qpsmtpd.spec

Log:
Added spec file, patches and additional sources for the RPM
(some of the patches are no longer applied but still included in the 
source rpm, so I included them here, too).


Added: contrib/hjp/rpm/in.qpsmtpd
==============================================================================
--- (empty file)
+++ contrib/hjp/rpm/in.qpsmtpd  Tue Jun 12 14:27:42 2007
@@ -0,0 +1,3 @@
+#!/bin/sh
+export QPSMTPD_CONFIG=/etc/qpsmtpd
+exec /usr/bin/qpsmtpd 2> /dev/null

Added: contrib/hjp/rpm/qpsmtpd-0.31-config.patch
==============================================================================
--- (empty file)
+++ contrib/hjp/rpm/qpsmtpd-0.31-config.patch   Tue Jun 12 14:27:42 2007
@@ -0,0 +1,69 @@
+--- lib/Qpsmtpd.pm.dirs        2005-07-31 07:54:36.000000000 +0200
++++ lib/Qpsmtpd.pm     2005-08-20 18:25:17.340983977 +0200
+@@ -87,7 +87,10 @@
+ # database or whatever.
+ #
+ sub config {
+-  my ($self, $c, $type) = @_;
++  my ($self, $c, $arg) = @_;
++  unless (ref $arg) {
++    $arg = { type => $arg };
++  }
+ 
+   #warn "SELF->config($c) ", ref $self;
+ 
+@@ -96,17 +99,13 @@
+                 timeout => 1200,
+                 );
+ 
+-  my ($rc, @config) = $self->run_hooks("config", $c);
+-  @config = () unless $rc == OK;
++  my ($rc, @config) = $self->run_hooks("config", $c, $arg);
++  unless ($rc == OK) {
++    @config = $self->get_qmail_config($c, $arg);
++    @config = $defaults{$c} if ([EMAIL PROTECTED] and $defaults{$c});
++  }
+ 
+-  if (wantarray) {
+-      @config = $self->get_qmail_config($c, $type) unless @config;
+-      @config = $defaults{$c} if ([EMAIL PROTECTED] and $defaults{$c});
+-      return @config;
+-  } 
+-  else {
+-      return ($config[0] || $self->get_qmail_config($c, $type) || 
$defaults{$c});
+-   }
++  return wantarray ? @config : $config[0];
+ }
+ 
+ sub config_dir {
+@@ -122,13 +121,18 @@
+ }
+ 
+ sub plugin_dir {
++  my $self = shift;
++  my $plugin_dir = $self->config('plugin_dir', {nolog => 1});
++  unless (defined($plugin_dir)) {
+     my ($name) = ($0 =~ m!(.*?)/([^/]+)$!);
+-    my $dir = "$name/plugins";
++    $plugin_dir = "$name/plugins";
++  }
++  return $plugin_dir;
+ }
+ 
+ sub get_qmail_config {
+-  my ($self, $config, $type) = @_;
+-  $self->log(LOGDEBUG, "trying to get config for $config");
++  my ($self, $config, $arg) = @_;
++  $self->log(LOGDEBUG, "trying to get config for $config") 
unless($arg->{nolog});
+   if ($self->{_config_cache}->{$config}) {
+     return wantarray ? @{$self->{_config_cache}->{$config}} : 
$self->{_config_cache}->{$config}->[0];
+   }
+@@ -136,7 +140,7 @@
+ 
+   my $configfile = "$configdir/$config";
+ 
+-  if ($type and $type eq "map")  {
++  if ($arg->{type} and $arg->{type} eq "map")  {
+     return +{} unless -e $configfile . ".cdb";
+     eval { require CDB_File };
+ 

Added: contrib/hjp/rpm/qpsmtpd-0.31.1-queue.patch
==============================================================================
--- (empty file)
+++ contrib/hjp/rpm/qpsmtpd-0.31.1-queue.patch  Tue Jun 12 14:27:42 2007
@@ -0,0 +1,18 @@
+--- config.sample/plugins.queue        Fri Nov 18 10:45:35 2005
++++ config.sample/plugins      Tue Nov 29 10:00:37 2005
+@@ -43,8 +43,13 @@
+ # run the clamav virus checking plugin
+ # virus/clamav
+ 
+-# queue the mail with qmail-queue
+-queue/qmail-queue
++# Queuing plugins:
++# uncomment one on them, depending on the mail system you have
++# installed.
++
++#queue/qmail-queue
++#queue/postfix-queue
++#queue/smtp-forward 127.0.0.1
+ 
+ 
+ # If you need to run the same plugin multiple times, you can do

Added: contrib/hjp/rpm/qpsmtpd-0.32-dns-random-id.patch
==============================================================================
--- (empty file)
+++ contrib/hjp/rpm/qpsmtpd-0.32-dns-random-id.patch    Tue Jun 12 14:27:42 2007
@@ -0,0 +1,22 @@
+--- qpsmtpd-forkserver.dns-random-id   Sun Feb 26 13:22:16 2006
++++ qpsmtpd-forkserver Sat Mar 18 23:31:20 2006
+@@ -14,6 +14,7 @@
+ use Socket;
+ use Getopt::Long;
+ use POSIX qw(:sys_wait_h :errno_h :signal_h);
++use Net::DNS::Header;
+ use strict;
+ $| = 1;
+ 
+@@ -232,7 +233,10 @@
+     # otherwise child
+   
+     # all children should have different seeds, to prevent conflicts
+-    srand( time ^ ($$ + ($$ << 15)) );
++    srand();
++    for (0 .. rand(65536)) {
++      Net::DNS::Header::nextid();
++    }
+   
+     close($server);
+   

Added: contrib/hjp/rpm/qpsmtpd-0.32-dnsbl-checkanswer.patch
==============================================================================
--- (empty file)
+++ contrib/hjp/rpm/qpsmtpd-0.32-dnsbl-checkanswer.patch        Tue Jun 12 
14:27:42 2007
@@ -0,0 +1,45 @@
+--- plugins/dnsbl.dnsbl-checkanswer    Sun Feb 26 13:22:16 2006
++++ plugins/dnsbl      Sat Mar 18 23:15:33 2006
+@@ -46,8 +46,10 @@
+ 
+   my $sel = IO::Select->new();
+ 
++  my $dom;
+   for my $dnsbl (keys %dnsbl_zones) {
+     # fix to find A records, if the dnsbl_zones line has a second field 
20/1/04 ++msp
++    $dom->{"$reversed_ip.$dnsbl"} = 1;
+     if (defined($dnsbl_zones{$dnsbl})) {
+       $self->log(LOGDEBUG, "Checking $reversed_ip.$dnsbl for A record in the 
background");
+       $sel->add($res->bgsend("$reversed_ip.$dnsbl"));
+@@ -58,6 +60,7 @@
+   }
+ 
+   $self->qp->connection->notes('dnsbl_sockets', $sel);
++  $self->qp->connection->notes('dnsbl_domains', $dom);
+ 
+   return DECLINED;
+ }
+@@ -77,6 +80,7 @@
+   $res->udp_timeout(30);
+ 
+   my $sel = $conn->notes('dnsbl_sockets') or return "";
++  my $dom = $conn->notes('dnsbl_domains');
+   my $remote_ip = $self->qp->connection->remote_ip;
+ 
+   my $result; 
+@@ -99,11 +103,13 @@
+     if ($query) {
+       my $a_record = 0;
+       foreach my $rr ($query->answer) {
+-      $a_record = 1 if $rr->type eq "A";
+       my $name = $rr->name;
++      $self->log(LOGDEBUG, "name $name");
++      next unless $dom->{$name};
++      $self->log(LOGDEBUG, "name $name was queried");
++      $a_record = 1 if $rr->type eq "A";
+       ($dnsbl) = ($name =~ m/(?:\d+\.){4}(.*)/) unless $dnsbl;
+       $dnsbl = $name unless $dnsbl;
+-      $self->log(LOGDEBUG, "name ", $rr->name);
+       next unless $rr->type eq "TXT";
+       $self->log(LOGDEBUG, "got txt record");
+       $result = $rr->txtdata and last;

Added: contrib/hjp/rpm/qpsmtpd-0.33-af_inet6.patch
==============================================================================
--- (empty file)
+++ contrib/hjp/rpm/qpsmtpd-0.33-af_inet6.patch Tue Jun 12 14:27:42 2007
@@ -0,0 +1,15 @@
+--- qpsmtpd-forkserver.af_inet6        Sun Nov  5 16:25:09 2006
++++ qpsmtpd-forkserver Sun Nov  5 17:32:08 2006
+@@ -231,9 +231,9 @@
+     my ($port, $iaddr) = ($server->sockdomain == AF_INET) ? 
(sockaddr_in($hisaddr)) : (sockaddr_in6($hisaddr));
+     my $localsockaddr = getsockname($client);
+     my ($lport, $laddr) = ($server->sockdomain == AF_INET) ? 
(sockaddr_in($localsockaddr)) : (sockaddr_in6($localsockaddr));
+-    my $nto_iaddr = ($server->sockdomain == AF_INET) ? (inet_ntoa($iaddr)) : 
(inet_ntop(AF_INET6, $iaddr));
+-    my $ton_iaddr = ($server->sockdomain == AF_INET) ? (inet_aton($iaddr)) : 
(inet_pton(AF_INET6, $iaddr));
+-    my $nto_laddr = ($server->sockdomain == AF_INET) ? (inet_ntoa($laddr)) : 
(inet_ntop(AF_INET6, $laddr));
++    my $nto_iaddr = ($server->sockdomain == AF_INET) ? (inet_ntoa($iaddr)) : 
(inet_ntop(AF_INET6(), $iaddr));
++    my $ton_iaddr = ($server->sockdomain == AF_INET) ? (inet_aton($iaddr)) : 
(inet_pton(AF_INET6(), $iaddr));
++    my $nto_laddr = ($server->sockdomain == AF_INET) ? (inet_ntoa($laddr)) : 
(inet_ntop(AF_INET6(), $laddr));
+     $nto_iaddr =~ s/::ffff://;
+     $nto_laddr =~ s/::ffff://;
+ 

Added: contrib/hjp/rpm/qpsmtpd-0.33-hook-logdebug.patch
==============================================================================
--- (empty file)
+++ contrib/hjp/rpm/qpsmtpd-0.33-hook-logdebug.patch    Tue Jun 12 14:27:42 2007
@@ -0,0 +1,11 @@
+--- lib/Qpsmtpd.pm.hook-logdebug       Sun Nov  5 10:54:03 2006
++++ lib/Qpsmtpd.pm     Sun Nov  5 19:35:48 2006
+@@ -341,7 +341,7 @@
+         $@ and warn("FATAL LOGGING PLUGIN ERROR: ", $@) and next;
+       }
+       else {
+-        $self->varlog(LOGINFO, $hook, $code->{name});
++        $self->varlog(LOGDEBUG, $hook, $code->{name});
+         eval { (@r) = $code->{code}->($self, $self->transaction, @_); };
+         $@ and $self->log(LOGCRIT, "FATAL PLUGIN ERROR: ", $@) and next;
+ 

Added: contrib/hjp/rpm/qpsmtpd-0.33-smtp-loginfo.patch
==============================================================================
--- (empty file)
+++ contrib/hjp/rpm/qpsmtpd-0.33-smtp-loginfo.patch     Tue Jun 12 14:27:42 2007
@@ -0,0 +1,29 @@
+--- lib/Qpsmtpd/TcpServer.pm.smtp-loginfo      Wed Oct  4 15:49:49 2006
++++ lib/Qpsmtpd/TcpServer.pm   Sun Nov  5 15:41:31 2006
+@@ -61,7 +61,7 @@
+   while (<STDIN>) {
+     alarm 0;
+     $_ =~ s/\r?\n$//s; # advanced chomp
+-    $self->log(LOGDEBUG, "dispatching $_");
++    $self->log(LOGINFO, "dispatching $_");
+     $self->connection->notes('original_string', $_);
+     defined $self->dispatch(split / +/, $_, 2)
+       or $self->respond(502, "command unrecognized: '$_'");
+@@ -75,7 +75,7 @@
+   my $buf = '';
+   while (my $msg = shift @messages) {
+     my $line = $code . (@messages?"-":" ").$msg;
+-    $self->log(LOGDEBUG, $line);
++    $self->log(LOGINFO, $line);
+     $buf .= "$line\r\n";
+   }
+   print $buf or ($self->log(LOGERROR, "Could not print [$buf]: $!"), return 
0);
+@@ -84,7 +84,7 @@
+ 
+ sub disconnect {
+   my $self = shift;
+-  $self->log(LOGDEBUG,"click, disconnecting");
++  $self->log(LOGINFO,"click, disconnecting");
+   $self->SUPER::disconnect(@_);
+   $self->run_hooks("post-connection");
+   exit;

Added: contrib/hjp/rpm/qpsmtpd-0.33-xinetd.patch
==============================================================================
--- (empty file)
+++ contrib/hjp/rpm/qpsmtpd-0.33-xinetd.patch   Tue Jun 12 14:27:42 2007
@@ -0,0 +1,41 @@
+--- lib/Qpsmtpd/TcpServer.pm.xinetd    Wed Oct  4 15:49:49 2006
++++ lib/Qpsmtpd/TcpServer.pm   Sun Nov  5 16:20:44 2006
+@@ -1,6 +1,7 @@
+ package Qpsmtpd::TcpServer;
+ use Qpsmtpd::SMTP;
+ use Qpsmtpd::Constants;
++use Socket;
+ 
+ @ISA = qw(Qpsmtpd::SMTP);
+ use strict;
+@@ -12,12 +13,25 @@
+ sub start_connection {
+     my $self = shift;
+ 
+-    die "Qpsmtpd::TcpServer must be started by tcpserver\n"
+-      unless $ENV{TCPREMOTEIP};
++    my ($remote_host, $remote_info, $remote_ip);
+ 
+-    my $remote_host = $ENV{TCPREMOTEHOST} || ( $ENV{TCPREMOTEIP} ? 
"[$ENV{TCPREMOTEIP}]" : "[noip!]");
+-    my $remote_info = $ENV{TCPREMOTEINFO} ? "[EMAIL PROTECTED]" : 
$remote_host;
+-    my $remote_ip   = $ENV{TCPREMOTEIP};
++    if ($ENV{TCPREMOTEIP}) {
++      # started from tcpserver (or some other superserver which
++      # exports the TCPREMOTE* variables.
++      $remote_ip   = $ENV{TCPREMOTEIP};
++      $remote_host = $ENV{TCPREMOTEHOST} || "[$remote_ip]";
++      $remote_info = $ENV{TCPREMOTEINFO} ? "[EMAIL PROTECTED]" : $remote_host;
++    } else {
++      # Started from inetd or similar. 
++      # get info on the remote host from the socket.
++      # ignore ident/tap/...
++      my $hersockaddr    = getpeername(STDIN) 
++          or die "getpeername failed: $0 must be called from tcpserver, 
(x)inetd or a similar program which passes a socket to stdin";
++      my ($port, $iaddr) = sockaddr_in($hersockaddr);
++      $remote_ip     = inet_ntoa($iaddr);
++      $remote_host    = gethostbyaddr($iaddr, AF_INET) || "[$remote_ip]";
++      $remote_info    = $remote_host;
++    }
+     $self->log(LOGNOTICE, "Connection from $remote_info [$remote_ip]");
+ 
+     # if the local dns resolver doesn't filter it out we might get

Added: contrib/hjp/rpm/qpsmtpd-forkserver.rc
==============================================================================
--- (empty file)
+++ contrib/hjp/rpm/qpsmtpd-forkserver.rc       Tue Jun 12 14:27:42 2007
@@ -0,0 +1,122 @@
+#! /bin/bash
+#
+# qpsmtpd-forkserver          Start/Stop the qpsmtpd forking server
+#
+# chkconfig: 2345 90 60
+# description: qpsmtpd is a flexible smtpd daemon written in Perl. \
+#              Apart from the core SMTP features, all functionality is \
+#              implemented in small "extension plugins" using the easy \
+#              to use object oriented plugin API.
+# processname: qpsmtpd-forkserver
+# config: /etc/qpsmtpd
+# pidfile: /var/run/qpsmtpd-forkserver.pid
+
+
+# Source function library.
+. /etc/init.d/functions
+. /etc/sysconfig/qpsmtpd-forkserver
+
+RETVAL=0
+
+# See how we were called.
+  
+prog="qpsmtpd-forkserver"
+
+start() {
+       # cleanup environment a bit.
+       unset PERL_UNICODE
+       unset LANG
+       unset LC_TIME
+       unset LC_ALL
+       unset BASH_ENV
+       unset ENV
+       unset CDPATH
+       unset IFS
+
+       echo -n $"Starting $prog: "
+       trap "" 1
+       daemon $prog --detach $QPSMTPD_OPTIONS
+       RETVAL=$?
+       echo
+       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
+       return $RETVAL
+}
+
+stop() {
+       echo -n $"Stopping $prog: "
+       killproc $prog
+       RETVAL=$?
+       echo
+       [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
+       return $RETVAL
+}      
+
+# functions status() uses pidof, which doesn't work with (?) scripts
+qpstatus() {
+       local base=${1##*/}
+       local pid
+
+       # Test syntax.
+       if [ "$#" = 0 ] ; then
+               echo $"Usage: status {program}"
+               return 1
+       fi
+
+       # Use "/var/run/*.pid" file for pid
+       if [ -f /var/run/${base}.pid ] ; then
+           read pid < /var/run/${base}.pid
+           if [ -n "$pid" ]; then
+            /bin/ps -p $pid >/dev/null
+            if [ $? -eq 0 ]; then
+                echo $"${base} (pid $pid) is running..."
+                return 0
+            else                
+                   echo $"${base} dead but pid file exists"
+                   return 1
+            fi
+           fi
+       fi
+       # See if /var/lock/subsys/${base} exists
+       if [ -f /var/lock/subsys/${base} ]; then
+               echo $"${base} dead but subsys locked"
+               return 2
+       fi
+       echo $"${base} is stopped"
+       return 3
+}
+
+restart() {
+       stop
+       start
+}      
+
+reload() {
+       stop
+       start
+}      
+
+case "$1" in
+  start)
+       start
+       ;;
+  stop)
+       stop
+       ;;
+  restart)
+       restart
+       ;;
+  reload)
+       reload
+       ;;
+  status)
+       qpstatus qpsmtpd-forkserver
+       ;;
+  condrestart)
+       [ -f /var/lock/subsys/$prog ] && restart || :
+       ;;
+  *)
+       echo $"Usage: $0 {start|stop|status|reload|restart|condrestart}"
+       exit 1
+esac
+
+exit $?

Added: contrib/hjp/rpm/qpsmtpd-forkserver.sysconfig
==============================================================================
--- (empty file)
+++ contrib/hjp/rpm/qpsmtpd-forkserver.sysconfig        Tue Jun 12 14:27:42 2007
@@ -0,0 +1,3 @@
+QPSMTPD_OPTIONS="-p 25 -l 127.0.0.1 --pid-file /var/run/qpsmtpd-forkserver.pid"
+export QPSMTPD_CONFIG=/etc/qpsmtpd
+export HOME=~smtpd

Added: contrib/hjp/rpm/qpsmtpd-plugin-file_connection
==============================================================================
--- (empty file)
+++ contrib/hjp/rpm/qpsmtpd-plugin-file_connection      Tue Jun 12 14:27:42 2007
@@ -0,0 +1,184 @@
+#!/usr/bin/perl
+# $Id: file 478 2005-07-19 07:40:16Z aqua $
+
+=head1 NAME
+
+file_connection - Simple per session log-to-file logging for qpsmtpd
+
+=head1 DESCRIPTION
+
+The 'file_connection' logging plugin for qpsmtpd records qpsmtpd log messages 
into a
+file (or a named pipe, if you prefer.)
+
+The file is reopened for each connection. To facilitate automatic
+logfile switching the filename can contain strftime conversion
+specifiers, which are expanded immediately before opening the file. This
+ensures that a single connection is never split across logfiles.
+
+The list of supported conversion specifiers depends on the strftime
+implementation of your C library. See strftime(3) for details.
+Additionally, %i exands to a (hopefully) unique session-id.
+
+
+=head1 CONFIGURATION
+
+To enable the logging plugin, add a line of this form to the qpsmtpd plugins
+configuration file:
+
+=over
+
+logging/file_connection [loglevel I<level>] I<path>
+
+For example:
+
+logging/file_connection loglevel LOGINFO /var/log/qpsmtpd/%Y-%m-%d
+
+=back
+
+Multiple instances of the plugin can be configured by appending :I<N> for any
+integer(s) I<N>, to log to multiple files simultaneously, e.g. to log critical
+errors and normally verbose logs elsewhere.
+
+The following optional configuration setting can be supplied:
+
+=over
+
+=item loglevel I<loglevel>
+
+The internal log level below which messages will be logged.  The I<loglevel>
+given should be chosen from this list.  Priorities count downward (for example,
+if LOGWARN were selected, LOGERROR, LOGCRIT and LOGEMERG messages would be
+logged as well):
+
+=over
+
+=item B<LOGDEBUG>
+
+=item B<LOGINFO>
+
+=item B<LOGNOTICE>
+
+=item B<LOGWARN>
+
+=item B<LOGERROR>
+
+=item B<LOGCRIT>
+
+=item B<LOGALERT>
+
+=item B<LOGEMERG>
+
+=back
+
+=back
+
+
+The chosen I<path> should be writable by the user running qpsmtpd; it will be
+created it did not already exist, and appended to otherwise.
+
+=head1 AUTHOR
+
+Peter J. Holzer <[EMAIL PROTECTED]>, based on a plugin by 
+Devin Carraway <[EMAIL PROTECTED]>
+
+=head1 LICENSE
+
+Copyright (c) 2005, Devin Carraway.
+
+This plugin is licensed under the same terms as the qpsmtpd package itself.
+Please see the LICENSE file included with qpsmtpd for details.
+
+=cut
+
+use strict;
+use warnings;
+
+use IO::File;
+#use Sys::Hostname;
+use POSIX qw(strftime);
+
+sub register {
+    my ($self, $qp, @args) = @_;
+    my %args;
+
+    $self->{_loglevel} = LOGWARN;
+
+    while (1) {
+       last if [EMAIL PROTECTED];
+       if (lc $args[0] eq 'loglevel') {
+            shift @args;
+            my $ll = shift @args;
+            if (!defined $ll) {
+                warn "Malformed arguments to logging/file_connection plugin";
+                return;
+            }
+            if ($ll =~ /^(\d+)$/) {
+                $self->{_loglevel} = $1;
+            }
+            elsif ($ll =~ /^(LOG\w+)$/) {
+                $self->{_loglevel} = log_level($1);
+                defined $self->{_loglevel} or $self->{_loglevel} = LOGWARN;
+            }
+        }
+        else { last }
+    }
+
+    unless (@args && $args[0]) {
+        warn "Malformed arguments to syslog plugin";
+        return;
+    }
+
+    $self->{_logfile} = join(' ', @args);
+    $self->{_log_session_id_prefix} = sprintf("%08x%04x", time(), $$);
+    $self->{_log_session_id_counter} = 0;
+
+    $self->register_hook('logging', 'write_log');
+    $self->register_hook('pre-connection', 'open_log');
+    $self->open_log($qp);
+}
+
+sub open_log {
+    my ($self, $qp) = @_;
+    my $output = $self->{_logfile};
+    $self->{_log_session_id} =
+        $self->{_log_session_id_prefix} . "." .
+        ++$self->{_log_session_id_counter};
+
+    $output =~ s/%i/$self->{_log_session_id}/;
+    $output = strftime($output, localtime);
+    #print STDERR "open_log: output=$output, uid=$>\n";
+    if ($output =~ /^\s*\|(.*)/) {
+        unless ($self->{_f} = new IO::File "|$1") {
+            warn "Error opening log output to command $1: $!";
+            return;
+        }
+    } elsif ($output =~ /^(.*)/) { # detaint
+        unless ($self->{_f} = new IO::File ">>$1") {
+            warn "Error opening log output to path $1: $!";
+            return;
+        }
+    }
+    $self->{_f}->autoflush(1);
+
+    return DECLINED;
+}
+
+sub write_log {
+    my ($self, $txn, $trace, $hook, $plugin, @log) = @_;
+
+    return DECLINED if $trace > $self->{_loglevel};
+    return DECLINED if defined $plugin and $plugin eq $self->plugin_name;
+    $self->open_log unless($self->{_f});
+
+    my $f = $self->{_f};
+    print STDERR "no open file\n" unless (defined $f);
+    print $f join(" ",
+                  strftime("%Y-%m-%dT%H:%M:%S%z", localtime), 
$self->{_log_session_id},
+                  (defined $plugin ? " $plugin plugin:" :
+                   defined $hook   ? " running plugin ($hook):"  : ""),
+                  @log), "\n";
+    return DECLINED;
+}
+
+# vi: tabstop=4 shiftwidth=4 expandtab:
+

Added: contrib/hjp/rpm/qpsmtpd-xinetd
==============================================================================
--- (empty file)
+++ contrib/hjp/rpm/qpsmtpd-xinetd      Tue Jun 12 14:27:42 2007
@@ -0,0 +1,19 @@
+# default: on
+# description: The telnet server serves telnet sessions; it uses \
+#      unencrypted username/password pairs for authentication.
+service smtp
+{
+       flags           = REUSE
+       socket_type     = stream        
+       wait            = no
+       user            = smtpd
+       groups          = yes
+       server          = /usr/sbin/in.qpsmtpd
+       log_on_failure  += USERID
+       disable         = yes
+       rlimit_as       = 128M
+       instances       = 40
+       per_source      = 10
+       cps             = 50 10
+}
+

Added: contrib/hjp/rpm/qpsmtpd.spec
==============================================================================
--- (empty file)
+++ contrib/hjp/rpm/qpsmtpd.spec        Tue Jun 12 14:27:42 2007
@@ -0,0 +1,408 @@
+Name: qpsmtpd
+Version: 0.40
+Release: 1.0
+%define orig_version 0.40
+Packager: [EMAIL PROTECTED]
+Summary: qpsmtpd
+License: distributable
+Group: System Environment/Daemons
+URL: http://smtpd.develooper.com/
+BuildRoot: %{_tmppath}/%{name}-root
+BuildRequires: perl >= 0:5.00503
+BuildArchitectures: noarch
+Requires: perl(Mail::Header), perl(Net::DNS) perl(Net::IP)
+
+Source0: qpsmtpd-%{orig_version}.tar.gz
+Source1: qpsmtpd-forkserver.rc
+Source2: qpsmtpd-forkserver.sysconfig
+Source3: qpsmtpd-plugin-file_connection
+Source4: qpsmtpd-xinetd
+Source5: in.qpsmtpd
+
+Patch1: qpsmtpd-0.31-config.patch
+Patch2: qpsmtpd-0.33-xinetd.patch
+Patch3: qpsmtpd-0.33-af_inet6.patch
+Patch4: qpsmtpd-0.31.1-queue.patch
+Patch5: qpsmtpd-0.33-smtp-loginfo.patch
+Patch6: qpsmtpd-0.33-hook-logdebug.patch
+Patch7: qpsmtpd-0.32-dnsbl-checkanswer.patch
+Patch8: qpsmtpd-0.32-dns-random-id.patch
+
+%description
+qpsmtpd is a flexible smtpd daemon written in Perl. Apart from the core
+SMTP features, all functionality is implemented in small "extension
+plugins" using the easy to use object oriented plugin API.
+
+qpsmtpd was originally written as a drop-in qmail-smtpd replacement, but
+now it also includes a smtp forward and a postfix "backend".
+
+%package apache
+Summary: mod_perl-2 connection handler for qpsmtpd
+Group: System Environment/Daemons
+
+%package async
+Summary: qpsmtpd using async I/O in a single process
+Group: System Environment/Daemons
+
+%description apache
+
+This module implements a mod_perl/apache 2.0 connection handler
+that turns Apache into an SMTP server using Qpsmtpd.
+
+%description async
+This package contains the Qpsmtpd::PollServer module, which allows
+qpsmtd to handle many connections in a single process and the 
+qpsmpd-async which uses it.
+
+%prep
+%setup -q -n qpsmtpd-%{orig_version}
+# XXX - doesn't apply cleanly any more but may still be needed for empty
+# configs.
+#%patch1 -p0 -b .config
+# Merged into upstream:
+#%patch2 -p0 -b .xinetd
+#%patch3 -p0 -b .af_inet6
+%patch4 -p0 -b .queue
+#%patch5 -p0 -b .smtp-loginfo
+#%patch6 -p0 -b .hook-logdebug
+#%patch7 -p0 -b .dnsbl-checkanswer
+#%patch8 -p0 -b .dns-random-id
+
+%build
+CFLAGS="$RPM_OPT_FLAGS" perl Makefile.PL 
INSTALLSITELIB=/usr/lib/perl5/site_perl
+make
+
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+%install
+
+rm -rf $RPM_BUILD_ROOT
+eval `perl '-V:installarchlib'`
+mkdir -p $RPM_BUILD_ROOT/$installarchlib
+if grep -q DESTDIR Makefile
+then
+       make DESTDIR=$RPM_BUILD_ROOT
+       find blib/lib -name '*.pm.*' -exec rm -f {} \;
+       make DESTDIR=$RPM_BUILD_ROOT install
+
+else
+       make PREFIX=$RPM_BUILD_ROOT/usr 
+       find blib/lib -name '*.pm.*' -exec rm -f {} \;
+       make PREFIX=$RPM_BUILD_ROOT/usr install
+fi
+mkdir -p $RPM_BUILD_ROOT/usr/sbin
+cp qpsmtpd-async $RPM_BUILD_ROOT/usr/sbin
+mkdir -p $RPM_BUILD_ROOT/usr/share/qpsmtpd
+cp -r plugins $RPM_BUILD_ROOT/usr/share/qpsmtpd/plugins
+rm -f $RPM_BUILD_ROOT/usr/share/qpsmtpd/plugins/*.*
+mkdir -p $RPM_BUILD_ROOT/etc
+cp -r config.sample $RPM_BUILD_ROOT/etc/qpsmtpd
+rm -f $RPM_BUILD_ROOT/etc/qpsmtpd/*.*
+echo /usr/share/qpsmtpd/plugins > $RPM_BUILD_ROOT/etc/qpsmtpd/plugin_dirs
+echo /var/spool/qpsmtpd > $RPM_BUILD_ROOT/etc/qpsmtpd/spool_dir
+echo logging/file_connection loglevel LOGINFO /var/log/qpsmtpd/%Y-%m-%d > 
$RPM_BUILD_ROOT/etc/qpsmtpd/logging
+mkdir -p $RPM_BUILD_ROOT/etc/init.d/
+cp %{SOURCE1} $RPM_BUILD_ROOT/etc/init.d/qpsmtpd-forkserver
+mkdir -p $RPM_BUILD_ROOT/etc/sysconfig/
+cp %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/qpsmtpd-forkserver
+cp %{SOURCE3} $RPM_BUILD_ROOT/usr/share/qpsmtpd/plugins/logging/file_connection
+mkdir -p $RPM_BUILD_ROOT/var/spool/qpsmtpd
+mkdir -p $RPM_BUILD_ROOT/var/log/qpsmtpd
+mkdir -p $RPM_BUILD_ROOT/etc/xinetd.d
+cp %{SOURCE4} $RPM_BUILD_ROOT/etc/xinetd.d/smtp
+mkdir -p $RPM_BUILD_ROOT/usr/sbin
+cp %{SOURCE5} $RPM_BUILD_ROOT/usr/sbin/in.smtp
+
+
+[ -x /usr/lib/rpm/brp-compress ] && /usr/lib/rpm/brp-compress
+
+find $RPM_BUILD_ROOT/usr \( -name perllocal.pod -o -name .packlist \) -exec rm 
{} \;
+find $RPM_BUILD_ROOT/usr -type f -print | \
+       sed "[EMAIL PROTECTED]@@g"     | \
+       grep -v /Apache                 |
+       grep -v /Danga                  |
+       grep -v Qpsmtpd/ConfigServer.pm |
+       grep -v Qpsmtpd/PollServer.pm   > qpsmtpd-%{version}-filelist
+if [ "$(cat qpsmtpd-%{version}-filelist)X" = "X" ] ; then
+    echo "ERROR: EMPTY FILE LIST"
+    exit -1
+fi
+find $RPM_BUILD_ROOT/usr -type f -path '*/Apache*' -print | \
+       sed "[EMAIL PROTECTED]@@g"      > qpsmtpd-apache-%{version}-filelist
+
+%files
+%defattr(-,root,root)
+/usr/sbin/in.smtp
+/usr/bin/qpsmtpd
+/usr/bin/qpsmtpd-forkserver
+/usr/lib/perl5/site_perl/Qpsmtpd.pm
+/usr/lib/perl5/site_perl/Qpsmtpd/Plugin.pm
+/usr/lib/perl5/site_perl/Qpsmtpd/Constants.pm
+/usr/lib/perl5/site_perl/Qpsmtpd/Command.pm
+/usr/lib/perl5/site_perl/Qpsmtpd/TcpServer.pm
+/usr/lib/perl5/site_perl/Qpsmtpd/Connection.pm
+/usr/lib/perl5/site_perl/Qpsmtpd/Transaction.pm
+/usr/lib/perl5/site_perl/Qpsmtpd/Postfix/Constants.pm
+/usr/lib/perl5/site_perl/Qpsmtpd/Postfix/pf2qp.pl
+/usr/lib/perl5/site_perl/Qpsmtpd/TcpServer/Prefork.pm
+/usr/lib/perl5/site_perl/Qpsmtpd/Auth.pm
+/usr/lib/perl5/site_perl/Qpsmtpd/Utils.pm
+/usr/lib/perl5/site_perl/Qpsmtpd/SelectServer.pm
+/usr/lib/perl5/site_perl/Qpsmtpd/DSN.pm
+/usr/lib/perl5/site_perl/Qpsmtpd/SMTP/Prefork.pm
+/usr/lib/perl5/site_perl/Qpsmtpd/SMTP.pm
+/usr/lib/perl5/site_perl/Qpsmtpd/Address.pm
+/usr/lib/perl5/site_perl/Qpsmtpd/Postfix.pm
+/usr/share/man/man3/Qpsmtpd::Command.3pm.gz
+/usr/share/man/man3/Qpsmtpd.3pm.gz
+/usr/share/man/man3/Qpsmtpd::Transaction.3pm.gz
+/usr/share/man/man3/Qpsmtpd::Constants.3pm.gz
+/usr/share/man/man3/Qpsmtpd::ConfigServer.3pm.gz
+/usr/share/man/man3/Qpsmtpd::DSN.3pm.gz
+/usr/share/man/man3/Qpsmtpd::Postfix.3pm.gz
+/usr/share/man/man3/Qpsmtpd::Address.3pm.gz
+/usr/share/man/man3/Qpsmtpd::Connection.3pm.gz
+/usr/share/qpsmtpd/plugins/check_loop
+/usr/share/qpsmtpd/plugins/check_relay
+/usr/share/qpsmtpd/plugins/sender_permitted_from
+/usr/share/qpsmtpd/plugins/count_unrecognized_commands
+/usr/share/qpsmtpd/plugins/spamassassin
+/usr/share/qpsmtpd/plugins/check_badrcptto
+/usr/share/qpsmtpd/plugins/rcpt_ok
+/usr/share/qpsmtpd/plugins/domainkeys
+/usr/share/qpsmtpd/plugins/virus/klez_filter
+/usr/share/qpsmtpd/plugins/virus/check_for_hi_virus
+/usr/share/qpsmtpd/plugins/virus/uvscan
+/usr/share/qpsmtpd/plugins/virus/kavscanner
+/usr/share/qpsmtpd/plugins/virus/hbedv
+/usr/share/qpsmtpd/plugins/virus/clamav
+/usr/share/qpsmtpd/plugins/virus/clamdscan
+/usr/share/qpsmtpd/plugins/virus/aveclient
+/usr/share/qpsmtpd/plugins/virus/sophie
+/usr/share/qpsmtpd/plugins/virus/bitdefender
+/usr/share/qpsmtpd/plugins/queue/smtp-forward
+/usr/share/qpsmtpd/plugins/queue/qmail-queue
+/usr/share/qpsmtpd/plugins/queue/maildir
+/usr/share/qpsmtpd/plugins/queue/exim-bsmtp
+/usr/share/qpsmtpd/plugins/queue/postfix-queue
+/usr/share/qpsmtpd/plugins/http_config
+/usr/share/qpsmtpd/plugins/quit_fortune
+/usr/share/qpsmtpd/plugins/milter
+/usr/share/qpsmtpd/plugins/auth/authnull
+/usr/share/qpsmtpd/plugins/auth/authdeny
+/usr/share/qpsmtpd/plugins/auth/auth_flat_file
+/usr/share/qpsmtpd/plugins/auth/auth_cvm_unix_local
+/usr/share/qpsmtpd/plugins/auth/auth_vpopmail_sql
+/usr/share/qpsmtpd/plugins/auth/auth_ldap_bind
+/usr/share/qpsmtpd/plugins/tls_cert
+/usr/share/qpsmtpd/plugins/logging/warn
+/usr/share/qpsmtpd/plugins/logging/syslog
+/usr/share/qpsmtpd/plugins/logging/adaptive
+/usr/share/qpsmtpd/plugins/logging/file
+/usr/share/qpsmtpd/plugins/logging/devnull
+/usr/share/qpsmtpd/plugins/logging/file_connection
+/usr/share/qpsmtpd/plugins/content_log
+/usr/share/qpsmtpd/plugins/tls
+/usr/share/qpsmtpd/plugins/check_spamhelo
+/usr/share/qpsmtpd/plugins/check_norelay
+/usr/share/qpsmtpd/plugins/check_earlytalker
+/usr/share/qpsmtpd/plugins/hosts_allow
+/usr/share/qpsmtpd/plugins/check_badmailfrom
+/usr/share/qpsmtpd/plugins/dns_whitelist_soft
+/usr/share/qpsmtpd/plugins/dnsbl
+/usr/share/qpsmtpd/plugins/ident/geoip
+/usr/share/qpsmtpd/plugins/ident/p0f
+/usr/share/qpsmtpd/plugins/relay_only
+/usr/share/qpsmtpd/plugins/parse_addr_withhelo
+/usr/share/qpsmtpd/plugins/require_resolvable_fromhost
+/usr/share/qpsmtpd/plugins/rhsbl
+/usr/share/qpsmtpd/plugins/dont_require_anglebrackets
+/usr/share/qpsmtpd/plugins/check_badrcptto_patterns
+/usr/share/qpsmtpd/plugins/greylisting
+/usr/share/qpsmtpd/plugins/check_basicheaders
+/usr/share/qpsmtpd/plugins/check_badmailfromto
+%doc CREDITS Changes LICENSE README README.plugins STATUS
+/etc/init.d/qpsmtpd-forkserver
+%config(noreplace) /etc/qpsmtpd/*
+%config(noreplace) /etc/xinetd.d/smtp
+%config(noreplace) /etc/sysconfig/qpsmtpd-forkserver
+%attr(0700,smtpd,smtpd) %dir /var/spool/qpsmtpd
+%attr(0750,smtpd,smtpd) %dir /var/log/qpsmtpd
+
+%files apache -f qpsmtpd-apache-%{version}-filelist
+%defattr(-,root,root)
+
+%files async
+%defattr(-,root,root)
+/usr/sbin/qpsmtpd-async
+/usr/lib/perl5/site_perl/Danga/Client.pm
+/usr/lib/perl5/site_perl/Danga/TimeoutSocket.pm
+/usr/lib/perl5/site_perl/Qpsmtpd/ConfigServer.pm
+/usr/lib/perl5/site_perl/Qpsmtpd/PollServer.pm
+/usr/share/qpsmtpd/plugins/async/check_earlytalker
+/usr/share/qpsmtpd/plugins/async/dnsbl
+/usr/share/qpsmtpd/plugins/async/require_resolvable_fromhost
+
+
+
+
+
+
+%pre
+if ! id smtpd >/dev/null 2>&1
+then
+    # need to create smtpd user.
+    if perl -e 'exit ! defined(getgrnam("postdrop"))'
+    then
+       # if postfix is installed, we will probably use
+       # queue/postfix, which will need this:
+       supp="-G postdrop"
+    fi
+    useradd -r -m $supp smtpd
+fi
+
+%post
+/sbin/chkconfig --add qpsmtpd-forkserver
+
+%changelog
+* Tue Jun 12 2007 <[EMAIL PROTECTED]> 0.40-1.0
+- updated to 0.40 - no code change.
+
+* Thu Jun 07 2007 <[EMAIL PROTECTED]> 0.40-0.2
+- unset environment variables which are normally tainted in perl.
+- updated to 0.40rc1
+- added dependency on Net::IP (needed by some plugins)
+
+* Sat May 05 2007 <[EMAIL PROTECTED]> 0.33-0.5
+- moved environment cleanup into start() function, otherwise
+  LANG just gets reinitialized.
+
+* Sat May 05 2007 <[EMAIL PROTECTED]> 0.33-0.4
+- split qpsmtpd-async into a separate package to avoid dependency
+  on ParaDNS.
+
+* Sat May 05 2007 <[EMAIL PROTECTED]> 0.33-0.3
+- also unset LANG, LC_ALL and LC_TIME in startup script to prevent
+  locale specific Received headers (bug reported by Dominik Meyer)
+
+* Sun Feb 25 2007 <[EMAIL PROTECTED]> 0.33-0.2
+- 0.3x branch has been merged back to trunk. 
+  Got current snapshot (r715) from trunk.
+
+* Sun Feb 25 2007 <[EMAIL PROTECTED]> 0.33-0.1
+- Start forkserver via "daemon" (Gavin Carr)
+- Fixed 'service qpsmtpd-forkserver status' (Gavin Carr)
+- Changed policy for config files to noreplace (Gavin Carr)
+
+* Sun Nov 05 2006 <[EMAIL PROTECTED]> 0.33-0.0
+- Upgraded to current snapshot from 0.3x branch (which should become
+  0.33 soon-ish)
+- included xinetd-support again.
+
+* Sat Mar 18 2006 <[EMAIL PROTECTED]> 0.32-2
+- fix dnsbl to check whether answer fits query.
+- randomize Net::DNS ids for qpsmtpd-forkserver child processes.
+
+* Wed Mar 08 2006 <[EMAIL PROTECTED]> 0.32-1
+- New upstream 0.32
+- rc-file unsets PERL_UNICODE (bug #38397)
+
+* Sat Jan 28 2006 <[EMAIL PROTECTED]> 0.31.1-3
+- Use ${SOURCE*} macros to refer to source files
+- Avoid invoking rpm and other cleanup in %pre section
+- Invoke chkconfig in %post.
+- (Thanks to Josko Plazonic for the reporting these problems and
+  suggesting fixes)
+
+* Tue Nov 30 2005 <[EMAIL PROTECTED]> 0.31.1-2
+- Revision 170 of plugins/loggin/file_connection:
+  Return DECLINED from open_log.
+  Open log in write_log if it isn't already open.
+
+* Tue Nov 29 2005 <[EMAIL PROTECTED]> 0.31.1-1
+- Commented out queue plugins from sample config
+- Added dependencies
+- Create smtpd user if it doesn't exist
+- Added /var/log/qpsmtpd and /var/spool/qpsmtpd
+
+* Sat Nov 26 2005 <[EMAIL PROTECTED]>
+- Added file_connection plugin
+- Startup file for qpsmtpd-forkserver now uses --detach and assumes that
+  a suitable logging module is configured (file_connection by default)
+
+* Wed Nov 23 2005 <[EMAIL PROTECTED]>
+- Forkserver drops privileges before loading plugins now.
+
+* Sun Nov 20 2005 <[EMAIL PROTECTED]>
+- New upstream 0.31.1
+
+* Mon Nov 14 2005 <[EMAIL PROTECTED]> 0.31-8
+- New upstream 0.31rc3.
+- pre-connection patch slightly simplified since upstream fixed one of
+  the bugs.
+
+* Tue Aug 23 2005 <[EMAIL PROTECTED]>
+- forced INSTALLSITELIB=/usr/lib/perl5/site_perl as suggested by 
+  Charlie Brady.
+
+* Sat Aug 20 2005 <[EMAIL PROTECTED]> 0.31-7
+- RC2 from upstream.
+- Removed patches which aren't applied from spec file.
+
+* Fri Jul 22 2005 <[EMAIL PROTECTED]> 0.31-6
+- New upstream snapshot from 0.31 branch: svn revision 509.
+
+* Sun Jul 17 2005 <[EMAIL PROTECTED]> 0.31-5
+- include only /etc/init.d/qpsmtpd-forkserver, not /etc/init.d
+  it conflicts with old initscripts packages.
+
+* Sun Jul 17 2005 <[EMAIL PROTECTED]> 0.31-4
+- removed tabs from forkserver 
+
+* Sun Jul 17 2005 <[EMAIL PROTECTED]> 0.31-3
+- added startup script for forkserver
+- changed BuildArchitectures to noarch.
+
+* Sat Jul 16 2005 <[EMAIL PROTECTED]> 0.31-2
+- pre-connection hook is now actually called, not just defined.
+
+* Fri Jul 15 2005 <[EMAIL PROTECTED]> 0.31-1
+- merged with 0.31. Most of my patches are now in the official release.
+- merged Gavin's per-user-config patch with my dirs patch, since the
+  latter needs a way to turn off logging.
+- added /etc/qpsmtpd/plugin_dir to package.
+
+* Mon Jun 13 2005 <[EMAIL PROTECTED]> 0.29-6
+- fixed removal of patch backup files
+- fixed option --pid-file
+
+* Sun Jun 12 2005 <[EMAIL PROTECTED]>
+- avoid installing patch backup files
+- split Apache::Qpsmtpd into separate package to avoid dependency hell.
+- fixed URL
+- changed group to Daemons.
+- Fixed installation for newer versions of ExtUtils::MakeMaker
+
+* Wed Jun  1 2005 <[EMAIL PROTECTED]> 0.29-5
+- Really don't reap children in signal handler.
+
+* Tue May 31 2005 <[EMAIL PROTECTED]> 0.29-4
+- Return 421 for DENYSOFT_DISCONNECT
+- Don't reap children in signal handler.
+
+* Thu May 19 2005 <[EMAIL PROTECTED]> 0.29-3
+- removed code to accept paths without <>.
+
+* Thu May 19 2005 <[EMAIL PROTECTED]> 0.29-2
+- added QPSMTPD_CONFIG env variable and plugin_dir config.
+- added supplemental groups and support for pid file
+- added shared_connect hook
+- changed log level for SMTP dialog from DEBUG to INFO
+
+* Thu Apr 21 2005 [EMAIL PROTECTED]
+- added plugins, /etc and docs.
+
+* Mon Apr 18 2005 [EMAIL PROTECTED]
+- Specfile autogenerated
+

Reply via email to