Fix issue #23, reported w/ patch by ulr...@topfen.net

git-svn-id: https://svn.perl.org/qpsmtpd/trunk@812 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Hanno Hecker 2007-10-27 09:05:04 +00:00
parent 85f0d91037
commit aa8ae14367
2 changed files with 13 additions and 6 deletions

View File

@ -90,10 +90,14 @@ sub print_rec_time {
} }
sub open_cleanup { 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, my $self = IO::Socket::UNIX->new(Type => SOCK_STREAM,
Peer => "/var/spool/postfix/public/cleanup"); Peer => $socket);
die qq[Couldn't open unix socket "/var/spool/postfix/public/cleanup": $!] unless ref $self; die qq(Couldn't open unix socket "$socket": $!) unless ref $self;
# allow buffered writes # allow buffered writes
$self->autoflush(0); $self->autoflush(0);
bless ($self, $class); bless ($self, $class);
@ -159,7 +163,7 @@ $transaction is supposed to be a Qpsmtpd::Transaction object.
sub inject_mail { sub inject_mail {
my ($class, $transaction) = @_; my ($class, $transaction) = @_;
my $strm = $class->open_cleanup(); my $strm = $class->open_cleanup($transaction->notes('postfix-queue-socket'));
my %at = $strm->get_attr; my %at = $strm->get_attr;
my $qid = $at{queue_id}; my $qid = $at{queue_id};

View File

@ -128,8 +128,10 @@ sub register {
."v$postfix_version"); ."v$postfix_version");
$self->{_queue_flags} = 0; $self->{_queue_flags} = 0;
if (@args > 0) { if (@args > 0) {
if ($args[0] =~ m#^/#) { if ($args[0] =~ m#^(/.+)#) {
$self->{_queue_socket} = shift @args; # untaint socket path
$self->{_queue_socket} = $1;
shift @args;
} }
else { else {
$self->{_queue_socket} = "/var/spool/postfix/public/cleanup"; $self->{_queue_socket} = "/var/spool/postfix/public/cleanup";
@ -157,6 +159,7 @@ sub register {
sub hook_queue { sub hook_queue {
my ($self, $transaction) = @_; my ($self, $transaction) = @_;
$transaction->notes('postfix-queue-flags', $self->{_queue_flags}); $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')); # $self->log(LOGDEBUG, "queue-flags=".$transaction->notes('postfix-queue-flags'));
my ($status, $qid, $reason) = Qpsmtpd::Postfix->inject_mail($transaction); my ($status, $qid, $reason) = Qpsmtpd::Postfix->inject_mail($transaction);