qmail-queue: a few tweaks and a lot of whitespace

This commit is contained in:
Matt Simerson 2012-06-23 00:57:04 -04:00
parent 6afcc54f4b
commit 8c3377f026

View File

@ -20,6 +20,11 @@ If set the environment variable QMAILQUEUE overrides this setting.
=cut =cut
use strict;
use warnings;
use Qpsmtpd::Constants;
use POSIX (); use POSIX ();
sub register { sub register {
@ -27,12 +32,10 @@ sub register {
if (@args > 0) { if (@args > 0) {
$self->{_queue_exec} = $args[0]; $self->{_queue_exec} = $args[0];
$self->log(LOGWARN, "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";
} }
$self->{_queue_exec} ||= ($ENV{QMAIL} || '/var/qmail') . "/bin/qmail-queue";
$self->{_queue_exec} = $ENV{QMAILQUEUE} if $ENV{QMAILQUEUE}; $self->{_queue_exec} = $ENV{QMAILQUEUE} if $ENV{QMAILQUEUE};
} }
@ -40,22 +43,22 @@ sub hook_queue {
my ($self, $transaction) = @_; my ($self, $transaction) = @_;
# these bits inspired by Peter Samuels "qmail-queue wrapper" # these bits inspired by Peter Samuels "qmail-queue wrapper"
pipe(MESSAGE_READER, MESSAGE_WRITER) or die("Could not create message pipe"); pipe(MESSAGE_READER, MESSAGE_WRITER) or die "Could not create message pipe";
pipe(ENVELOPE_READER, ENVELOPE_WRITER) or die("Could not create envelope pipe"); pipe(ENVELOPE_READER, ENVELOPE_WRITER) or die "Could not create envelope pipe";
local $SIG{PIPE} = sub { die "SIGPIPE" }; local $SIG{PIPE} = sub { die 'SIGPIPE' };
my $child = fork(); my $child = fork();
not defined $child and die("Could not fork"); ! defined $child and die "Could not fork";
if ($child) { if ($child) {
# Parent # Parent
my $oldfh = select(MESSAGE_WRITER); $| = 1; my $oldfh = select MESSAGE_WRITER; $| = 1;
select(ENVELOPE_WRITER); $| = 1; select ENVELOPE_WRITER; $| = 1;
select($oldfh); select $oldfh;
close MESSAGE_READER or die("close msg reader fault"); close MESSAGE_READER or die "close msg reader fault";
close ENVELOPE_READER or die("close envelope reader fault"); close ENVELOPE_READER or die "close envelope reader fault";
$transaction->header->print(\*MESSAGE_WRITER); $transaction->header->print(\*MESSAGE_WRITER);
$transaction->body_resetpos; $transaction->body_resetpos;
@ -102,7 +105,7 @@ sub hook_queue {
POSIX::dup2(fileno(ENVELOPE_READER), 1) or die "Unable to dup ENVELOPE_READER: $!"; POSIX::dup2(fileno(ENVELOPE_READER), 1) or die "Unable to dup ENVELOPE_READER: $!";
my $ppid = getppid(); my $ppid = getppid();
$self->log(LOGNOTICE, "(for $ppid ) Queuing qp $$ to $queue_exec"); $self->log(LOGNOTICE, "(for $ppid) Queuing to $queue_exec");
my $rc = exec $queue_exec; my $rc = exec $queue_exec;