From 569ea2a5120d69c9de089060268918518761aeb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ask=20Bj=C3=B8rn=20Hansen?= Date: Mon, 5 May 2008 17:05:38 +0000 Subject: [PATCH] s/txn/transaction/ and perltidy cleanup (Steve Kemp) git-svn-id: https://svn.perl.org/qpsmtpd/trunk@885 958fd67b-6ff1-0310-b445-bb7760255be9 --- plugins/async/check_earlytalker | 8 ++++---- plugins/check_earlytalker | 10 +++++----- plugins/logging/file | 30 +++++++++++++++--------------- plugins/logging/syslog | 6 +++--- plugins/queue/exim-bsmtp | 14 +++++++------- plugins/uribl | 14 +++++++------- 6 files changed, 41 insertions(+), 41 deletions(-) diff --git a/plugins/async/check_earlytalker b/plugins/async/check_earlytalker index eb5b0e3..b5c4038 100644 --- a/plugins/async/check_earlytalker +++ b/plugins/async/check_earlytalker @@ -87,7 +87,7 @@ sub register { sub check_talker_poll { my ($self, $transaction) = @_; - + my $qp = $self->qp; my $conn = $qp->connection; my $check_until = time + $self->{_args}{'wait'}; @@ -97,7 +97,7 @@ sub check_talker_poll { sub read_now { my ($qp, $conn, $until, $phase) = @_; - + if ($qp->has_data) { $qp->log(LOGNOTICE, 'remote host started talking after $phase before we responded'); $qp->clear_data if $phase eq 'data'; @@ -115,7 +115,7 @@ sub read_now { sub check_talker_post { my ($self, $transaction) = @_; - + my $conn = $self->qp->connection; return DECLINED unless $conn->notes('earlytalker'); return DECLINED if $self->{'defer-reject'}; @@ -125,7 +125,7 @@ sub check_talker_post { } sub hook_mail { - my ($self, $txn) = @_; + my ($self, $transaction) = @_; return DECLINED unless $self->connection->notes('earlytalker'); return (DENY,$MSG) if $self->{_args}->{'action'} eq 'deny'; diff --git a/plugins/check_earlytalker b/plugins/check_earlytalker index cae606c..af585e9 100644 --- a/plugins/check_earlytalker +++ b/plugins/check_earlytalker @@ -102,7 +102,7 @@ sub register { sub apr_connect_handler { my ($self, $transaction) = @_; - + return DECLINED unless $self->{_args}{'check-at'}{CONNECT}; return DECLINED if ($self->qp->connection->notes('whitelistclient')); my $ip = $self->qp->connection->remote_ip; @@ -110,7 +110,7 @@ sub apr_connect_handler { my $c = $self->qp->{conn}; my $socket = $c->client_socket; my $timeout = $self->{_args}->{'wait'} * 1_000_000; - + my $rc = $socket->poll($c->pool, $timeout, APR::Const::POLLIN()); if ($rc == APR::Const::SUCCESS()) { $self->log(LOGNOTICE, "remote host started talking before we said hello [$ip]"); @@ -130,7 +130,7 @@ sub apr_connect_handler { sub apr_data_handler { my ($self, $transaction) = @_; - + return DECLINED unless $self->{_args}{'check-at'}{DATA}; return DECLINED if ($self->qp->connection->notes('whitelistclient')); my $ip = $self->qp->connection->remote_ip; @@ -138,7 +138,7 @@ sub apr_data_handler { my $c = $self->qp->{conn}; my $socket = $c->client_socket; my $timeout = $self->{_args}->{'wait'} * 1_000_000; - + my $rc = $socket->poll($c->pool, $timeout, APR::Const::POLLIN()); if ($rc == APR::Const::SUCCESS()) { $self->log(LOGNOTICE, "remote host started talking before we said hello [$ip]"); @@ -199,7 +199,7 @@ sub data_handler { } sub mail_handler { - my ($self, $txn) = @_; + my ($self, $transaction) = @_; my $msg = 'Connecting host started transmitting before SMTP greeting'; return DECLINED unless $self->qp->connection->notes('earlytalker'); diff --git a/plugins/logging/file b/plugins/logging/file index a6c445e..31292ad 100644 --- a/plugins/logging/file +++ b/plugins/logging/file @@ -183,9 +183,9 @@ sub register { } sub log_output { - my ($self, $txn) = @_; + my ($self, $transaction) = @_; my $output = $self->{_log_format}; - $output =~ s/%i/($txn->notes('logging-session-id') || 'parent')/ge; + $output =~ s/%i/($transaction->notes('logging-session-id') || 'parent')/ge; $output = strftime $output, localtime; $output; } @@ -216,28 +216,28 @@ sub open_log { # # Returns true if the file was reopened, zero if not, undef on error. sub maybe_reopen { - my ($self, $txn) = @_; + my ($self, $transaction) = @_; - my $new_output = $self->log_output($txn); + my $new_output = $self->log_output($transaction); if (!$self->{_current_output} || $self->{_current_output} ne $new_output || ($self->{_reopen} && - !$txn->notes('file-reopened-this-session'))) { - unless ($self->open_log($new_output, $txn)) { + !$transaction->notes('file-reopened-this-session'))) { + unless ($self->open_log($new_output, $transaction)) { return undef; } - $txn->notes('file-reopened-this-session', 1); + $transaction->notes('file-reopened-this-session', 1); return 1; } return 0; } sub hook_connect { - my ($self, $txn) = @_; + my ($self, $transaction) = @_; - $txn->notes('file-logged-this-session', 0); - $txn->notes('file-reopened-this-session', 0); - $txn->notes('logging-session-id', + $transaction->notes('file-logged-this-session', 0); + $transaction->notes('file-reopened-this-session', 0); + $transaction->notes('logging-session-id', sprintf("%08d-%04d-%d", scalar time, $$, ++$self->{_session_counter})); return DECLINED; @@ -253,7 +253,7 @@ sub hook_disconnect { } sub hook_logging { - my ($self, $txn, $trace, $hook, $plugin, @log) = @_; + my ($self, $transaction, $trace, $hook, $plugin, @log) = @_; return DECLINED if !defined $self->{_loglevel} or $trace > $self->{_loglevel}; @@ -265,11 +265,11 @@ sub hook_logging { # - We haven't logged anything yet this session if (!$self->{_f} || !$self->{_nosplit} || - !$txn->notes('file-logged-this-session')) { - unless (defined $self->maybe_reopen($txn)) { + !$transaction->notes('file-logged-this-session')) { + unless (defined $self->maybe_reopen($transaction)) { return DECLINED; } - $txn->notes('file-logged-this-session', 1); + $transaction->notes('file-logged-this-session', 1); } my $f = $self->{_f}; diff --git a/plugins/logging/syslog b/plugins/logging/syslog index 6ea90b6..864314f 100644 --- a/plugins/logging/syslog +++ b/plugins/logging/syslog @@ -61,7 +61,7 @@ Normally, log messages will be mapped from the above log levels into the syslog(3) log levels of their corresponding names. This will cause various messages to appear or not in syslog outputs according to your syslogd configuration (typically /etc/syslog.conf). However, if the B -setting is used, all messages will be logged at that priority regardless of +setting is used, all messages will be logged at that priority regardless of what the original priority might have been. =item B @@ -141,7 +141,7 @@ sub register { $self->{_priority} = $1; } } - + if ($args{ident} && $args{ident} =~ /^([\w\-.]+)$/) { $ident = $1; } @@ -172,7 +172,7 @@ my %priorities_ = ( ); sub hook_logging { - my ($self, $txn, $trace, $hook, $plugin, @log) = @_; + my ($self, $transaction, $trace, $hook, $plugin, @log) = @_; return DECLINED if $trace > $self->{_loglevel}; return DECLINED if defined $plugin and $plugin eq $self->plugin_name; diff --git a/plugins/queue/exim-bsmtp b/plugins/queue/exim-bsmtp index 1168ffb..d25644f 100644 --- a/plugins/queue/exim-bsmtp +++ b/plugins/queue/exim-bsmtp @@ -78,7 +78,7 @@ sub register { } sub hook_queue { - my ($self, $txn) = @_; + my ($self, $transaction) = @_; my $tmp_dir = $self->qp->config('spool_dir') || '/tmp'; $tmp_dir = $1 if ($tmp_dir =~ /(.*)/); @@ -89,12 +89,12 @@ sub hook_queue { } print $tmp "HELO ", hostname(), "\n", - "MAIL FROM:<", ($txn->sender->address || ''), ">\n"; + "MAIL FROM:<", ($transaction->sender->address || ''), ">\n"; print $tmp "RCPT TO:<", ($_->address || ''), ">\n" - for $txn->recipients; - print $tmp "DATA\n", $txn->header->as_string; - $txn->body_resetpos; - while (my $line = $txn->body_getline) { + for $transaction->recipients; + print $tmp "DATA\n", $transaction->header->as_string; + $transaction->body_resetpos; + while (my $line = $transaction->body_getline) { $line =~ s/^\./../; print $tmp $line; } @@ -107,7 +107,7 @@ sub hook_queue { unless ($exim) { $self->log(LOGERROR, "Could not execute $self->{_exim_path}: $!"); unlink $tmpfn or $self->log(LOGERROR, "unlink: $tmpfn: $!"); - return (DECLINED, "Internal error enqueuing mail"); + return (DECLINED, "Internal error enqueuing mail"); } # Normally exim produces no output in BSMTP mode; anything that # does come out is an error worth logging. diff --git a/plugins/uribl b/plugins/uribl index 997847d..323834d 100644 --- a/plugins/uribl +++ b/plugins/uribl @@ -215,7 +215,7 @@ sub send_query { if (defined $s1) { $self->{sockets}->{$z}->{$name}->{'txt'} = $s1; $self->{socket_select}->add($s1); - $self->{socket_idx}->{"$s1"} = + $self->{socket_idx}->{"$s1"} = $self->{socket_idx}->{"$s1"} = $index; $count++; } else { @@ -251,18 +251,18 @@ sub evaluate { } sub data_handler { - my ($self, $txn) = @_; + my ($self, $transaction) = @_; my $l; my $queries = 0; my %pending; my @qp_continuations; - $txn->body_resetpos; - while ($self->{check_headers} and $l = $txn->body_getline) { + $transaction->body_resetpos; + while ($self->{check_headers} and $l = $transaction->body_getline) { chomp $l; last if !$l; } - while ($l = $txn->body_getline) { + while ($l = $transaction->body_getline) { chomp $l; if ($l =~ /(.*)=$/) { @@ -378,7 +378,7 @@ sub data_handler { } } } - $txn->body_resetpos; + $transaction->body_resetpos; unless ($queries) { $self->log(LOGINFO, "No URIs found in mail"); @@ -448,7 +448,7 @@ sub data_handler { for (@matches) { $self->log(LOGWARN, $_->{desc}); if ($_->{action} eq 'add-header') { - $txn->header->add('X-URIBL-Match', $_->{desc}); + $transaction->header->add('X-URIBL-Match', $_->{desc}); } elsif ($_->{action} eq 'deny') { return (DENY, $_->{desc}); } elsif ($_->{action} eq 'denysoft') {