From 3837fabc9fbfa2c583ade30c3c779a8abf6f6c37 Mon Sep 17 00:00:00 2001 From: John Peacock Date: Thu, 14 Sep 2006 19:48:37 +0000 Subject: [PATCH] Ask and ye shall receive git-svn-id: https://svn.perl.org/qpsmtpd/branches/0.3x@659 958fd67b-6ff1-0310-b445-bb7760255be9 --- Changes | 1 + lib/Qpsmtpd/TcpServer/Prefork.pm | 2 +- plugins/auth/auth_vpopmail_sql | 2 +- plugins/count_unrecognized_commands | 7 +++++- plugins/relay_only | 35 +++++++++++++++++++++++++++++ qpsmtpd-prefork | 6 +++-- 6 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 plugins/relay_only diff --git a/Changes b/Changes index 469de24..3838f9c 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,5 @@ 0.33 + relay_only plugin for smart relay host. (John Peacock) Experimental IPv6 support (forkserver only). (Mike Williams) diff --git a/lib/Qpsmtpd/TcpServer/Prefork.pm b/lib/Qpsmtpd/TcpServer/Prefork.pm index 67bc7ad..1351266 100644 --- a/lib/Qpsmtpd/TcpServer/Prefork.pm +++ b/lib/Qpsmtpd/TcpServer/Prefork.pm @@ -30,7 +30,7 @@ sub read_input { $_ =~ 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; } diff --git a/plugins/auth/auth_vpopmail_sql b/plugins/auth/auth_vpopmail_sql index 8f07479..7c8626d 100644 --- a/plugins/auth/auth_vpopmail_sql +++ b/plugins/auth/auth_vpopmail_sql @@ -65,7 +65,7 @@ sub authsql { my $connect = "dbi:mysql:dbname=vpopmail"; my $dbuser = "vpopmailuser"; - my $dbpasswd = "**********"; + my $dbpasswd = "vpoppasswd"; my $dbh = DBI->connect( $connect, $dbuser, $dbpasswd ); $dbh->{ShowErrorStatement} = 1; diff --git a/plugins/count_unrecognized_commands b/plugins/count_unrecognized_commands index d369307..92110e2 100644 --- a/plugins/count_unrecognized_commands +++ b/plugins/count_unrecognized_commands @@ -25,8 +25,13 @@ sub register { $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 --git a/plugins/relay_only b/plugins/relay_only new file mode 100644 index 0000000..a25fc52 --- /dev/null +++ b/plugins/relay_only @@ -0,0 +1,35 @@ +#!/usr/bin/perl -w +=head1 NAME + +relay_only - this plugin only permits relaying + +=head1 SYNOPSIS + +# in config/plugins + +check_relay + +relay_only + +# other rcpt hooks go here + +=head1 DESCRIPTION + +This plugin can be used for the case where a server is used as the smart +relay host for internal users and external/authenticated users, but should +not be considered a normal inbound MX server + +It should be configured to be run _AFTER_ check_relay and before other +RCPT hooks! Only clients that have authenticated or are listed in the +relayclient file will be allowed to send mail. + +=cut + +sub hook_rcpt { + if ( shift->qp->connection->relay_client ) { + return (OK); + } + else { + return (DENY); + } +} diff --git a/qpsmtpd-prefork b/qpsmtpd-prefork index 5c8fcaa..6814091 100755 --- a/qpsmtpd-prefork +++ b/qpsmtpd-prefork @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/perl -Tw # High performance pre-forking qpsmtpd daemon, Copyright (C) 2006 SoftScan # http://www.softscan.co.uk # @@ -96,6 +96,8 @@ GetOptions( '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 +338,7 @@ sub new_child { # 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