Merge pull request #39 from rsiddall/master

Removed packaging/rpm/files/qpsmtpd-plugin-file_connection as there's a ...
This commit is contained in:
Matt Simerson 2014-02-13 17:05:42 -08:00
commit ecf924e35b
2 changed files with 12 additions and 195 deletions

View File

@ -1,184 +0,0 @@
#!/usr/bin/perl
# $Id: file 478 2005-07-19 07:40:16Z aqua $
=head1 NAME
file_connection - Simple per session log-to-file logging for qpsmtpd
=head1 DESCRIPTION
The 'file_connection' logging plugin for qpsmtpd records qpsmtpd log messages into a
file (or a named pipe, if you prefer.)
The file is reopened for each connection. To facilitate automatic
logfile switching the filename can contain strftime conversion
specifiers, which are expanded immediately before opening the file. This
ensures that a single connection is never split across logfiles.
The list of supported conversion specifiers depends on the strftime
implementation of your C library. See strftime(3) for details.
Additionally, %i exands to a (hopefully) unique session-id.
=head1 CONFIGURATION
To enable the logging plugin, add a line of this form to the qpsmtpd plugins
configuration file:
=over
logging/file_connection [loglevel I<level>] I<path>
For example:
logging/file_connection loglevel LOGINFO /var/log/qpsmtpd/%Y-%m-%d
=back
Multiple instances of the plugin can be configured by appending :I<N> for any
integer(s) I<N>, to log to multiple files simultaneously, e.g. to log critical
errors and normally verbose logs elsewhere.
The following optional configuration setting can be supplied:
=over
=item loglevel I<loglevel>
The internal log level below which messages will be logged. The I<loglevel>
given should be chosen from this list. Priorities count downward (for example,
if LOGWARN were selected, LOGERROR, LOGCRIT and LOGEMERG messages would be
logged as well):
=over
=item B<LOGDEBUG>
=item B<LOGINFO>
=item B<LOGNOTICE>
=item B<LOGWARN>
=item B<LOGERROR>
=item B<LOGCRIT>
=item B<LOGALERT>
=item B<LOGEMERG>
=back
=back
The chosen I<path> should be writable by the user running qpsmtpd; it will be
created it did not already exist, and appended to otherwise.
=head1 AUTHOR
Peter J. Holzer <hjp@hjp.at>, based on a plugin by
Devin Carraway <qpsmtpd@devin.com>
=head1 LICENSE
Copyright (c) 2005, Devin Carraway.
This plugin is licensed under the same terms as the qpsmtpd package itself.
Please see the LICENSE file included with qpsmtpd for details.
=cut
use strict;
use warnings;
use IO::File;
#use Sys::Hostname;
use POSIX qw(strftime);
sub register {
my ($self, $qp, @args) = @_;
my %args;
$self->{_loglevel} = LOGWARN;
while (1) {
last if !@args;
if (lc $args[0] eq 'loglevel') {
shift @args;
my $ll = shift @args;
if (!defined $ll) {
warn "Malformed arguments to logging/file_connection plugin";
return;
}
if ($ll =~ /^(\d+)$/) {
$self->{_loglevel} = $1;
}
elsif ($ll =~ /^(LOG\w+)$/) {
$self->{_loglevel} = log_level($1);
defined $self->{_loglevel} or $self->{_loglevel} = LOGWARN;
}
}
else { last }
}
unless (@args && $args[0]) {
warn "Malformed arguments to syslog plugin";
return;
}
$self->{_logfile} = join(' ', @args);
$self->{_log_session_id_prefix} = sprintf("%08x%04x", time(), $$);
$self->{_log_session_id_counter} = 0;
$self->register_hook('logging', 'write_log');
$self->register_hook('pre-connection', 'open_log');
$self->open_log($qp);
}
sub open_log {
my ($self, $qp) = @_;
my $output = $self->{_logfile};
$self->{_log_session_id} =
$self->{_log_session_id_prefix} . "." .
++$self->{_log_session_id_counter};
$output =~ s/%i/$self->{_log_session_id}/;
$output = strftime($output, localtime);
#print STDERR "open_log: output=$output, uid=$>\n";
if ($output =~ /^\s*\|(.*)/) {
unless ($self->{_f} = new IO::File "|$1") {
warn "Error opening log output to command $1: $!";
return;
}
} elsif ($output =~ /^(.*)/) { # detaint
unless ($self->{_f} = new IO::File ">>$1") {
warn "Error opening log output to path $1: $!";
return;
}
}
$self->{_f}->autoflush(1);
return DECLINED;
}
sub write_log {
my ($self, $txn, $trace, $hook, $plugin, @log) = @_;
return DECLINED if $trace > $self->{_loglevel};
return DECLINED if defined $plugin and $plugin eq $self->plugin_name;
$self->open_log unless($self->{_f});
my $f = $self->{_f};
print STDERR "no open file\n" unless (defined $f);
print $f join(" ",
strftime("%Y-%m-%dT%H:%M:%S%z", localtime), $self->{_log_session_id},
(defined $plugin ? " $plugin plugin:" :
defined $hook ? " running plugin ($hook):" : ""),
@log), "\n";
return DECLINED;
}
# vi: tabstop=4 shiftwidth=4 expandtab:

View File

@ -19,11 +19,10 @@ Requires(pre): coreutils, shadow-utils, perl
Source0: %{name}-%{version}-%{release}.tar.gz Source0: %{name}-%{version}-%{release}.tar.gz
Source1: qpsmtpd-forkserver.rc Source1: qpsmtpd-forkserver.rc
Source2: qpsmtpd-forkserver.sysconfig Source2: qpsmtpd-forkserver.sysconfig
Source3: qpsmtpd-plugin-file_connection Source3: qpsmtpd-xinetd
Source4: qpsmtpd-xinetd Source4: in.qpsmtpd
Source5: in.qpsmtpd Source5: qpsmtpd.conf
Source6: qpsmtpd.conf Source6: README.selinux
Source7: README.selinux
%description %description
qpsmtpd is a flexible smtpd daemon written in Perl. Apart from the core qpsmtpd is a flexible smtpd daemon written in Perl. Apart from the core
@ -85,22 +84,20 @@ rm -f ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/*.*
cp -r config.sample/* ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/ cp -r config.sample/* ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/
echo %{_datadir}/%{name}/plugins > ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/plugin_dirs echo %{_datadir}/%{name}/plugins > ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/plugin_dirs
echo %{_localstatedir}/spool/qpsmtpd > ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/spool_dir echo %{_localstatedir}/spool/qpsmtpd > ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/spool_dir
echo logging/file_connection loglevel LOGINFO %{_localstatedir}/log/qpsmtpd/%Y-%m-%d > ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/logging
mkdir -p ${RPM_BUILD_ROOT}%{_initrddir} mkdir -p ${RPM_BUILD_ROOT}%{_initrddir}
cp %{SOURCE1} ${RPM_BUILD_ROOT}%{_initrddir}/qpsmtpd-forkserver cp %{SOURCE1} ${RPM_BUILD_ROOT}%{_initrddir}/qpsmtpd-forkserver
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig
cp %{SOURCE2} ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/qpsmtpd-forkserver cp %{SOURCE2} ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/qpsmtpd-forkserver
cp %{SOURCE3} ${RPM_BUILD_ROOT}%{_datadir}/%{name}/plugins/logging/file_connection
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/spool/qpsmtpd mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/spool/qpsmtpd
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/log/qpsmtpd mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/log/qpsmtpd
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/xinetd.d mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/xinetd.d
cp %{SOURCE4} ${RPM_BUILD_ROOT}%{_sysconfdir}/xinetd.d/smtp cp %{SOURCE3} ${RPM_BUILD_ROOT}%{_sysconfdir}/xinetd.d/smtp
mkdir -p ${RPM_BUILD_ROOT}%{_sbindir} mkdir -p ${RPM_BUILD_ROOT}%{_sbindir}
cp %{SOURCE5} ${RPM_BUILD_ROOT}%{_sbindir}/in.smtp cp %{SOURCE4} ${RPM_BUILD_ROOT}%{_sbindir}/in.smtp
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/httpd/conf.d mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/httpd/conf.d
cp %{SOURCE6} ${RPM_BUILD_ROOT}%{_sysconfdir}/httpd/conf.d cp %{SOURCE5} ${RPM_BUILD_ROOT}%{_sysconfdir}/httpd/conf.d
mkdir -p $RPM_BUILD_ROOT%{_docdir}/%{name}-apache-%{version} mkdir -p $RPM_BUILD_ROOT%{_docdir}/%{name}-apache-%{version}
cp %{SOURCE7} $RPM_BUILD_ROOT%{_docdir}/%{name}-apache-%{version} cp %{SOURCE6} $RPM_BUILD_ROOT%{_docdir}/%{name}-apache-%{version}
[ -x /usr/lib/rpm/brp-compress ] && /usr/lib/rpm/brp-compress [ -x /usr/lib/rpm/brp-compress ] && /usr/lib/rpm/brp-compress
@ -161,6 +158,10 @@ then
fi fi
%changelog %changelog
* Fri Oct 14 2011 <richard.siddall@elirion.net> 0.84-1
- Removed rpm/files/qpsmtpd-plugin-file_connection as there's a
newer version in plugins/logging/file
* Sun Jul 12 2009 <rpmbuild@robinbowes.com> 0.82-0.1 * Sun Jul 12 2009 <rpmbuild@robinbowes.com> 0.82-0.1
- Update to latest release - Update to latest release
- don't add qpsmtpd to start-up by default - don't add qpsmtpd to start-up by default