cvs commit: qpsmtpd/plugins check_relay

[email protected] (Ask Bjoern Hansen)
Newsgroups perl.cvs.qpsmtpd
Message-ID <[email protected]>
Date: 25 Mar 2003 12:50:07 -0000
From: Ask Bjoern Hansen <[email protected]>
To: [email protected]
Subject: cvs commit: qpsmtpd/plugins check_relay

ask         03/03/25 04:50:07

   Modified:    .        Changes qpsmtpd
                lib      Qpsmtpd.pm
                plugins  check_relay
   Log:
     Support morercpthosts.cdb

     config now takes an extra "type" parameter.  If it's "map" then a
     reference to a tied hash will be returned.

   Revision  Changes    Path
   1.36      +8 -0      qpsmtpd/Changes

   Index: Changes
   ===================================================================
   RCS file: /cvs/public/qpsmtpd/Changes,v
   retrieving revision 1.35
   retrieving revision 1.36
   diff -u -w -r1.35 -r1.36
   --- Changes	18 Mar 2003 09:55:06 -0000	1.35
   +++ Changes	25 Mar 2003 12:50:07 -0000	1.36
   @@ -1,3 +1,11 @@
   +0.26-dev
   +
   +  Support morercpthosts.cdb
   +
   +  config now takes an extra "type" parameter.  If it's "map" then a
   +  reference to a tied hash will be returned.
   +
   +
    0.25 - 2003/03/18

      Use the proper RFC2822 date format in the Received headers. 
(Somehow



   1.15      +1 -1      qpsmtpd/qpsmtpd

   Index: qpsmtpd
   ===================================================================
   RCS file: /cvs/public/qpsmtpd/qpsmtpd,v
   retrieving revision 1.14
   retrieving revision 1.15
   diff -u -w -r1.14 -r1.15
   --- qpsmtpd	13 Oct 2002 01:05:40 -0000	1.14
   +++ qpsmtpd	25 Mar 2003 12:50:07 -0000	1.15
   @@ -1,4 +1,4 @@
   -#!/usr/bin/perl -Tw
   +#!/home/perl/bin/perl -Tw
    # Copyright (c) 2001 Ask Bjoern Hansen. See the LICENSE file for 
details.
    # The "command dispatch" system is taken from colobus - 
http://trainedmonkey.com/colobus/
    #



   1.18      +27 -6     qpsmtpd/lib/Qpsmtpd.pm

   Index: Qpsmtpd.pm
   ===================================================================
   RCS file: /cvs/public/qpsmtpd/lib/Qpsmtpd.pm,v
   retrieving revision 1.17
   retrieving revision 1.18
   diff -u -w -r1.17 -r1.18
   --- Qpsmtpd.pm	18 Mar 2003 10:02:12 -0000	1.17
   +++ Qpsmtpd.pm	25 Mar 2003 12:50:07 -0000	1.18
   @@ -1,7 +1,7 @@
    package Qpsmtpd;
    use strict;

   -$Qpsmtpd::VERSION = "0.25";
   +$Qpsmtpd::VERSION = "0.26-dev";
    sub TRACE_LEVEL { 6 }

    use Sys::Hostname;
   @@ -24,7 +24,7 @@
    # database or whatever.
    #
    sub config {
   -  my ($self, $c) = @_;
   +  my ($self, $c, $type) = @_;

      #warn "SELF->config($c) ", ref $self;

   @@ -37,18 +37,18 @@
      @config = () unless $rc == OK;

      if (wantarray) {
   -      @config = $self->get_qmail_config($c) unless @config;
   +      @config = $self->get_qmail_config($c, $type) unless @config;
          @config = @{$defaults{$c}} if (!@config and $defaults{$c});
          return @config;
      }
      else {
   -      return ($config[0] || $self->get_qmail_config($c) || 
$defaults{$c});
   +      return ($config[0] || $self->get_qmail_config($c, $type) || 
$defaults{$c});
       }
    }


    sub get_qmail_config {
   -  my ($self, $config) = (shift, shift);
   +  my ($self, $config, $type) = @_;
      $self->log(8, "trying to get config for $config");
      if ($self->{_config_cache}->{$config}) {
        return wantarray ? @{$self->{_config_cache}->{$config}} : 
$self->{_config_cache}->{$config}->[0];
   @@ -56,7 +56,28 @@
      my $configdir = '/var/qmail/control';
      my ($name) = ($0 =~ m!(.*?)/([^/]+)$!);
      $configdir = "$name/config" if (-e "$name/config/$config");
   -  open CF, "<$configdir/$config" or warn "$$ could not open 
configfile $config: $!", return;
   +
   +  my $configfile = "$configdir/$config";
   +
   +  if ($type and $type eq "map")  {
   +    warn "MAP!";
   +    return +{} unless -e $configfile;
   +    eval { require CDB_File };
   +
   +    if ($@) {
   +      $self->log(0, "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;
   +    }
   +    #warn Data::Dumper->Dump([\%h], [qw(h)]);
   +    # should we cache this?
   +    return \%h;
   +  }
   +
   +  open CF, "<$configfile" or warn "$$ could not open configfile 
$configfile: $!", return;
      my @config = <CF>;
      chomp @config;
      @config = grep { $_ and $_ !~ m/^\s*#/ and $_ =~ m/\S/} @config;



   1.4       +4 -0      qpsmtpd/plugins/check_relay

   Index: check_relay
   ===================================================================
   RCS file: /cvs/public/qpsmtpd/plugins/check_relay,v
   retrieving revision 1.3
   retrieving revision 1.4
   diff -u -w -r1.3 -r1.4
   --- check_relay	20 Jan 2003 11:03:15 -0000	1.3
   +++ check_relay	25 Mar 2003 12:50:07 -0000	1.4
   @@ -28,5 +28,9 @@
        return (OK) if $host eq lc $allowed;
        return (OK) if substr($allowed,0,1) eq "." and $host =~ 
m/\Q$allowed\E$/i;
      }
   +
   +  my $more_rcpt_hosts = $self->qp->config('morercpthosts', 'map');
   +  return (OK) if exists $more_rcpt_hosts->{$host};
   +
      return (DENY);
    }





-- 
http://www.askbjoernhansen.com/
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.