dbaa9dbd6c
on files in plugins dir: fixed a number of POD errors formatted some # comments into POD removed bare 1; (these are plugins, not perl modules) most instances of this were copy/pasted from a previous plugin that had it removed instances of # vim ts=N ... they weren't consistent, many didn't match .perltidyrc on modules that failed perl -c tests, added 'use Qpsmtpd::Constants;' Conflicts: plugins/async/check_earlytalker plugins/async/dns_whitelist_soft plugins/async/dnsbl plugins/async/queue/smtp-forward plugins/async/require_resolvable_fromhost plugins/async/rhsbl plugins/async/uribl plugins/auth/auth_checkpassword plugins/auth/auth_cvm_unix_local plugins/auth/auth_flat_file plugins/auth/auth_ldap_bind plugins/auth/auth_vpopmail plugins/auth/auth_vpopmail_sql plugins/auth/authdeny plugins/check_badmailfromto plugins/check_badrcptto_patterns plugins/check_bogus_bounce plugins/check_earlytalker plugins/check_norelay plugins/check_spamhelo plugins/connection_time plugins/dns_whitelist_soft plugins/dnsbl plugins/domainkeys plugins/greylisting plugins/hosts_allow plugins/http_config plugins/logging/adaptive plugins/logging/apache plugins/logging/connection_id plugins/logging/transaction_id plugins/logging/warn plugins/milter plugins/queue/exim-bsmtp plugins/queue/maildir plugins/queue/postfix-queue plugins/queue/smtp-forward plugins/quit_fortune plugins/random_error plugins/rcpt_map plugins/rcpt_regexp plugins/relay_only plugins/require_resolvable_fromhost plugins/rhsbl plugins/sender_permitted_from plugins/spamassassin plugins/tls plugins/tls_cert plugins/uribl plugins/virus/aveclient plugins/virus/bitdefender plugins/virus/clamav plugins/virus/clamdscan plugins/virus/hbedv plugins/virus/kavscanner plugins/virus/klez_filter plugins/virus/sophie plugins/virus/uvscan
114 lines
3.0 KiB
Perl
114 lines
3.0 KiB
Perl
#!perl -Tw
|
|
|
|
=head1 NAME
|
|
|
|
logging/apache - logging plugin for qpsmtpd which logs to the apache error log
|
|
|
|
=cut
|
|
|
|
# more POD at the end
|
|
|
|
use strict;
|
|
use warnings FATAL => 'all';
|
|
use Apache2::Log;
|
|
use Apache2::RequestUtil ();
|
|
|
|
use Qpsmtpd::Constants;
|
|
|
|
sub register {
|
|
my ($self, $qp) = @_;
|
|
|
|
die "Not running under Apache::Qpsmtpd"
|
|
unless ($qp->{conn} && $qp->{conn}->isa('Apache2::Connection'));
|
|
|
|
my $rr = Apache2::RequestRec->new($self->qp->{conn});
|
|
$self->{_log} = $rr->log
|
|
if $rr;
|
|
|
|
$self->log(LOGINFO, 'Initializing logging::apache plugin');
|
|
}
|
|
|
|
sub hook_logging {
|
|
my ($self, $transaction, $trace, $hook, $plugin, @log) = @_;
|
|
|
|
# Don't log your own log entries! If this is the only logging plugin
|
|
# then these lines will not be logged at all. You can safely comment
|
|
# out this line and it will not cause an infinite loop.
|
|
return DECLINED if defined $plugin and $plugin eq $self->plugin_name;
|
|
|
|
unless ($self->{_log}) {
|
|
my $rr = Apache2::RequestRec->new($self->qp->{conn});
|
|
unless ($rr) {
|
|
warn "no Apache2::RequestRec?... logmsg was: ", join(" ", @log);
|
|
return DECLINED;
|
|
}
|
|
$self->{_log} = $rr->log;
|
|
}
|
|
|
|
# luckily apache uses the same log levels as qpsmtpd...
|
|
($trace = lc Qpsmtpd::Constants::log_level($trace)) =~ s/^log//;
|
|
$trace = 'emerg' # ... well, nearly...
|
|
if $trace eq 'radar';
|
|
|
|
my $log = $self->{_log};
|
|
unless ($log->can($trace)) { # ... but you never know if it changes
|
|
$log->emerg("Can't log with level '$trace', logmsg was: ",
|
|
join(" ", @log));
|
|
return DECLINED;
|
|
}
|
|
|
|
$log->$trace(
|
|
join(
|
|
" ",
|
|
$$
|
|
. (
|
|
defined $plugin ? " $plugin plugin:"
|
|
: defined $hook ? " running plugin ($hook):"
|
|
: ""
|
|
),
|
|
@log
|
|
)
|
|
); # no \n at the end!
|
|
|
|
return DECLINED;
|
|
}
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
The logging/apache plugin uses the apache logging mechanism to write its
|
|
messages to the apache error log.
|
|
|
|
=head1 INSTALL AND CONFIG
|
|
|
|
Place this plugin in the plugin/logging directory beneath the standard
|
|
qpsmtpd installation. Edit the config/logging file and add a line like
|
|
this:
|
|
|
|
logging/apache
|
|
|
|
To change what is shown in the logs, change the I<LogLevel> directive in
|
|
the virtual host config for Qpsmtpd and maybe change the I<ErrorLog> log
|
|
file:
|
|
|
|
<VirtualHost _default_:25>
|
|
PerlSetVar QpsmtpdDir /path/to/qpsmtpd
|
|
PerlModule Apache::Qpsmtpd
|
|
PerlProcessConnectionHandler Apache::Qpsmtpd
|
|
LogLevel debug
|
|
ErrorLog /var/log/apache2/qpsmtpd.log
|
|
</VirtualHost>
|
|
|
|
=head1 AUTHOR
|
|
|
|
Hanno Hecker <vetinari@ankh-morp.org>
|
|
|
|
=head1 COPYRIGHT AND LICENSE
|
|
|
|
Copyright (c) 2007 Hanno Hecker
|
|
|
|
This plugin is licensed under the same terms as the qpsmtpd package itself.
|
|
Please see the LICENSE file included with qpsmtpd for details.
|
|
|
|
=cut
|
|
|