Compare commits
No commits in common. "config" and "main" have entirely different histories.
@ -59,19 +59,19 @@ sub load_logging {
|
|||||||
return if $LOGGING_LOADED; # already done
|
return if $LOGGING_LOADED; # already done
|
||||||
return if $hooks->{'logging'}; # avoid triggering log activity
|
return if $hooks->{'logging'}; # avoid triggering log activity
|
||||||
|
|
||||||
my @plugin_dirs = $self->conf->early_config('plugin_dirs');
|
my @plugin_dirs = $self->conf->from_file('plugin_dirs');
|
||||||
if (!@plugin_dirs) {
|
if (!@plugin_dirs) {
|
||||||
my ($name) = ($0 =~ m!(.*?)/([^/]+)$!);
|
my ($name) = ($0 =~ m!(.*?)/([^/]+)$!);
|
||||||
@plugin_dirs = ("$name/plugins");
|
@plugin_dirs = ("$name/plugins");
|
||||||
}
|
}
|
||||||
|
|
||||||
my @loggers = $self->conf->early_config('logging');
|
my @loggers = $self->conf->from_file('logging');
|
||||||
for my $logger (@loggers) {
|
for my $logger (@loggers) {
|
||||||
$self->_load_plugin($logger, @plugin_dirs);
|
$self->_load_plugin($logger, @plugin_dirs);
|
||||||
$self->log(LOGINFO, "Loaded $logger");
|
$self->log(LOGINFO, "Loaded $logger");
|
||||||
}
|
}
|
||||||
|
|
||||||
$TraceLevel = $self->conf->early_config('loglevel');
|
$TraceLevel = $self->conf->from_file('loglevel');
|
||||||
|
|
||||||
unless (defined($TraceLevel) && $TraceLevel =~ /^\d+$/) {
|
unless (defined($TraceLevel) && $TraceLevel =~ /^\d+$/) {
|
||||||
$TraceLevel = LOGWARN; # Default if no loglevel file found.
|
$TraceLevel = LOGWARN; # Default if no loglevel file found.
|
||||||
|
@ -27,17 +27,6 @@ sub log {
|
|||||||
warn join(' ', $$, @log) . "\n";
|
warn join(' ', $$, @log) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub early_config {
|
|
||||||
my ($self, $config, $file, $visited) = @_;
|
|
||||||
|
|
||||||
my @config;
|
|
||||||
|
|
||||||
@config = $self->from_environment($config);
|
|
||||||
return wantarray ? @config : $config[0] if @config;
|
|
||||||
|
|
||||||
return $self->from_file($config, $file, $visited);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub config {
|
sub config {
|
||||||
my ($self, $qp, $c, $type) = @_;
|
my ($self, $qp, $c, $type) = @_;
|
||||||
|
|
||||||
@ -45,11 +34,6 @@ sub config {
|
|||||||
|
|
||||||
# first run the user_config hooks
|
# first run the user_config hooks
|
||||||
my ($rc, @config);
|
my ($rc, @config);
|
||||||
|
|
||||||
@config = $self->from_environment($c);
|
|
||||||
|
|
||||||
return wantarray ? @config : $config[0] if @config;
|
|
||||||
|
|
||||||
if (ref $type && UNIVERSAL::can($type, 'address')) {
|
if (ref $type && UNIVERSAL::can($type, 'address')) {
|
||||||
($rc, @config) = $qp->run_hooks_no_respond('user_config', $type, $c);
|
($rc, @config) = $qp->run_hooks_no_respond('user_config', $type, $c);
|
||||||
if (defined $rc && $rc == OK) {
|
if (defined $rc && $rc == OK) {
|
||||||
@ -143,23 +127,6 @@ sub get_qmail_map {
|
|||||||
return \%h;
|
return \%h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub from_environment {
|
|
||||||
my ($self, $config) = @_;
|
|
||||||
return unless $config;
|
|
||||||
|
|
||||||
my $env_name = "QPSMTPD_" . $config;
|
|
||||||
return unless $ENV{$env_name};
|
|
||||||
|
|
||||||
my @config = split "\n", $ENV{$env_name};
|
|
||||||
|
|
||||||
chomp @config;
|
|
||||||
for (@config) { s/^\s+//; s/\s+$//; } # trim leading/trailing whitespace
|
|
||||||
|
|
||||||
|
|
||||||
return wantarray ? @config : $config[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
sub from_file {
|
sub from_file {
|
||||||
my ($self, $config, $file, $visited) = @_;
|
my ($self, $config, $file, $visited) = @_;
|
||||||
$file ||= $self->config_dir($config) . "/$config";
|
$file ||= $self->config_dir($config) . "/$config";
|
||||||
|
Loading…
Reference in New Issue
Block a user