Commit c99c5d7c authored by david.verdin's avatar david.verdin
Browse files

[feature] Now the sympa.conf, wwsympa.conf and robot.conf are cached in binary...

[feature] Now the sympa.conf, wwsympa.conf and robot.conf are cached in binary form (e.g. sympa.conf.bin). This speeds up that startup process.
[change] Full refactoring of Conf.pm to better distinguish conf/robot loading. First step towards robot-independant and on-the-fly config loading, and also wwsympa.cnf and sympa.conf merge.


git-svn-id: https://subversion.renater.fr/sympa/trunk@7000 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 80073c39
This diff is collapsed.
......@@ -7180,15 +7180,13 @@ sub is_listmaster {
return 0 unless ($who);
if ($robot && (defined $Conf::Conf{'robots'}{$robot}) && $Conf::Conf{'robots'}{$robot}{'listmasters'}) {
foreach my $listmaster (@{$Conf::Conf{'robots'}{$robot}{'listmasters'}}){
return 1 if (lc($listmaster) eq lc($who));
}
foreach my $listmaster (@{&Conf::get_robot_conf($robot,'listmasters')}){
return 1 if (lc($listmaster) eq lc($who));
}
foreach my $listmaster (@{$Conf::Conf{'listmasters'}}){
return 1 if (lc($listmaster) eq lc($who));
}
return 1 if (lc($listmaster) eq lc($who));
}
return 0;
}
......
......@@ -1085,10 +1085,10 @@ sub check_owner_defined {
my $smtp;
my (@suf, @addresses);
my $smtp_relay = $Conf::Conf{'robots'}{$robot}{'list_check_smtp'} || $Conf::Conf{'list_check_smtp'};
my $smtp_helo = $Conf::Conf{'robots'}{$robot}{'list_check_helo'} || $Conf::Conf{'list_check_helo'} || $smtp_relay;
my $smtp_relay = &Conf::get_robot_conf($robot, 'list_check_smtp');
my $smtp_helo = &Conf::get_robot_conf($robot, 'list_check_helo') || $smtp_relay;
$smtp_helo =~ s/:[-\w]+$//;
my $suffixes = $Conf::Conf{'robots'}{$robot}{'list_check_suffixes'} || $Conf::Conf{'list_check_suffixes'};
my $suffixes = &Conf::get_robot_conf($robot, 'list_check_suffixes');
return 0
unless ($smtp_relay && $suffixes);
my $domain = &Conf::get_robot_conf($robot, 'host');
......
......@@ -155,7 +155,7 @@ our @params = (
},
{
name => 'queuedistribute',
file => 'sympa.conf'
file => 'sympa.conf'
},
{
name => 'queueautomatic',
......@@ -288,10 +288,10 @@ our @params = (
{ title => 'General definition' },
{
name => 'domain',
default => 'domain.tld',
query => 'Main robot hostname',
edit => '1',
file => 'sympa.conf',
vhost => '1',
},
{
name => 'listmaster',
......@@ -894,9 +894,9 @@ our @params = (
},
{
name => 'wwsympa_url',
default => 'http://host.domain.tld/sympa',
sample => 'http://host.domain.tld/sympa',
query => 'URL of main web page',
vhost => '1',
vhost => '1',
file => 'sympa.conf',
edit => '1',
},
......@@ -1011,7 +1011,7 @@ our @params = (
},
{
name => 'host',
default => undef,
optional => 1,
vhost => '1',
},
{
......@@ -1020,7 +1020,8 @@ our @params = (
},
{
name => 'tmpdir',
},
default => Sympa::Constants::SPOOLDIR . '/tmp',
},
{
name => 'sleep',
default => '5',
......
......@@ -3205,6 +3205,45 @@ sub is_in_array {
return undef;
}
####################################################
# a_is_older_than_b
####################################################
# Compares the last modifications date of two files
#
# IN : - a hash with two entries:
#
# * a_file : the full path to a file
# * b_file : the full path to a file
#
# OUT : string: 'true' it the last modification date of "a_file" is older than "b_file"'s, 'false' otherwise.
# return undef if the comparison could not be caried on.
#######################################################
sub a_is_older_than_b {
my $param = shift;
my ($a_file_readable, $b_file_readable) = (0,0);
my $answer = undef;
if (-r $param->{'a_file'}) {
$a_file_readable = 1;
}else{
&do_log('err', 'Could not read file %s. Comparison impossible', $param->{'a_file'});
}
if (-r $param->{'b_file'}) {
$b_file_readable = 1;
}else{
&do_log('err', 'Could not read file %s. Comparison impossible', $param->{'b_file'});
}
if ($a_file_readable && $b_file_readable) {
my @a_stats = stat ($param->{'a_file'});
my @b_stats = stat ($param->{'b_file'});
if($a_stats[9] < $b_stats[9]){
$answer = 1;
}else{
$answer = 0;
}
}
return $answer;
}
####################################################
# clean_msg_id
####################################################
......
......@@ -282,7 +282,7 @@ sub ldap_authentication {
&do_log('debug3',"canonic: $canonic_email[0]");
## If the identifier provided was a valid email, return the provided email.
## Otherwise, return the canonical email guessed after the login.
if( &tools::valid_email($auth) && !$Conf::Conf{'robots'}{$robot}{'ldap_force_canonical_email'}) {
if( &tools::valid_email($auth) && !&Conf::get_robot_conf($robot,'ldap_force_canonical_email')) {
return ($auth);
}else{
return lc($canonic_email[0]);
......@@ -362,12 +362,8 @@ sub remote_app_check_password {
# seach entry for trusted_application in Conf
my @trusted_apps ;
# select trusted_apps from robot context or symap context
if ((defined $robot) && (defined $Conf::Conf{'robots'}{$robot}{'trusted_applications'})) {
@trusted_apps = @{$Conf::Conf{'robots'}{$robot}{'trusted_applications'}{'trusted_application'}};
}else{
@trusted_apps = @{$Conf::Conf{'trusted_applications'}{'trusted_application'}};
}
# select trusted_apps from robot context or sympa context
@trusted_apps = @{&Conf::get_robot_conf($robot,'trusted_applications')};
foreach my $application (@trusted_apps){
......
......@@ -1026,8 +1026,7 @@ my $birthday = time ;
$param->{'default_robot'} = 1;
}
$param->{'cookie_domain'} = $Conf{'robots'}{$robot}{'cookie_domain'} if $Conf{'robots'}{$robot};
$param->{'cookie_domain'} ||= $wwsconf->{'cookie_domain'};
$param->{'cookie_domain'} = &Conf::get_robot_conf($robot,'cookie_domain');
$ip = $ENV{'REMOTE_HOST'};
$ip = $ENV{'REMOTE_ADDR'} unless ($ip);
$ip = 'undef' unless ($ip);
......@@ -1040,7 +1039,7 @@ my $birthday = time ;
$param->{'cookie_domain'} = $http_host;
}
 
&Log::set_log_level($Conf{'robots'}{$robot}{'log_level'});
&Log::set_log_level(&Conf::get_robot_conf($robot, 'log_level'));
 
## Sympa parameters in $param->{'conf'}
$param->{'conf'} = {};
......@@ -8385,10 +8384,10 @@ sub do_set_pending_list_request {
my $smtp;
my (@suf, @addresses);
 
my $smtp_relay = $Conf{'robots'}{$robot}{'list_check_smtp'} || $Conf{'list_check_smtp'};
my $smtp_helo = $Conf{'robots'}{$robot}{'list_check_helo'} || $Conf{'list_check_helo'} || $smtp_relay;
my $smtp_relay = &Conf::get_robot_conf($robot, 'list_check_smtp');
my $smtp_helo = &Conf::get_robot_conf($robot, 'list_check_helo') || $smtp_relay;
$smtp_helo =~ s/:[-\w]+$//;
my $suffixes = $Conf{'robots'}{$robot}{'list_check_suffixes'} || $Conf{'list_check_suffixes'};
my $suffixes = &Conf::get_robot_conf($robot, 'list_check_suffixes');
return 0
unless ($smtp_relay && $suffixes);
my $domain = &Conf::get_robot_conf($robot, 'host');
......
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