Eliminate the creeping use of warn() in favor of log() and make
more use of the "fd:#" code everywhere. * lib/Qpsmtpd.pm Default log method use '$self->fd()' instead of '$self->{fd}'. Include a sub fd() method for inheritance purposes. * lib/Qpsmtpd/PollServer.pm Inherit log() from Qpsmtpd.pm (via SMTP.pm). * lib/Qpsmtpd/Plugin.pm Appropriate code allow plugins to inherit fd(). * plugins/dnsbl Use log() instead of warn(). * plugins/logging/adaptive plugins/logging/warn Include the 'fd:#' to the log line if defined. * qpsmtpd Reorder things slightly so we can use log(). git-svn-id: https://svn.perl.org/qpsmtpd/trunk@589 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
parent
2535e77293
commit
7cc114edd5
@ -76,7 +76,7 @@ sub varlog {
|
||||
|
||||
unless ( $rc and $rc == DECLINED or $rc == OK ) {
|
||||
# no logging plugins registered so fall back to STDERR
|
||||
my $fd = $self->{fd};
|
||||
my $fd = $self->fd();
|
||||
warn join(" ", $$ .
|
||||
(defined $fd ? " fd:$fd" : "") .
|
||||
(defined $plugin ? " $plugin plugin:" :
|
||||
@ -370,7 +370,7 @@ sub finish_continuation {
|
||||
$r[0] = DECLINED if not defined $r[0];
|
||||
my $responder = $hook . "_respond";
|
||||
if (my $meth = $self->can($responder)) {
|
||||
warn("continuation finished on $self\n");
|
||||
$self->log(LOGNOTICE, "continuation finished on $self\n");
|
||||
return $meth->($self, $r[0], $r[1], @$args);
|
||||
}
|
||||
die "No ${hook}_respond method";
|
||||
@ -501,6 +501,10 @@ sub auth_mechanism {
|
||||
return (defined $self->{_auth_mechanism} ? $self->{_auth_mechanism} : "" );
|
||||
}
|
||||
|
||||
sub fd {
|
||||
return shift->{fd};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
@ -50,6 +50,10 @@ sub qp {
|
||||
shift->{_qp};
|
||||
}
|
||||
|
||||
sub fd {
|
||||
shift->qp->fd();
|
||||
}
|
||||
|
||||
sub log {
|
||||
my $self = shift;
|
||||
$self->qp->varlog(shift, $self->hook_name, $self->plugin_name, @_)
|
||||
@ -116,7 +120,7 @@ sub isa_plugin {
|
||||
$self->compile($self->plugin_name . "_isa_$cleanParent",
|
||||
$newPackage,
|
||||
"plugins/$parent"); # assumes Cwd is qpsmtpd root
|
||||
warn "---- $newPackage\n";
|
||||
$self->log(LOGDEBUG,"---- $newPackage\n");
|
||||
no strict 'refs';
|
||||
push @{"${currentPackage}::ISA"}, $newPackage;
|
||||
}
|
||||
|
@ -98,13 +98,6 @@ sub fault {
|
||||
return;
|
||||
}
|
||||
|
||||
sub log {
|
||||
my ($self, $trace, @log) = @_;
|
||||
my $fd = $self->{fd};
|
||||
$fd ||= '?';
|
||||
$self->SUPER::log($trace, "fd:$fd", @log);
|
||||
}
|
||||
|
||||
sub process_line {
|
||||
my $self = shift;
|
||||
my $line = shift || return;
|
||||
|
@ -75,7 +75,7 @@ sub finished {
|
||||
sub process_a_result {
|
||||
my ($qp, $template, $result, $query) = @_;
|
||||
|
||||
warn("Result for A $query: $result\n");
|
||||
$qp->log(LOGINFO, "Result for A $query: $result\n");
|
||||
if ($result !~ /^\d+\.\d+\.\d+\.\d+$/) {
|
||||
# NXDOMAIN or ERROR possibly...
|
||||
# $qp->finish_continuation if $qp->input_sock->readable;
|
||||
@ -92,7 +92,7 @@ sub process_a_result {
|
||||
sub process_txt_result {
|
||||
my ($qp, $result, $query) = @_;
|
||||
|
||||
warn("Result for TXT $query: $result\n");
|
||||
$qp->log(LOGINFO, "Result for TXT $query: $result\n");
|
||||
if ($result !~ /[a-z]/) {
|
||||
# NXDOMAIN or ERROR probably...
|
||||
# $qp->finish_continuation if $qp->input_sock->readable;
|
||||
|
@ -44,8 +44,10 @@ sub hook_logging { # wlog
|
||||
return DECLINED if defined $plugin and $plugin eq $self->plugin_name;
|
||||
|
||||
if ( defined $self->{_maxlevel} && $trace <= $self->{_maxlevel} ) {
|
||||
my $fd = $self->fd();
|
||||
warn join(
|
||||
" ", $$.
|
||||
(defined $fd ? " fd:$fd" : "") .
|
||||
(
|
||||
defined $plugin ? " $plugin plugin:"
|
||||
: defined $hook ? " running plugin ($hook):"
|
||||
|
@ -29,9 +29,11 @@ sub hook_logging {
|
||||
# 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;
|
||||
my $fd = $self->fd();
|
||||
|
||||
warn
|
||||
join(" ", $$ .
|
||||
(defined $fd ? " fd:$fd" : "") .
|
||||
(defined $plugin ? " $plugin plugin:" :
|
||||
defined $hook ? " running plugin ($hook):" : ""),
|
||||
@log), "\n"
|
||||
|
11
qpsmtpd
11
qpsmtpd
@ -189,7 +189,6 @@ sub run_as_inetd {
|
||||
|
||||
my $out = Qpsmtpd::PollServer->new($outsock);
|
||||
$out->load_plugins;
|
||||
$out->init_logger;
|
||||
$out->input_sock($client);
|
||||
$client->push_back_read("Connect\n");
|
||||
# Cause poll/kevent/epoll to end quickly in first iteration
|
||||
@ -241,15 +240,15 @@ sub run_as_server {
|
||||
die "unable to change uid: $!\n";
|
||||
$> = $quid;
|
||||
|
||||
::log(LOGINFO, 'Running as user '.
|
||||
(getpwuid($>) || $>) .
|
||||
', group '.
|
||||
(getgrgid($)) || $)));
|
||||
|
||||
# Load plugins here
|
||||
my $plugin_loader = Qpsmtpd::SMTP->new();
|
||||
$plugin_loader->load_plugins;
|
||||
|
||||
$plugin_loader->log(LOGINFO, 'Running as user '.
|
||||
(getpwuid($>) || $>) .
|
||||
', group '.
|
||||
(getgrgid($)) || $)));
|
||||
|
||||
if ($PROCS > 1) {
|
||||
$SIG{'CHLD'} = \&sig_chld;
|
||||
my @kids;
|
||||
|
Loading…
Reference in New Issue
Block a user