Author: vetinari
Date: Sat Oct 27 02:05:04 2007
New Revision: 812
Modified:
trunk/lib/Qpsmtpd/Postfix.pm
trunk/plugins/queue/postfix-queue
Log:
Fix issue #23, reported w/ patch by [EMAIL PROTECTED]
Modified: trunk/lib/Qpsmtpd/Postfix.pm
==============================================================================
--- trunk/lib/Qpsmtpd/Postfix.pm (original)
+++ trunk/lib/Qpsmtpd/Postfix.pm Sat Oct 27 02:05:04 2007
@@ -90,10 +90,14 @@
}
sub open_cleanup {
- my ($class) = @_;
+ my ($class, $socket) = @_;
+
+ $socket = "/var/spool/postfix/public/cleanup"
+ unless defined $socket;
+
my $self = IO::Socket::UNIX->new(Type => SOCK_STREAM,
- Peer => "/var/spool/postfix/public/cleanup");
- die qq[Couldn't open unix socket "/var/spool/postfix/public/cleanup": $!]
unless ref $self;
+ Peer => $socket);
+ die qq(Couldn't open unix socket "$socket": $!) unless ref $self;
# allow buffered writes
$self->autoflush(0);
bless ($self, $class);
@@ -159,7 +163,7 @@
sub inject_mail {
my ($class, $transaction) = @_;
- my $strm = $class->open_cleanup();
+ my $strm = $class->open_cleanup($transaction->notes('postfix-queue-socket'));
my %at = $strm->get_attr;
my $qid = $at{queue_id};
Modified: trunk/plugins/queue/postfix-queue
==============================================================================
--- trunk/plugins/queue/postfix-queue (original)
+++ trunk/plugins/queue/postfix-queue Sat Oct 27 02:05:04 2007
@@ -128,8 +128,10 @@
."v$postfix_version");
$self->{_queue_flags} = 0;
if (@args > 0) {
- if ($args[0] =~ m#^/#) {
- $self->{_queue_socket} = shift @args;
+ if ($args[0] =~ m#^(/.+)#) {
+ # untaint socket path
+ $self->{_queue_socket} = $1;
+ shift @args;
}
else {
$self->{_queue_socket} = "/var/spool/postfix/public/cleanup";
@@ -157,6 +159,7 @@
sub hook_queue {
my ($self, $transaction) = @_;
$transaction->notes('postfix-queue-flags', $self->{_queue_flags});
+ $transaction->notes('postfix-queue-socket', $self->{_queue_socket});
# $self->log(LOGDEBUG,
"queue-flags=".$transaction->notes('postfix-queue-flags'));
my ($status, $qid, $reason) = Qpsmtpd::Postfix->inject_mail($transaction);