cvs commit: qpsmtpd/plugins/queue qmail-queue smtp-forward

[email protected] (Matt Sergeant)
Newsgroups perl.cvs.qpsmtpd
Message-ID <[email protected]>
cvsuser     04/03/05 04:46:24

  Modified:    lib      Qpsmtpd.pm
               lib/Qpsmtpd Constants.pm Plugin.pm SMTP.pm SelectServer.pm
                        TcpServer.pm Transaction.pm
               plugins  check_earlytalker check_spamhelo clamav
                        count_unrecognized_commands dnsbl http_config
                        milter rhsbl sender_permitted_from spamassassin
               plugins/queue qmail-queue smtp-forward
  Added:       config   loglevel
  Log:
  New for 0.28: Log levels and $Include for config/plugins
  
  Revision  Changes    Path
  1.1                  qpsmtpd/config/loglevel
  
  Index: loglevel
  ===================================================================
  # Log levels
  # LOGDEBUG   = 8
  # LOGINFO    = 7
  # LOGNOTICE  = 6
  # LOGWARN    = 5
  # LOGERROR   = 4
  # LOGCRIT    = 3
  # LOGALERT   = 2
  # LOGEMERG   = 1
  # LOGRADAR   = 0
  4
  
  
  1.32      +74 -19    qpsmtpd/lib/Qpsmtpd.pm
  
  Index: Qpsmtpd.pm
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/lib/Qpsmtpd.pm,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -w -r1.31 -r1.32
  --- Qpsmtpd.pm	5 Mar 2004 09:26:36 -0000	1.31
  +++ Qpsmtpd.pm	5 Mar 2004 12:46:23 -0000	1.32
  @@ -1,20 +1,39 @@
   package Qpsmtpd;
   use strict;
  -
  -$Qpsmtpd::VERSION = "0.28-dev";
  -sub TRACE_LEVEL () { 6 }
  +use vars qw($VERSION $LogLevel);
   
   use Sys::Hostname;
   use Qpsmtpd::Constants;
   
  -sub version { $Qpsmtpd::VERSION };
  +$VERSION = "0.28-dev";
  +sub TRACE_LEVEL { $LogLevel }
  +
  +sub version { $VERSION };
   
   $Qpsmtpd::_hooks = {};
   
  +sub init_logger {
  +    my $self = shift;
  +    # Get the loglevel - we localise loglevel to zero while we do this
  +    my $loglevel = do {
  +        local $LogLevel = 0;
  +        $self->config("loglevel");
  +    };
  +    if (defined($loglevel) and $loglevel =~ /^\d+$/) {
  +        $LogLevel = $loglevel;
  +    }
  +    else {
  +        $LogLevel = LOGWARN; # Default if no loglevel file found.
  +    }
  +    return $LogLevel;
  +}
  +
   sub log {
     my ($self, $trace, @log) = @_;
  +  my $level = TRACE_LEVEL();
  +  $level = $self->init_logger unless defined $level;
     warn join(" ", $$, @log), "\n"
  -    if $trace <= TRACE_LEVEL;
  +    if $trace <= $level;
   }
   
   
  @@ -49,7 +68,7 @@
   
   sub get_qmail_config {
     my ($self, $config, $type) = @_;
  -  $self->log(8, "trying to get config for $config");
  +  $self->log(LOGDEBUG, "trying to get config for $config");
     if ($self->{_config_cache}->{$config}) {
       return wantarray ? @{$self->{_config_cache}->{$config}} : $self->{_config_cache}->{$config}->[0];
     }
  @@ -64,23 +83,28 @@
       eval { require CDB_File };
   
       if ($@) {
  -      $self->log(0, "No $configfile.cdb support, could not load CDB_File module: $@");
  +      $self->log(LOGERROR, "No $configfile.cdb support, could not load CDB_File module: $@");
       }
       my %h;
       unless (tie(%h, 'CDB_File', "$configfile.cdb")) {
  -      $self->log(0, "tie of $configfile.cdb failed: $!");
  -      return DECLINED;
  +      $self->log(LOGERROR, "tie of $configfile.cdb failed: $!");
  +      return +{};
       }
       #warn Data::Dumper->Dump([\%h], [qw(h)]);
       # should we cache this?
       return \%h;
     }
   
  +  return $self->_config_from_file($configfile, $config);
  +}
  +
  +sub _config_from_file {
  +  my ($self, $configfile, $config) = @_;
     return unless -e $configfile;
     open CF, "<$configfile" or warn "$$ could not open configfile $configfile: $!" and return;
     my @config = <CF>;
     chomp @config;
  -  @config = grep { $_ and $_ !~ m/^\s*#/ and $_ =~ m/\S/} @config;
  +  @config = grep { length($_) and $_ !~ m/^\s*#/ and $_ =~ m/\S/} @config;
     close CF;
     #$self->log(10, "returning get_config for $config ",Data::Dumper->Dump([\@config], [qw(config)]));
     $self->{_config_cache}->{$config} = \@config;
  @@ -94,12 +118,43 @@
   
     my ($name) = ($0 =~ m!(.*?)/([^/]+)$!);
     my $dir = "$name/plugins";
  -  $self->log(2, "loading plugins from $dir");
  +  $self->log(LOGNOTICE, "loading plugins from $dir");
  +
  +  $self->_load_plugins($dir, @plugins);
  +}
  +
  +sub _load_plugins {
  +  my $self = shift;
  +  my ($dir, @plugins) = @_;
   
     for my $plugin (@plugins) {
  -    $self->log(7, "Loading $plugin");
  +    $self->log(LOGINFO, "Loading $plugin");
       ($plugin, my @args) = split /\s+/, $plugin;
       
  +    if (lc($plugin) eq '$include') {
  +      my $inc = shift @args;
  +      my $config_dir = ($ENV{QMAIL} || '/var/qmail') . '/control';
  +      my ($name) = ($0 =~ m!(.*?)/([^/]+)$!);
  +      $config_dir = "$name/config" if (-e "$name/config/$inc");
  +      if (-d "$config_dir/$inc") {
  +        $self->log(LOGDEBUG, "Loading include dir: $config_dir/$inc");
  +        opendir(DIR, "$config_dir/$inc") || die "opendir($config_dir/$inc): $!";
  +        my @plugconf = sort grep { -f $_ } map { "$config_dir/$inc/$_" } grep { !/^\./ } readdir(DIR);
  +        closedir(DIR);
  +        foreach my $f (@plugconf) {
  +            $self->_load_plugins($dir, $self->_config_from_file($f, "plugins"));
  +        }
  +      }
  +      elsif (-f "$config_dir/$inc") {
  +        $self->log(LOGDEBUG, "Loading include file: $config_dir/$inc");
  +        $self->_load_plugins($dir, $self->_config_from_file("$config_dir/$inc", "plugins"));
  +      }
  +      else {
  +        $self->log(LOGCRIT, "CRITICAL PLUGIN CONFIG ERROR: Include $config_dir/$inc not found");
  +      }
  +      next;
  +    }
  +    
       my $plugin_name = $plugin;
   
       # Escape everything into valid perl identifiers
  @@ -113,8 +168,10 @@
   		       "::" . (length $2 ? sprintf("_%2x",unpack("C",$2)) : "")
   		      ]egx;
   
  +    my $package = "Qpsmtpd::Plugin::$plugin_name";
  +
       # don't reload plugins if they are already loaded
  -    next if defined &{"Qpsmtpd::Plugin::${plugin_name}::register"};
  +    next if defined &{"${package}::register"};
       
       my $sub;
       open F, "$dir/$plugin" or die "could not open $dir/$plugin: $!";
  @@ -124,8 +181,6 @@
       }
       close F;
   
  -    my $package = "Qpsmtpd::Plugin::$plugin_name";
  -
       my $line = "\n#line 1 $dir/$plugin\n";
   
       my $eval = join(
  @@ -161,18 +216,18 @@
     if ($self->{_hooks}->{$hook}) {
       my @r;
       for my $code (@{$self->{_hooks}->{$hook}}) {
  -      $self->log(5, "running plugin ", $code->{name});
  +      $self->log(LOGINFO, "running plugin ", $code->{name});
         eval { (@r) = $code->{code}->($self, $self->can('transaction') ? $self->transaction : {}, @_); };
  -      $@ and $self->log(0, "FATAL PLUGIN ERROR: ", $@) and next;
  +      $@ and $self->log(LOGCRIT, "FATAL PLUGIN ERROR: ", $@) and next;
         !defined $r[0] 
  -	  and $self->log(1, "plugin ".$code->{name}
  +	  and $self->log(LOGERROR, "plugin ".$code->{name}
   			 ."running the $hook hook returned undef!")
   	  and next;
   
         # should we have a hook for "OK" too? 
         if ($r[0] == DENY or $r[0] == DENYSOFT) {
   	  $r[1] = "" if not defined $r[1];
  -	  $self->log(10, "Plugin $code->{name}, hook $hook returned $r[0], $r[1]");
  +	  $self->log(LOGDEBUG, "Plugin $code->{name}, hook $hook returned $r[0], $r[1]");
   	  $self->run_hooks("deny", $code->{name}, $r[0], $r[1]) unless ($hook eq "deny");
         }
   
  
  
  
  1.7       +13 -4     qpsmtpd/lib/Qpsmtpd/Constants.pm
  
  Index: Constants.pm
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/lib/Qpsmtpd/Constants.pm,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -w -r1.6 -r1.7
  --- Constants.pm	3 Dec 2003 08:07:36 -0000	1.6
  +++ Constants.pm	5 Mar 2004 12:46:23 -0000	1.7
  @@ -2,13 +2,12 @@
   use strict;
   require Exporter;
   
  -my (@common) = qw(OK DECLINED DONE DENY DENYSOFT DENYHARD TRACE);
  +my (@common) = qw(OK DECLINED DONE DENY DENYSOFT DENYHARD);
  +my (@loglevels) = qw(LOGDEBUG LOGINFO LOGNOTICE LOGWARN LOGERROR LOGCRIT LOGALERT LOGEMERG LOGRADAR);
   
   use vars qw($VERSION @ISA @EXPORT);
   @ISA    = qw(Exporter);
  -@EXPORT = @common;
  -
  -use constant TRACE => 10;
  +@EXPORT = (@common, @loglevels);
   
   use constant OK       => 900;
   use constant DENY     => 901;
  @@ -17,6 +16,16 @@
   use constant DONE     => 910;
   use constant DENYHARD     => 903;
   
  +# log levels
  +use constant LOGDEBUG   => 8;
  +use constant LOGINFO    => 7;
  +use constant LOGNOTICE  => 6;
  +use constant LOGWARN    => 5;
  +use constant LOGERROR   => 4;
  +use constant LOGCRIT    => 3;
  +use constant LOGALERT   => 2;
  +use constant LOGEMERG   => 1;
  +use constant LOGRADAR   => 0;
   
   1;
   
  
  
  
  1.6       +8 -0      qpsmtpd/lib/Qpsmtpd/Plugin.pm
  
  Index: Plugin.pm
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/lib/Qpsmtpd/Plugin.pm,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -w -r1.5 -r1.6
  --- Plugin.pm	2 Nov 2003 11:35:15 -0000	1.5
  +++ Plugin.pm	5 Mar 2004 12:46:23 -0000	1.6
  @@ -1,6 +1,11 @@
   package Qpsmtpd::Plugin;
   use strict;
   
  +my %hooks = map { $_ => 1 } qw(
  +    config  queue  data_post  quit  rcpt  mail  ehlo  helo
  +    connect  reset_transaction  unrecognized_command  disconnect
  +);
  +
   sub new {
     my $proto = shift;
     my $class = ref($proto) || $proto;
  @@ -10,6 +15,9 @@
   
   sub register_hook {
     my ($plugin, $hook, $method) = @_;
  +  
  +  die $plugin->plugin_name . " : Invalid hook: $hook" unless $hooks{$hook};
  +
     # I can't quite decide if it's better to parse this code ref or if
     # we should pass the plugin object and method name ... hmn.
     $plugin->qp->_register_hook($hook, { code => sub { local $plugin->{_qp} = shift; $plugin->$method(@_) },
  
  
  
  1.25      +10 -10    qpsmtpd/lib/Qpsmtpd/SMTP.pm
  
  Index: SMTP.pm
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/lib/Qpsmtpd/SMTP.pm,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -w -r1.24 -r1.25
  --- SMTP.pm	4 Mar 2004 04:29:45 -0000	1.24
  +++ SMTP.pm	5 Mar 2004 12:46:23 -0000	1.25
  @@ -68,7 +68,7 @@
   
     if (1 or $self->{_commands}->{$cmd} and $self->can($cmd)) {
       my ($result) = eval { $self->$cmd(@_) };
  -    $self->log(0, "XX: $@") if $@;
  +    $self->log(LOGERROR, "XX: $@") if $@;
       return $result if defined $result;
       return $self->fault("command '$cmd' failed unexpectedly");
     }
  @@ -205,7 +205,7 @@
     }
     else {
       my $from_parameter = join " ", @_;
  -    $self->log(2, "full from_parameter: $from_parameter");
  +    $self->log(LOGINFO, "full from_parameter: $from_parameter");
       my ($from) = ($from_parameter =~ m/^from:\s*(\S+)/i)[0];
       warn "$$ from email address : [$from]\n";
       if ($from eq "<>" or $from =~ m/\[undefined\]/) {
  @@ -222,22 +222,22 @@
       }
       elsif ($rc == DENY) {
         $msg ||= $from->format . ', denied';
  -      $self->log(2, "deny mail from " . $from->format . " ($msg)");
  +      $self->log(LOGINFO, "deny mail from " . $from->format . " ($msg)");
         $self->respond(550, $msg);
       }
       elsif ($rc == DENYSOFT) {
         $msg ||= $from->format . ', temporarily denied';
  -      $self->log(2, "denysoft mail from " . $from->format . " ($msg)");
  +      $self->log(LOGINFO, "denysoft mail from " . $from->format . " ($msg)");
         $self->respond(450, $msg);
       }
       elsif ($rc == DENYHARD) {
         $msg ||= $from->format . ', denied';
  -      $self->log(2, "deny mail from " . $from->format . " ($msg)");
  +      $self->log(LOGINFO, "deny mail from " . $from->format . " ($msg)");
         $self->respond(550, $msg);
         $self->disconnect;
       }
       else { # includes OK
  -      $self->log(2, "getting mail from ".$from->format);
  +      $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);
       }
  @@ -269,7 +269,7 @@
     }
     elsif ($rc == DENYHARD) {
         $msg ||= 'delivery denied';
  -      $self->log(2, "delivery denied ($msg)");
  +      $self->log(LOGINFO, "delivery denied ($msg)");
         $self->respond(550, $msg);
         $self->disconnect;
     }
  @@ -337,7 +337,7 @@
     my $in_header = 1;
     my $complete = 0;
   
  -  $self->log(8, "max_size: $max_size / size: $size");
  +  $self->log(LOGDEBUG, "max_size: $max_size / size: $size");
   
     my $header = Mail::Header->new(Modify => 0, MailFrom => "COERCE");
   
  @@ -392,12 +392,12 @@
   
         $size += length $_;
       }
  -    #$self->log(5, "size is at $size\n") unless ($i % 300);
  +    #$self->log(LOGDEBUG, "size is at $size\n") unless ($i % 300);
   
       alarm $timeout;
     }
   
  -  $self->log(6, "max_size: $max_size / size: $size");
  +  $self->log(LOGDEBUG, "max_size: $max_size / size: $size");
   
     $self->transaction->header($header);
   
  
  
  
  1.8       +8 -6      qpsmtpd/lib/Qpsmtpd/SelectServer.pm
  
  Index: SelectServer.pm
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/lib/Qpsmtpd/SelectServer.pm,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -w -r1.7 -r1.8
  --- SelectServer.pm	19 Nov 2003 23:01:43 -0000	1.7
  +++ SelectServer.pm	5 Mar 2004 12:46:23 -0000	1.8
  @@ -29,8 +29,10 @@
   
   sub log {
     my ($self, $trace, @log) = @_;
  +  my $level = Qpsmtpd::TRACE_LEVEL();
  +  $level = $self->init_logger unless defined $level;
     warn join(" ", fileno($self->client), @log), "\n"
  -    if $trace <= Qpsmtpd::TRACE_LEVEL();
  +    if $trace <= $level;
   }
   
   sub main {
  @@ -75,7 +77,7 @@
                   my $qp = Qpsmtpd::SelectServer->new();
                   $qp->client($qpclient);
                   $qp{$qpclient} = $qp;
  -                $qp->log(1, "Connection number " . keys(%qp));
  +                $qp->log(LOGINFO, "Connection number " . keys(%qp));
                   $inbuffer{$qpclient} = '';
                   $outbuffer{$qpclient} = '';
                   $ready{$qpclient} = [];
  @@ -118,7 +120,7 @@
                       $qp->data_line($req . CRLF);
                   }
                   else {
  -                    $qp->log(1, "dispatching $req");
  +                    $qp->log(LOGINFO, "dispatching $req");
                       defined $qp->dispatch(split / +/, $req)
                           or $qp->respond(502, "command unrecognized: '$req'");
                   }
  @@ -174,7 +176,7 @@
       my $remote_ip = shift;
       my $remote_host = shift;
   
  -    $self->log(1, "Connection from $remote_host [$remote_ip]");
  +    $self->log(LOGNOTICE, "Connection from $remote_host [$remote_ip]");
       my $remote_info = 'NOINFO';
   
       # if the local dns resolver doesn't filter it out we might get
  @@ -212,7 +214,7 @@
     my $client = $self->client || die "No client!";
     while (my $msg = shift @messages) {
       my $line = $code . (@messages?"-":" ").$msg;
  -    $self->log(1, ">$line");
  +    $self->log(LOGINFO, ">$line");
       $outbuffer{$client} .= "$line\r\n";
     }
     return 1;
  @@ -244,7 +246,7 @@
     local $_ = shift;
     
     if ($_ eq ".\r\n") {
  -      $self->log(6, "max_size: $self->{__max_size} / size: $self->{__size}");
  +      $self->log(LOGDEBUG, "max_size: $self->{__max_size} / size: $self->{__size}");
         delete $indata{$self->client()};
       
         my $smtp = $self->connection->hello eq "ehlo" ? "ESMTP" : "SMTP";
  
  
  
  1.9       +3 -3      qpsmtpd/lib/Qpsmtpd/TcpServer.pm
  
  Index: TcpServer.pm
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/lib/Qpsmtpd/TcpServer.pm,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -w -r1.8 -r1.9
  --- TcpServer.pm	21 Apr 2003 08:28:12 -0000	1.8
  +++ TcpServer.pm	5 Mar 2004 12:46:23 -0000	1.9
  @@ -50,7 +50,7 @@
     while (<STDIN>) {
       alarm 0;
       $_ =~ s/\r?\n$//s; # advanced chomp
  -    $self->log(1, "dispatching $_");
  +    $self->log(LOGDEBUG, "dispatching $_");
       defined $self->dispatch(split / +/, $_)
         or $self->respond(502, "command unrecognized: '$_'");
       alarm $timeout;
  @@ -61,8 +61,8 @@
     my ($self, $code, @messages) = @_;
     while (my $msg = shift @messages) {
       my $line = $code . (@messages?"-":" ").$msg;
  -    $self->log(1, "$line");
  -    print "$line\r\n" or ($self->log(1, "Could not print [$line]: $!"), return 0);
  +    $self->log(LOGDEBUG, "$line");
  +    print "$line\r\n" or ($self->log(LOGERROR, "Could not print [$line]: $!"), return 0);
     }
     return 1;
   }
  
  
  
  1.7       +1 -1      qpsmtpd/lib/Qpsmtpd/Transaction.pm
  
  Index: Transaction.pm
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/lib/Qpsmtpd/Transaction.pm,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -w -r1.6 -r1.7
  --- Transaction.pm	10 Jun 2003 10:15:42 -0000	1.6
  +++ Transaction.pm	5 Mar 2004 12:46:23 -0000	1.7
  @@ -121,7 +121,7 @@
   
     undef $self->{_body_file} if $self->{_body_file};
     if ($self->{_filename} and -e $self->{_filename}) {
  -    unlink $self->{_filename} or $self->log(0, "Could not unlink ", $self->{_filename}, ": $!");
  +    unlink $self->{_filename} or $self->log(LOGERROR, "Could not unlink ", $self->{_filename}, ": $!");
     }
   }
   
  
  
  
  1.2       +2 -2      qpsmtpd/plugins/check_earlytalker
  
  Index: check_earlytalker
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/plugins/check_earlytalker,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -w -r1.1 -r1.2
  --- check_earlytalker	15 Apr 2003 17:39:27 -0000	1.1
  +++ check_earlytalker	5 Mar 2004 12:46:24 -0000	1.2
  @@ -34,9 +34,9 @@
     
     $in->add(\*STDIN) || return DECLINED;
     if ($in->can_read(1)) {
  -    $self->log(1, "remote host started talking before we said hello");
  +    $self->log(LOGDEBUG, "remote host started talking before we said hello");
       return (DENYSOFT, "Don't be rude and talk before I say hello!");
     }
  -  $self->log(10,"remote host said nothing spontaneous, proceeding");
  +  $self->log(LOGINFO,"remote host said nothing spontaneous, proceeding");
     return DECLINED;
   }
  
  
  
  1.2       +1 -1      qpsmtpd/plugins/check_spamhelo
  
  Index: check_spamhelo
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/plugins/check_spamhelo,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -w -r1.1 -r1.2
  --- check_spamhelo	18 Mar 2003 09:43:12 -0000	1.1
  +++ check_spamhelo	5 Mar 2004 12:46:24 -0000	1.2
  @@ -28,7 +28,7 @@
     
     for my $bad ($self->qp->config('badhelo')) {
       if ($host eq lc $bad) {
  -      $self->log(5, "Denying HELO from host claiming to be $bad");
  +      $self->log(LOGDEBUG, "Denying HELO from host claiming to be $bad");
         return (DENY, "Uh-huh.  You're $host, and I'm a boil on the bottom of the Marquess of Queensbury's great-aunt.");
       }
     }
  
  
  
  1.3       +7 -7      qpsmtpd/plugins/clamav
  
  Index: clamav
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/plugins/clamav,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -w -r1.2 -r1.3
  --- clamav	8 Oct 2003 07:15:51 -0000	1.2
  +++ clamav	5 Mar 2004 12:46:24 -0000	1.3
  @@ -12,10 +12,10 @@
       if ($args[0] =~ /^(\/[\/\-\_\.a-z0-9A-Z]*)$/) {
         $self->{_clamscan_loc} = $1;
       } else {
  -      $self->log(1, "FATAL ERROR: Unexpected characters in clamav argument 1");
  +      $self->log(LOGERROR, "FATAL ERROR: Unexpected characters in clamav argument 1");
         exit 3;
       }
  -    $self->log(1, "WARNING: Ignoring additional arguments.") if (@args > 1);
  +    $self->log(LOGWARN, "WARNING: Ignoring additional arguments.") if (@args > 1);
     } else {
       $self->{_clamscan_loc} = "/usr/local/bin/clamscan";
     }
  @@ -35,7 +35,7 @@
    
     # Now do the actual scanning!
     my $cmd = $self->{_clamscan_loc}." --stdout -i --max-recursion=50 --disable-summary $filename 2>&1";
  -  $self->log(1, "Running: $cmd");
  +  $self->log(LOGDEBUG, "Running: $cmd");
     my $output = `$cmd`;
    
     my $result = ($? >> 8);
  @@ -46,20 +46,20 @@
    
     $output =~ s/^.* (.*) FOUND$/$1 /mg;
    
  -  $self->log(1, "clamscan results: $output");
  +  $self->log(LOGDEBUG, "clamscan results: $output");
    
     if ($signal) {
  -    $self->log(1, "clamscan exited with signal: $signal");
  +    $self->log(LOGINFO, "clamscan exited with signal: $signal");
       return (DECLINED);
     }
     if ($result == 1) {
  -    $self->log(1, "Virus(es) found");
  +    $self->log(LOGINFO, "Virus(es) found");
       # return (DENY, "Virus Found: $output");
       $transaction->header->add('X-Virus-Found', 'Yes');
       $transaction->header->add('X-Virus-Details', $output);
     }
     elsif ($result) {
  -    $self->log(1, "ClamAV error: $result\n");
  +    $self->log(LOGWARN, "ClamAV error: $result\n");
     }
     $transaction->header->add('X-Virus-Checked', 'Checked');
     return (DECLINED);
  
  
  
  1.3       +3 -3      qpsmtpd/plugins/count_unrecognized_commands
  
  Index: count_unrecognized_commands
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/plugins/count_unrecognized_commands,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -w -r1.2 -r1.3
  --- count_unrecognized_commands	4 Mar 2004 04:14:09 -0000	1.2
  +++ count_unrecognized_commands	5 Mar 2004 12:46:24 -0000	1.3
  @@ -20,7 +20,7 @@
   
     if (@args > 0) {
       $self->{_unrec_cmd_max} = $args[0];
  -    $self->log(1, "WARNING: Ignoring additional arguments.") if (@args > 1);
  +    $self->log(LOGWARN, "WARNING: Ignoring additional arguments.") if (@args > 1);
     } else {
       $self->{_unrec_cmd_max} = 4;
     }
  @@ -32,7 +32,7 @@
   sub check_unrec_cmd {
     my ($self, $cmd) = @_[0,2];
     
  -  $self->log(5, "Unrecognized command '$cmd'");
  +  $self->log(LOGINFO, "Unrecognized command '$cmd'");
   
     my $badcmdcount = 
       $self->qp->connection->notes('unrec_cmd_count',
  @@ -40,7 +40,7 @@
   				);
   
     if ($badcmdcount >= $self->{_unrec_cmd_max}) {
  -    $self->log(5, "Closing connection. Too many unrecognized commands.");
  +    $self->log(LOGINFO, "Closing connection. Too many unrecognized commands.");
       return (DENY, "Closing connection. $badcmdcount unrecognized commands.  Perhaps you should read RFC 2821?");
     }
   
  
  
  
  1.11      +7 -7      qpsmtpd/plugins/dnsbl
  
  Index: dnsbl
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/plugins/dnsbl,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -w -r1.10 -r1.11
  --- dnsbl	4 Mar 2004 04:40:23 -0000	1.10
  +++ dnsbl	5 Mar 2004 12:46:24 -0000	1.11
  @@ -40,10 +40,10 @@
     for my $dnsbl (keys %dnsbl_zones) {
       # fix to find A records, if the dnsbl_zones line has a second field 20/1/04 ++msp
       if (defined($dnsbl_zones{$dnsbl})) {
  -      $self->log(7, "Checking $reversed_ip.$dnsbl for A record in the background");
  +      $self->log(LOGDEBUG, "Checking $reversed_ip.$dnsbl for A record in the background");
         $sel->add($res->bgsend("$reversed_ip.$dnsbl"));
       } else {
  -      $self->log(7, "Checking $reversed_ip.$dnsbl for TXT record in the background");
  +      $self->log(LOGDEBUG, "Checking $reversed_ip.$dnsbl for TXT record in the background");
         $sel->add($res->bgsend("$reversed_ip.$dnsbl", "TXT"));
       }
     }
  @@ -69,12 +69,12 @@
   
     my $result; 
   
  -  $self->log(8, "waiting for dnsbl dns");
  +  $self->log(LOGDEBUG, "waiting for dnsbl dns");
   
     # don't wait more than 8 seconds here
     my @ready = $sel->can_read(8);
   
  -  $self->log(8, "DONE waiting for dnsbl dns, got " , scalar @ready, " answers ...") ;
  +  $self->log(LOGDEBUG, "DONE waiting for dnsbl dns, got " , scalar @ready, " answers ...") ;
     return '' unless @ready;
   
     for my $socket (@ready) {
  @@ -91,9 +91,9 @@
   	my $name = $rr->name;
   	($dnsbl) = ($name =~ m/(?:\d+\.){4}(.*)/) unless $dnsbl;
   	$dnsbl = $name unless $dnsbl;
  -	$self->log(9, "name ", $rr->name);
  +	$self->log(LOGDEBUG, "name ", $rr->name);
   	next unless $rr->type eq "TXT";
  -	$self->log(10, "got txt record");
  +	$self->log(LOGDEBUG, "got txt record");
   	$result = $rr->txtdata and last;
         }
         #$a_record and $result = "Blocked by $dnsbl";
  @@ -110,7 +110,7 @@
         }
       }
       else {
  -      $self->log(4, "$dnsbl query failed: ", $res->errorstring)
  +      $self->log(LOGERROR, "$dnsbl query failed: ", $res->errorstring)
   	unless $res->errorstring eq "NXDOMAIN";
       }
   
  
  
  
  1.4       +3 -3      qpsmtpd/plugins/http_config
  
  Index: http_config
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/plugins/http_config,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -w -r1.3 -r1.4
  --- http_config	15 Sep 2003 10:50:27 -0000	1.3
  +++ http_config	5 Mar 2004 12:46:24 -0000	1.4
  @@ -36,14 +36,14 @@
   
   sub http_config {
     my ($self, $transaction, $config) = @_; 
  -  $self->log(0, "http_config called with $config");
  +  $self->log(LOGNOTICE, "http_config called with $config");
     for my $url (@urls) {
  -    $self->log(10, "http_config loading from $url");
  +    $self->log(LOGDEBUG, "http_config loading from $url");
       my @config = split /[\r\n]+/, (get "$url$config" || "");
       chomp @config;
       @config = grep { $_ and $_ !~ m/^\s*#/ and $_ =~ m/\S/ } @config;
       close CF;
  -    # $self->log(0, "returning http_config for $config ",Data::Dumper->Dump([\@config], [qw(config)]));
  +    # $self->log(LOGNOTICE, "returning http_config for $config ",Data::Dumper->Dump([\@config], [qw(config)]));
       return (OK, @config) if @config;
     }
     return DECLINED;
  
  
  
  1.3       +9 -9      qpsmtpd/plugins/milter
  
  Index: milter
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/plugins/milter,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -w -r1.2 -r1.3
  --- milter	10 Nov 2003 08:06:00 -0000	1.2
  +++ milter	5 Mar 2004 12:46:24 -0000	1.3
  @@ -66,7 +66,7 @@
       my ($self, $transaction, $where, @results) = @_;
       foreach my $result (@results) {
           next if $result->{action} eq 'continue';
  -        $self->log(1, "milter $self->{name} result action: $result->{action}");
  +        $self->log(LOGINFO, "milter $self->{name} result action: $result->{action}");
           if ($result->{action} eq 'reject') {
               die("Rejected at $where by $self->{name} milter ($result->{explanation})");
           }
  @@ -96,7 +96,7 @@
   sub connect_handler {
       my ($self, $transaction) = @_;
       
  -    $self->log(1, "milter $self->{name} opening connection to milter backend");
  +    $self->log(LOGDEBUG, "milter $self->{name} opening connection to milter backend");
       my $milter = Net::Milter->new();
       $milter->open($self->{host}, $self->{port}, 'tcp');
       $milter->protocol_negotiation();
  @@ -105,7 +105,7 @@
       
       my $remote_ip = $self->qp->connection->remote_ip;
       my $remote_host = $self->qp->connection->remote_host;
  -    $self->log(1, "milter $self->{name} checking connect from $remote_host\[$remote_ip\]");
  +    $self->log(LOGDEBUG, "milter $self->{name} checking connect from $remote_host\[$remote_ip\]");
       
       eval {
           $self->check_results($transaction, "connection",
  @@ -128,7 +128,7 @@
       my $helo = $self->qp->connection->hello;
       my $host = $self->qp->connection->hello_host;
   
  -    $self->log(1, "milter $self->{name} checking HELO $host");
  +    $self->log(LOGDEBUG, "milter $self->{name} checking HELO $host");
       
       eval { $self->check_results($transaction, "HELO",
                                   $milter->send_helo($host)) };
  @@ -142,7 +142,7 @@
       
       my $milter = $self->qp->connection->notes('milter');
   
  -    $self->log(1, "milter $self->{name} checking MAIL FROM " . $address->format);
  +    $self->log(LOGDEBUG, "milter $self->{name} checking MAIL FROM " . $address->format);
       eval { $self->check_results($transaction, "MAIL FROM",
                                   $milter->send_mail_from($address->format)) };
       return(DENY, $@) if $@;
  @@ -155,7 +155,7 @@
       
       my $milter = $self->qp->connection->notes('milter');
   
  -    $self->log(1, "milter $self->{name} checking RCPT TO " . $address->format);
  +    $self->log(LOGDEBUG, "milter $self->{name} checking RCPT TO " . $address->format);
   
       eval { $self->check_results($transaction, "RCPT TO",
                                   $milter->send_rcpt_to($address->format)) };
  @@ -169,7 +169,7 @@
   
       my $milter = $self->qp->connection->notes('milter');
   
  -    $self->log(1, "milter $self->{name} checking headers");
  +    $self->log(LOGDEBUG, "milter $self->{name} checking headers");
   
       my $headers = $transaction->header(); # Mail::Header object
       foreach my $h ($headers->tags) {
  @@ -177,7 +177,7 @@
           $h =~ s/\b(\w)/\U$1/g;
           $h =~ s/\bid\b/ID/g;
           foreach my $val ($headers->get($h)) {
  -            # $self->log(1, "milter $self->{name} checking header: $h: $val");
  +            # $self->log(LOGDEBUG, "milter $self->{name} checking header: $h: $val");
               eval { $self->check_results($transaction, "header $h",
                                   $milter->send_header($h, $val)) };
               return(DENY, $@) if $@;
  @@ -197,7 +197,7 @@
           last unless length($line);
       }
   
  -    $self->log(1, "milter $self->{name} checking body");
  +    $self->log(LOGDEBUG, "milter $self->{name} checking body");
   
       my $data = '';
       while (my $line = $transaction->body_getline) {
  
  
  
  1.4       +1 -1      qpsmtpd/plugins/rhsbl
  
  Index: rhsbl
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/plugins/rhsbl,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -w -r1.3 -r1.4
  --- rhsbl	8 Sep 2002 14:15:21 -0000	1.3
  +++ rhsbl	5 Mar 2004 12:46:24 -0000	1.4
  @@ -34,7 +34,7 @@
   sub check_rhsbl {
     my ($self, $rhsbl, $host) = @_;
     return 0 unless $host;
  -  $self->log(2, "checking $host in $rhsbl");
  +  $self->log(LOGDEBUG, "checking $host in $rhsbl");
     return 1 if ((gethostbyname("$host.$rhsbl"))[4]);
     return 0;
   }
  
  
  
  1.7       +2 -2      qpsmtpd/plugins/sender_permitted_from
  
  Index: sender_permitted_from
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/plugins/sender_permitted_from,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -w -r1.6 -r1.7
  --- sender_permitted_from	3 Feb 2004 02:57:04 -0000	1.6
  +++ sender_permitted_from	5 Mar 2004 12:46:24 -0000	1.7
  @@ -97,7 +97,7 @@
     }
   
     if ($result eq 'fail' or $result eq 'softfail') {
  -    $self->log(1, "result for $rcpt->address was $result: $comment");
  +    $self->log(LOGDEBUG, "result for $rcpt->address was $result: $comment");
     }
      
     return DECLINED;
  @@ -117,7 +117,7 @@
   
     my ($result, $smtp_comment, $comment) = $query->message_result2();
   
  -  $self->log(1, "result was $result: $comment") if ($result);
  +  $self->log(LOGDEBUG, "result was $result: $comment") if ($result);
   
     $transaction->header->add('Received-SPF' => "$result ($comment)", 0);
   
  
  
  
  1.8       +6 -6      qpsmtpd/plugins/spamassassin
  
  Index: spamassassin
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/plugins/spamassassin,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -w -r1.7 -r1.8
  --- spamassassin	5 Mar 2004 09:12:20 -0000	1.7
  +++ spamassassin	5 Mar 2004 12:46:24 -0000	1.8
  @@ -70,7 +70,7 @@
     my ($self, $qp, @args) = @_;
     $self->register_hook("data_post", "check_spam");
   
  -  $self->log(0, "Bad parameters for the spamassassin plugin")
  +  $self->log(LOGERROR, "Bad parameters for the spamassassin plugin")
       if @_ % 2;
   
     %{$self->{_args}} = @args;
  @@ -94,7 +94,7 @@
     if ($port =~ /\D/) { $port = getservbyname($port, 'tcp') }
     die "No port" unless $port;
     my $iaddr   = inet_aton($remote) or 
  -    $self->log(1, "Could not resolve host: $remote") and return (DECLINED);
  +    $self->log(LOGERROR, "Could not resolve host: $remote") and return (DECLINED);
     my $paddr   = sockaddr_in($port, $iaddr);
   
     my $proto   = getprotobyname('tcp');
  @@ -102,18 +102,18 @@
       my $spamd_socket = $1;
       
       socket(SPAMD, PF_UNIX, SOCK_STREAM, 0)
  -      or $self->log(1, "Could not open socket: $!") and return (DECLINED);
  +      or $self->log(LOGERROR, "Could not open socket: $!") and return (DECLINED);
   
       $paddr = sockaddr_un($spamd_socket); 
     }
     else {
       socket(SPAMD, PF_INET, SOCK_STREAM, $proto)
  -      or $self->log(1, "Could not open socket: $!") and return (DECLINED);
  +      or $self->log(LOGERROR, "Could not open socket: $!") and return (DECLINED);
     }
   
     connect(SPAMD, $paddr) 
  -    or $self->log(1, "Could not connect to spamassassin daemon: $!") and return DECLINED;
  -  $self->log(6, "check_spam: connected to spamd");
  +    or $self->log(LOGERROR, "Could not connect to spamassassin daemon: $!") and return DECLINED;
  +  $self->log(LOGDEBUG, "check_spam: connected to spamd");
   
     SPAMD->autoflush(1);
     
  
  
  
  1.6       +4 -3      qpsmtpd/plugins/queue/qmail-queue
  
  Index: qmail-queue
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/plugins/queue/qmail-queue,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -w -r1.5 -r1.6
  --- qmail-queue	9 Oct 2003 17:21:49 -0000	1.5
  +++ qmail-queue	5 Mar 2004 12:46:24 -0000	1.6
  @@ -26,7 +26,7 @@
   
     if (@args > 0) {
       $self->{_queue_exec} = $args[0];
  -    $self->log(1, "WARNING: Ignoring additional arguments.") if (@args > 1);
  +    $self->log(LOGWARN, "WARNING: Ignoring additional arguments.") if (@args > 1);
     }
     else {
       $self->{_queue_exec} = ($ENV{QMAIL} || '/var/qmail') . "/bin/qmail-queue";
  @@ -86,7 +86,8 @@
       if ($queue_exec =~ /^(\/[\/\-\_\.a-z0-9A-Z]*)$/) {
         $queue_exec = $1;
       } else {
  -      $self->log(1, "FATAL ERROR: Unexpected characters in qmail-queue plugin argument");
  +      $self->log(LOGERROR, "FATAL ERROR: Unexpected characters in qmail-queue plugin argument");
  +      # This exit is ok as we're exiting a forked child process.
         exit 3;
       }
   
  @@ -97,7 +98,7 @@
       POSIX::dup2(fileno(MESSAGE_READER), 0) or die "Unable to dup MESSAGE_READER: $!";
       POSIX::dup2(fileno(ENVELOPE_READER), 1) or die "Unable to dup ENVELOPE_READER: $!";
   
  -    $self->log(7, "Queuing to $queue_exec");
  +    $self->log(LOGNOTICE, "Queuing to $queue_exec");
   
       my $rc = exec $queue_exec;
   
  
  
  
  1.3       +3 -3      qpsmtpd/plugins/queue/smtp-forward
  
  Index: smtp-forward
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/plugins/queue/smtp-forward,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -w -r1.2 -r1.3
  --- smtp-forward	24 Jul 2003 12:44:19 -0000	1.2
  +++ smtp-forward	5 Mar 2004 12:46:24 -0000	1.3
  @@ -36,7 +36,7 @@
       if (@args > 1 and $args[1] =~ /^(\d+)$/) {
         $self->{_smtp_port} = $1;
       }
  -    $self->log(1, "WARNING: Ignoring additional arguments.") if (@args > 2);
  +    $self->log(LOGWARN, "WARNING: Ignoring additional arguments.") if (@args > 2);
     } else {
       die("No SMTP server specified in smtp-forward config");
     }
  @@ -46,7 +46,7 @@
   sub queue_handler {
     my ($self, $transaction) = @_;
   
  -  $self->log(1, "forwarding to $self->{_smtp_server}:$self->{_smtp_port}");
  +  $self->log(LOGINFO, "forwarding to $self->{_smtp_server}:$self->{_smtp_port}");
     my $smtp = Net::SMTP->new(
                               $self->{_smtp_server},
                               Port => $self->{_smtp_port},
  @@ -62,6 +62,6 @@
     }
     $smtp->dataend();
     $smtp->quit() or return(DECLINED, "Unable to queue message ($!)");
  -  $self->log(1, "finished queueing");
  +  $self->log(LOGINFO, "finished queueing");
     return (OK, "Queued!");
   }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.