Mail-SpamAssassin
view release on metacpan or search on metacpan
spamd-apache2/lib/Mail/SpamAssassin/Spamd/Config.pm view on Meta::CPAN
# ident-based spamc user authentication
if ($self->{'auth-ident'}) {
eval { sub Net::Ident::_export_hooks(); require Net::Ident };
die "spamd: ident-based authentication requested,",
" but Net::Ident is unavailable\n"
if $@;
if (exists $self->{'ident-timeout'} && $self->{'ident-timeout'} <= 0) {
die "ERROR: --ident-timeout must be > 0\n";
}
##Net::Ident->import(qw(ident_lookup));
}
# let's not modify %ENV here...
my $home =
(exists $ENV{HOME} && defined $ENV{HOME} && -d $ENV{HOME})
? $ENV{HOME}
: undef;
if (exists $self->{username})
{ # spamd is going to run as another user, so reset $HOME
if (my $nh = (getpwnam($self->{username}))[7]) {
$home = $nh;
}
else {
die "spamd: unable to determine home directory for user"
. " '$self->{username}'\n";
}
}
if (!exists $self->{home_dir_for_helpers}) {
die "ERROR: \$HOME='$home' does not exist or not a directory\n"
unless defined $home && -d $home;
$self->{home_dir_for_helpers} = $home;
}
if (exists $self->{'max-spare'}) {
if (exists $self->{'min-spare'}) {
## emulate Apache behaviour:
## http://httpd.apache.org/docs-2.0/mod/prefork.html#maxspareservers
$self->{'max-spare'} = $self->{'min-spare'} + 1
if $self->{'max-spare'} < $self->{'min-spare'};
}
else {
$self->{'min-spare'} = $self->{'max-spare'};
}
}
elsif (exists $self->{'min-spare'}) {
$self->{'max-spare'} = $self->{'min-spare'};
}
# set other defaults
for my $opt (keys %defaults) {
$self->{$opt} = $defaults{$opt} if !exists $self->{$opt};
}
# check for server certs, must be done after setting other defaults
if ($self->{'ssl'}) {
$self->{'server-key'} ||= "$self->{LOCAL_RULES_DIR}/certs/server-key.pem";
$self->{'server-cert'} ||= "$self->{LOCAL_RULES_DIR}/certs/server-cert.pem";
eval { require IO::Socket::SSL };
die "spamd: SSL encryption requested, but IO::Socket::SSL is unavailable\n"
if $@;
die "spamd: server key file '$self->{'server-key'}' does not exist\n"
unless -f $self->{'server-key'};
die "spamd: server certificate file '$self->{'server-cert'}' does not exist\n"
unless -f $self->{'server-cert'};
}
# XXX: delete LOCAL_{RULES,STATE}_DIR and PREFIX if eq $defaults{$_}?
1;
}
sub _validate_logging {
my $self = shift;
# Enable debugging, if any areas were specified. We do this already here,
# accessing some non-public API so we can use the convenient dbg() routine.
# Don't do this at home (aka any 3rd party tools), kids!
$self->{debug} ||= 'all' if exists $self->{debug};
# always turn on at least info-level debugging for spamd
$self->{debug} ||= 'info';
$self->{'syslog-socket'} = lc $self->{'syslog-socket'} || 'unix';
$self->{'log-facility'} = $self->{syslog} || 'mail';
# This is the default log file; it can be changed on the command line
# via a --syslog flag containing non-word characters.
$self->{'log-file'} = 'spamd.log';
if ($self->{'log-facility'} =~ /[^a-z0-9]/) {
# A specific log file was given (--syslog=/path/to/file).
$self->{'log-file'} = $self->{'log-facility'};
$self->{'syslog-socket'} = 'file';
}
elsif ($self->{'log-facility'} eq 'file') {
# The generic log file was requested (--syslog=file).
$self->{'syslog-socket'} = 'file';
}
else {
# The casing is kept only if the facility specified a file.
$self->{'log-facility'} = lc $self->{'log-facility'};
}
if ($self->{'syslog-socket'} eq 'file') {
# Either above or at the command line the socket was set
# to 'file' (--syslog-socket=file).
$self->{'log-facility'} = 'file';
}
elsif ($self->{'syslog-socket'} eq 'none') {
# The socket 'none' (--syslog-socket=none) historically
# represents logging to STDERR.
$self->{'log-facility'} = 'stderr';
}
# Either above or at the command line the facility was set
# to 'stderr' (--syslog=stderr).
$self->{'syslog-socket'} = 'file' if $self->{'log-facility'} eq 'stderr';
1;
( run in 3.161 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )