Commit df56d85b authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Whitespace cleanup

parent ba42bd62
#!/usr/bin/perl
# Cluebringer policy daemon
# Copyright (C) 2010, AllWorldIT
# Copyright (C) 2010-2014, AllWorldIT
# Copyright (C) 2008, LinuxRulz
# Copyright (C) 2007, Nigel Kukard <nkukard@lbsd.net>
#
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
......@@ -65,7 +65,7 @@ sub configure {
$server->{'host'} = "*";
$server->{'port'} = 10031;
$server->{'min_servers'} = 4;
$server->{'min_spare_servers'} = 4;
$server->{'max_spare_servers'} = 12;
......@@ -96,7 +96,7 @@ sub configure {
print(STDERR "ERROR: No configuration file '".$cfg->{'config_file'}."' found!\n");
exit 1;
}
# Use config file, ignore case
tie my %inifile, 'Config::IniFiles', (
-file => $cfg->{'config_file'},
......@@ -112,12 +112,12 @@ sub configure {
'log_level','log_file',
'port', 'host',
'cidr_allow', 'cidr_deny',
'pid_file',
'pid_file',
'user', 'group',
'timeout',
'timeout_idle', 'timeout_busy',
'background',
'min_servers',
'min_servers',
'min_spare_servers',
'max_spare_servers',
'max_servers',
......@@ -179,8 +179,8 @@ sub configure {
$module = "protocols/$module";
push(@{$cfg->{'module_list'}},$module);
}
}
}
# Override
if ($cmdline->{'debug'}) {
$server->{'log_level'} = 4;
......@@ -212,7 +212,7 @@ sub configure {
$cfg->{'log_mail'} = $config{'server'}{'log_mail'};
}
}
# Save our config and stuff
$self->{'config'} = $cfg;
$self->{'cmdline'} = $cmdline;
......@@ -226,7 +226,7 @@ sub post_configure_hook {
my $self = shift;
my $log_mail = $self->{'config'}{'log_mail'};
$self->log(LOG_NOTICE,"[CBPOLICYD] Policyd v2 / Cluebringer - v".VERSION);
$self->log(LOG_NOTICE,"[CBPOLICYD] Initializing system modules.");
......@@ -262,12 +262,12 @@ sub post_configure_hook {
my $facility = $1;
my $method = defined($2) ? $2 : 'syslog';
my $destination = $3;
# Check method of logging
if ($method eq "syslog") {
$destination = 'native' if (!defined($destination));
$facility = 'mail' if (!defined($facility));
$self->log(LOG_DEBUG,"[CBPOLICYD] Opening syslog, destination = '$destination', facility = '$facility'.");
# We may have some args to pass to setlogsock
my @syslogArgs = split(/,/,$destination);
......@@ -277,11 +277,11 @@ sub post_configure_hook {
if (!Sys::Syslog::openlog("cbpolicyd",'pid|ndelay',$facility)) {
$self->log(LOG_ERR,"[CBPOLICYD] Failed to open syslog socket: $!");
}
} else {
$self->log(LOG_WARN,"[CBPOLICYD] Value of 'log_mail' not understood. Method '$method' is invalid.");
}
} else {
$self->log(LOG_WARN,"[CBPOLICYD] Value '$log_mail' of 'log_mail' not understood.");
}
......@@ -319,9 +319,9 @@ sub child_init_hook
{
my $self = shift;
$self->SUPER::child_init_hook();
$self->log(LOG_DEBUG,"[CBPOLICYD] Starting up caching engine");
cbp::cache::connect($self);
......@@ -353,7 +353,7 @@ sub child_finish_hook {
my $server = $self->{'server'};
$self->SUPER::child_finish_hook();
$self->log(LOG_DEBUG,"[CBPOLICYD] Shutting down caching engine ($$)");
cbp::cache::disconnect($self);
}
......@@ -369,7 +369,7 @@ sub process_request {
# How many times did we pipeline...
my $policyRequests = 0;
#
# Loop till we fill up the buffer
#
......@@ -379,10 +379,10 @@ CONN_READ:
# Found module, set to 1 if found, 0 if otherwize
my $found = 0;
# Buffer
my $buf = "";
# Create an FDSET for use in select()
my $fdset = "";
vec($fdset, fileno(STDIN), 1) = 1;
......@@ -419,7 +419,7 @@ CONN_READ:
$server->{'sockaddr'}.":".$server->{'sockport'});
return;
}
# Setup timeout
my $timeout;
......@@ -438,7 +438,7 @@ CONN_READ:
$server->{'peerport'}.", Local: ".$server->{'sockaddr'}.":".$server->{'sockport'});
return;
}
# Read in 8kb
$n = sysread(STDIN,$buf,8192,$bufLen);
if (!$n) {
......@@ -460,7 +460,7 @@ CONN_READ:
# If we have a init function, call it before processing...
$server->{'_protocol_handler'}->{'protocol_init'}($self) if (defined($server->{'_protocol_handler'}->{'protocol_init'}));
# Process buffer
my $request = $server->{'_protocol_handler'}->{'protocol_parse'}($self,$buf);
......@@ -479,8 +479,8 @@ CONN_READ:
# Internal data
$request->{'_timestamp'} = time();
# Check if we got connected, if not ... bypass
if ($self->{'client'}->{'dbh_status'} > 0) {
my $action;
......@@ -505,7 +505,7 @@ CONN_READ:
$self->protocol_response(PROTO_DB_ERROR);
$action = "tempfail";
}
$self->maillog("module=Core, action=$action, host=%s, from=%s, to=%s, reason=db_failure_bypass",
$request->{'client_address'} ? $request->{'client_address'} : "unknown",
$request->{'helo_name'} ? $request->{'helo_name'} : "",
......@@ -557,7 +557,7 @@ CONN_READ:
next if (!defined($module->{'request_process'}));
$self->log(LOG_DEBUG,"[CBPOLICYD] Running module: ".$module->{'name'}) if ($log);
# Run request in eval
my $res;
eval {
......@@ -591,7 +591,7 @@ CONN_READ:
last;
}
}
$self->log(LOG_DEBUG,"[CBPOLICYD] Done with modules") if ($log);
# Update session data
......@@ -617,7 +617,7 @@ sub server_exit
my $self = shift;
my $log_mail = $self->{'config'}{'log_mail'};
$self->log(LOG_DEBUG,"Destroying system modules.");
# Destroy cache
cbp::cache::Destroy($self);
......@@ -653,7 +653,7 @@ sub log
$logtxt = "WARNING";
} elsif ($level == LOG_ERR) {
$logtxt = "ERROR";
}
}
# Parse message nicely
if ($msg =~ /^(\[[^\]]+\]) (.*)/s) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment