Commit e62bddac authored by sikeda's avatar sikeda
Browse files

[svn] (con'd r10649) Retrieving layout changes done on trunk (#2 of #3/3).

Exception: tools::save_to_bad() is kept.


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@11337 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 3c89d30e
......@@ -31,7 +31,7 @@ use HTTP::Cookies;
#use SOAP::Lite +trace;
use SOAP::Lite;
use tools;
use Sympa::Tools::Data;
my ($reponse, @ret, $val, %fault);
......@@ -318,7 +318,7 @@ sub print_result {
} else {
@ret = $r->result;
}
tools::dump_var(\@ret, 0, \*STDOUT);
Sympa::Tools::Data::dump_var(\@ret, 0, \*STDOUT);
}
return 1;
......
......@@ -35,7 +35,7 @@ use Sympa::List;
use Log;
use SDM;
use Sympa::Template::Compat;
use tools;
use Sympa::Tools::File;
my %options;
......@@ -219,7 +219,7 @@ foreach my $tpl (@templates) {
next;
}
unless (
tools::set_file_rights(
Sympa::Tools::File::set_file_rights(
file => $dest_path,
user => Sympa::Constants::USER,
group => Sympa::Constants::GROUP,
......@@ -276,7 +276,7 @@ sub convert {
printf "Template file $in_file has been converted to $out_file\n";
unless (
tools::set_file_rights(
Sympa::Tools::File::set_file_rights(
file => $out_file,
user => Sympa::Constants::USER,
group => Sympa::Constants::GROUP
......
This diff is collapsed.
......@@ -36,9 +36,10 @@ use Sympa::Constants;
use Sympa::Language;
use Sympa::LockedFile;
use Log;
use Sympa::Robot;
use SDM;
use tools;
use Sympa::Tools::Data;
use Sympa::Tools::File;
=head1 NAME
......@@ -650,7 +651,7 @@ sub checkfiles_as_root {
$Conf{'sendmail_aliases'}
);
unless (
tools::set_file_rights(
Sympa::Tools::File::set_file_rights(
file => $Conf{'sendmail_aliases'},
user => Sympa::Constants::USER,
group => Sympa::Constants::GROUP,
......@@ -674,7 +675,7 @@ sub checkfiles_as_root {
}
unless (
tools::set_file_rights(
Sympa::Tools::File::set_file_rights(
file => $dir,
user => Sympa::Constants::USER,
group => Sympa::Constants::GROUP,
......@@ -720,7 +721,7 @@ sub checkfiles {
$config_err++;
}
unless (
tools::set_file_rights(
Sympa::Tools::File::set_file_rights(
file => $Conf{$qdir},
user => Sympa::Constants::USER,
group => Sympa::Constants::GROUP,
......@@ -743,7 +744,7 @@ sub checkfiles {
$config_err++;
}
unless (
tools::set_file_rights(
Sympa::Tools::File::set_file_rights(
file => $subdir,
user => Sympa::Constants::USER,
group => Sympa::Constants::GROUP,
......@@ -865,7 +866,7 @@ sub checkfiles {
## Create directory if required
unless (-d $dir) {
unless (tools::mkdir_all($dir, 0755)) {
unless (Sympa::Tools::File::mkdir_all($dir, 0755)) {
tools::send_notify_to_listmaster($robot, 'cannot_mkdir',
["Could not create directory $dir: $ERRNO"]);
Log::do_log('err', 'Failed to create directory %s: %m', $dir);
......@@ -1448,9 +1449,10 @@ sub load_trusted_application {
return undef unless (-r $config_file);
return undef unless (-r $config_file);
# open TMP,
# ">/tmp/dump1";tools::dump_var(load_generic_conf_file($config_file,\
# %trusted_applications);, 0,\*TMP);close TMP;
# open TMP, ">/tmp/dump1";
# Sympa::Tools::Data::dump_var(load_generic_conf_file($config_file,
# \%trusted_applications);, 0,\*TMP);
# close TMP;
return (load_generic_conf_file($config_file, \%trusted_applications));
}
......@@ -1866,7 +1868,11 @@ sub _infer_server_specific_parameter_values {
Sympa::Constants::DEFAULTDIR . '/ca-bundle.crt';
}
unless (tools::smart_eq($param->{'config_hash'}{'dkim_feature'}, 'on')) {
unless (
Sympa::Tools::Data::smart_eq(
$param->{'config_hash'}{'dkim_feature'}, 'on'
)
) {
# dkim_signature_apply_ on nothing if dkim_feature is off
# Sets empty array.
$param->{'config_hash'}{'dkim_signature_apply_on'} = [''];
......@@ -2307,7 +2313,7 @@ sub _set_listmasters_entry {
sub _check_double_url_usage {
my $param = shift;
my ($host, $path);
if (tools::smart_eq(
if (Sympa::Tools::Data::smart_eq(
$param->{'config_hash'}{'http_host'},
qr/^([^\/]+)(\/.*)$/
)
......@@ -2460,7 +2466,7 @@ sub _save_config_hash_to_binary {
sub _source_has_not_changed {
my $param = shift;
my $is_older = tools::a_is_older_than_b(
my $is_older = Sympa::Tools::File::a_is_older_than_b(
{ 'a_file' => $param->{'config_file'},
'b_file' => $param->{'config_file'} . $binary_file_extension,
}
......@@ -2491,7 +2497,7 @@ sub _get_config_file_name {
sub _create_robot_like_config_for_main_robot {
return if (defined $Conf::Conf{'robots'}{$Conf::Conf{'domain'}});
my $main_conf_no_robots = tools::dup_var(\%Conf);
my $main_conf_no_robots = Sympa::Tools::Data::dup_var(\%Conf);
delete $main_conf_no_robots->{'robots'};
_remove_unvalid_robot_entry(
{'config_hash' => $main_conf_no_robots, 'quiet' => 1});
......
......@@ -32,9 +32,9 @@ use Scalar::Util;
use Sys::Syslog qw();
use Conf;
use Sympa::Robot;
use SDM;
use tools;
use Sympa::Tools::Time;
my ($log_facility, $log_socket_type, $log_service, $sth, @sth_stack,
$rows_nb);
......@@ -684,8 +684,9 @@ sub aggregate_data {
#store reslults in stat_counter_table
foreach my $key_op (keys(%$aggregated_data)) {
#open TMP2, ">/tmp/digdump"; tools::dump_var($aggregated_data->{$key_op}, 0, \*TMP2); close TMP2;
# open TMP2, ">/tmp/digdump";
# Sympa::Tools::Data::dump_var($aggregated_data->{$key_op}, 0, \*TMP2);
# close TMP2;
#store send mail data-------------------------------
if ($key_op eq 'send_mail') {
......@@ -1318,7 +1319,7 @@ sub agregate_daily_data {
my $first_date = $param->{'first_date'} || time;
my $last_date = $param->{'last_date'} || time;
foreach my $begin_date (sort keys %{$param->{'hourly_data'}}) {
my $reftime = tools::get_midnight_time($begin_date);
my $reftime = Sympa::Tools::Time::get_midnight_time($begin_date);
unless (defined $param->{'first_date'}) {
$first_date = $reftime if ($reftime < $first_date);
}
......
......@@ -71,13 +71,18 @@ nobase_modules_DATA = \
Sympa/Task.pm \
Sympa/Template/Compat.pm \
tools.pm \
Sympa/Tools/Daemon.pm \
Sympa/Tools/Data.pm \
Sympa/Tools/DKIM.pm \
Sympa/Tools/File.pm \
Sympa/Tools/SMIME.pm \
Sympa/Tools/Text.pm \
Sympa/Tools/Time.pm \
Sympa/Tools/WWW.pm \
Sympa/Tracking.pm \
tt2.pm \
Sympa/Upgrade.pm \
Sympa/User.pm \
wwslib.pm
Sympa/User.pm
man3dir = $(mandir)/man3
man3ext = 3Sympa
......
......@@ -35,6 +35,7 @@ use Log;
#use Sympa::Robot;
use Sympa::SQLSource;
use tools;
use Sympa::Tools::Data;
# db structure description has moved in Sympa/Constant.pm
my %db_struct = Sympa::DatabaseDescription::db_struct();
......@@ -698,7 +699,7 @@ sub check_db_field_type {
($effective_type, $effective_size) = ($1, $3);
}
if (tools::smart_eq($effective_type, $required_type)
if (Sympa::Tools::Data::smart_eq($effective_type, $required_type)
and (not defined $required_size or $effective_size >= $required_size))
{
return 1;
......
......@@ -54,13 +54,12 @@ use Sympa::Robot;
use Sympa::Scenario;
use SDM;
use tools;
use Sympa::Tools::File;
use tt2;
use Sympa::User;
my $language = Sympa::Language->instance;
=pod
=head1 SUBFUNCTIONS
This is the description of the subfunctions contained by admin.pm
......@@ -1173,7 +1172,7 @@ sub clone_list_as_empty {
foreach my $subdir ('etc', 'web_tt2', 'mail_tt2', 'data_sources') {
if (-d $new_dir . '/' . $subdir) {
unless (
tools::copy_dir(
Sympa::Tools::File::copy_dir(
$list->{'dir'} . '/' . $subdir,
$new_dir . '/' . $subdir
)
......
......@@ -35,6 +35,7 @@ use Conf;
use Log;
use Sympa::Message;
use tools;
use Sympa::Tools::File;
my $serial_number = 0; # incremented on each archived mail
......@@ -279,8 +280,9 @@ sub clean_archive_directory {
$answer->{'dir_to_rebuild'} = $arc_root . '/' . $dir_to_rebuild;
$answer->{'cleaned_dir'} = $Conf::Conf{'tmpdir'} . '/' . $dir_to_rebuild;
unless (
my $number_of_copies = tools::copy_dir(
$answer->{'dir_to_rebuild'}, $answer->{'cleaned_dir'}
my $number_of_copies = Sympa::Tools::File::copy_dir(
$answer->{'dir_to_rebuild'},
$answer->{'cleaned_dir'}
)
) {
Log::do_log(
......@@ -310,7 +312,7 @@ sub clean_archive_directory {
'Unable to open directory %s: %m',
$answer->{'dir_to_rebuild'}
);
tools::del_dir($answer->{'cleaned_dir'});
Sympa::Tools::File::del_dir($answer->{'cleaned_dir'});
return undef;
}
return $answer;
......@@ -400,7 +402,7 @@ sub convert_single_message {
}
unless (-d $destination_dir) {
unless (tools::mkdir_all($destination_dir, 0755)) {
unless (Sympa::Tools::File::mkdir_all($destination_dir, 0755)) {
Log::do_log('err', 'Unable to create %s', $destination_dir);
return undef;
}
......
......@@ -36,6 +36,8 @@ use Sympa::Robot;
use SDM;
use Sympa::Session;
use tools;
use Sympa::Tools::Data;
use Sympa::Tools::Time;
use Sympa::User;
## return the password finger print (this proc allow futur replacement of md5
......@@ -232,7 +234,7 @@ sub ldap_authentication {
$filter =~ s/\[sender\]/$auth/ig;
## bind in order to have the user's DN
my $param = tools::dup_var($ldap);
my $param = Sympa::Tools::Data::dup_var($ldap);
my $ds = Sympa::LDAPSource->new($param);
unless (defined $ds && ($ldap_anonymous = $ds->connect())) {
......@@ -264,7 +266,7 @@ sub ldap_authentication {
## Duplicate structure first
## Then set the bind_dn and password according to the current user
$param = tools::dup_var($ldap);
$param = Sympa::Tools::Data::dup_var($ldap);
$param->{'ldap_bind_dn'} = $DN[0];
$param->{'ldap_bind_password'} = $pwd;
......@@ -360,7 +362,7 @@ sub get_email_by_net_id {
my $ldap = @{$Conf::Conf{'auth_services'}{$robot}}[$auth_id];
my $param = tools::dup_var($ldap);
my $param = Sympa::Tools::Data::dup_var($ldap);
my $ds = Sympa::LDAPSource->new($param);
my $ldap_anonymous;
......@@ -523,7 +525,7 @@ sub get_one_time_ticket {
my $lockout = Conf::get_robot_conf($robot, 'one_time_ticket_lockout')
|| 'open';
my $lifetime =
tools::duration_conv(
Sympa::Tools::Time::duration_conv(
Conf::get_robot_conf($robot, 'one_time_ticket_lifetime') || 0);
if ($lockout eq 'one_time' and $ticket->{'status'} ne 'open') {
......
......@@ -36,6 +36,7 @@ use Conf;
use Log;
use SDM;
use tools;
use Sympa::Tools::Daemon;
## Database and SQL statement handlers
my $sth;
......@@ -60,7 +61,7 @@ sub next {
Log::do_log('debug', '');
# lock next packet
my $lock = tools::get_lockname();
my $lock = Sympa::Tools::Daemon::get_lockname();
my $order;
my $limit_oracle = '';
......
......@@ -40,6 +40,8 @@ use Sympa::Report;
use Sympa::Robot;
use Sympa::Scenario;
use tools;
use Sympa::Tools::Data;
use Sympa::Tools::File;
use Sympa::User;
my %comms = (
......@@ -2707,9 +2709,10 @@ sub distribute {
|| ($main::daemon_usage == Conf::DAEMON_ALL)) {
my $numsmtp;
$message->{shelved}{dkim_sign} = 1
if tools::is_in_array($list->{'admin'}{'dkim_signature_apply_on'},
'any')
or tools::is_in_array($list->{'admin'}{'dkim_signature_apply_on'},
if Sympa::Tools::Data::is_in_array(
$list->{'admin'}{'dkim_signature_apply_on'}, 'any')
or Sympa::Tools::Data::is_in_array(
$list->{'admin'}{'dkim_signature_apply_on'},
'editor_validated_messages');
$numsmtp = Sympa::List::distribute_msg($message);
......@@ -3021,9 +3024,9 @@ sub confirm {
|| ($main::daemon_usage == Conf::DAEMON_ALL)) {
my $numsmtp;
$message->{shelved}{dkim_sign} = 1
if tools::is_in_array(
if Sympa::Tools::Data::is_in_array(
$list->{'admin'}{'dkim_signature_apply_on'}, 'any')
or tools::is_in_array(
or Sympa::Tools::Data::is_in_array(
$list->{'admin'}{'dkim_signature_apply_on'},
'md5_authenticated_messages');
......@@ -3233,7 +3236,7 @@ sub reject {
close(IN);
Log::do_log('info', 'REJECT %s %s from %s accepted (%d seconds)',
$name, $sender, $key, time - $time_command);
tools::remove_dir($Conf::Conf{'viewmail_dir'} . '/mod/'
Sympa::Tools::File::remove_dir($Conf::Conf{'viewmail_dir'} . '/mod/'
. $list->get_list_id() . '/'
. $key);
unlink($file);
......@@ -3308,8 +3311,8 @@ sub modindex {
Conf::get_robot_conf($robot, 'clean_delay_queuemod');
}
if (tools::get_mtime("$modqueue/$i") < (time - $moddelay * 86400))
{
if (Sympa::Tools::File::get_mtime("$modqueue/$i") <
(time - $moddelay * 86400)) {
unlink("$modqueue/$i");
Log::do_log('notice',
'Deleting unmoderated message %s, too old', $i);
......
......@@ -54,6 +54,7 @@ use Sympa::Regexps;
use Sympa::Robot;
use Sympa::Scenario;
use tools;
use Sympa::Tools::File;
my $language = Sympa::Language->instance;
......@@ -1605,7 +1606,8 @@ sub get_constraints {
Log::do_log('debug3', '(%s)', $self->{'name'});
## load param_constraint.conf
my $time_file = tools::get_mtime("$self->{'dir'}/param_constraint.conf");
my $time_file =
Sympa::Tools::File::get_mtime("$self->{'dir'}/param_constraint.conf");
unless (defined($self->{'param_constraint_conf'})
and $self->{'mtime'}{'param_constraint_conf'} >= $time_file) {
$self->{'param_constraint_conf'} =
......@@ -2975,11 +2977,6 @@ sub _load_param_constraint_conf {
}
}
###########################"
# open TMP, ">/tmp/dump1";
# tools::dump_var ($constraint, 0, \*TMP);
# close TMP;
return $constraint;
}
......
......@@ -64,7 +64,10 @@ use SDM;
use Sympa::SQLSource;
use Sympa::Task;
use tools;
use Sympa::Tools::Data;
use Sympa::Tools::File;
use Sympa::Tools::SMIME;
use Sympa::Tools::Text;
use Sympa::Tracking;
use tt2;
use Sympa::User;
......@@ -889,8 +892,8 @@ sub dump {
# Note: "subscribers" file was deprecated.
$self->{'_mtime'} = {
'config' => tools::get_mtime($self->{'dir'} . '/config'),
'stats' => tools::get_mtime($self->{'dir'} . '/stats'),
'config' => Sympa::Tools::File::get_mtime($self->{'dir'} . '/config'),
'stats' => Sympa::Tools::File::get_mtime($self->{'dir'} . '/stats'),
};
return 1;
......@@ -1028,11 +1031,13 @@ sub load {
$last_time_stats = POSIX::INT_MIN();
}
my $time_config = tools::get_mtime("$self->{'dir'}/config");
my $time_config_bin = tools::get_mtime("$self->{'dir'}/config.bin");
my $time_stats = tools::get_mtime("$self->{'dir'}/stats");
my $main_config_time = tools::get_mtime(Sympa::Constants::CONFIG);
# my $web_config_time = tools::get_mtime(Sympa::Constants::WWSCONFIG);
my $time_config = Sympa::Tools::File::get_mtime("$self->{'dir'}/config");
my $time_config_bin =
Sympa::Tools::File::get_mtime("$self->{'dir'}/config.bin");
my $time_stats = Sympa::Tools::File::get_mtime("$self->{'dir'}/stats");
my $main_config_time =
Sympa::Tools::File::get_mtime(Sympa::Constants::CONFIG);
# my $web_config_time = Sympa::Tools::File::get_mtime(Sympa::Constants::WWSCONFIG);
my $config_reloaded = 0;
my $admin;
......@@ -1317,7 +1322,8 @@ sub get_config_changes {
}
## load config_changes
my $time_file = tools::get_mtime("$self->{'dir'}/config_changes");
my $time_file =
Sympa::Tools::File::get_mtime("$self->{'dir'}/config_changes");
unless (defined $self->{'config_changes'}
&& ($self->{'config_changes'}{'mtime'} >= $time_file)) {
unless ($self->{'config_changes'} =
......@@ -1361,7 +1367,8 @@ sub update_config_changes {
}
## load config_changes
my $time_file = tools::get_mtime("$self->{'dir'}/config_changes");
my $time_file =
Sympa::Tools::File::get_mtime("$self->{'dir'}/config_changes");
unless (defined $self->{'config_changes'}
&& ($self->{'config_changes'}{'mtime'} >= $time_file)) {
unless ($self->{'config_changes'} =
......@@ -1424,7 +1431,7 @@ sub _load_config_changes_file {
close FILE;
$config_changes->{'mtime'} =
tools::get_mtime("$self->{'dir'}/config_changes");
Sympa::Tools::File::get_mtime("$self->{'dir'}/config_changes");
return $config_changes;
}
......@@ -1602,7 +1609,7 @@ sub distribute_msg {
}
# Will this message be processed?
if (tools::is_in_array(
if (Sympa::Tools::Data::is_in_array(
$self->{'admin'}{'dmarc_protection'}{'mode'}, 'all'
)
) {
......@@ -1611,7 +1618,7 @@ sub distribute_msg {
}
if ( !$mungeFrom
and $dkimSignature
and tools::is_in_array(
and Sympa::Tools::Data::is_in_array(
$self->{'admin'}{'dmarc_protection'}{'mode'},
'dkim_signature'
)
......@@ -1622,7 +1629,7 @@ sub distribute_msg {
if ( !$mungeFrom
and $origFrom
and $dkimdomain
and tools::is_in_array(
and Sympa::Tools::Data::is_in_array(
$self->{'admin'}{'dmarc_protection'}{'mode'},
'domain_regex'
)
......@@ -1634,12 +1641,12 @@ sub distribute_msg {
if ( !$mungeFrom
and $origFrom
and (
tools::is_in_array(
Sympa::Tools::Data::is_in_array(
$self->{'admin'}{'dmarc_protection'}{'mode'},
'dmarc_reject')
or tools::is_in_array(
or Sympa::Tools::Data::is_in_array(
$self->{'admin'}{'dmarc_protection'}{'mode'}, 'dmarc_any')
or tools::is_in_array(
or Sympa::Tools::Data::is_in_array(
$self->{'admin'}{'dmarc_protection'}{'mode'},
'dmarc_quarantine'
)
......@@ -1661,7 +1668,7 @@ sub distribute_msg {
my $rr (grep { $_->type eq 'TXT' } $packet->answer) {
next if ($rr->string !~ /v=DMARC/);
if (!$mungeFrom
and tools::is_in_array(
and Sympa::Tools::Data::is_in_array(
$self->{'admin'}{'dmarc_protection'}{'mode'},
'dmarc_reject'
)
......@@ -1675,7 +1682,7 @@ sub distribute_msg {
}
}
if (!$mungeFrom
and tools::is_in_array(
and Sympa::Tools::Data::is_in_array(
$self->{'admin'}{'dmarc_protection'}{'mode'},
'dmarc_quarantine'
)
......@@ -1689,7 +1696,7 @@ sub distribute_msg {
}
}
if (!$mungeFrom
and tools::is_in_array(
and Sympa::Tools::Data::is_in_array(
$self->{'admin'}{'dmarc_protection'}{'mode'},
'dmarc_any'
)
......@@ -1914,13 +1921,13 @@ sub distribute_msg {
my @apply_tracking = ();
push @apply_tracking, 'dsn'
if tools::smart_eq(
if Sympa::Tools::Data::smart_eq(
$self->{'admin'}{'tracking'}->{'delivery_status_notification'}, 'on');
push @apply_tracking, 'mdn'
if tools::smart_eq(
if Sympa::Tools::Data::smart_eq(
$self->{'admin'}{'tracking'}->{'message_delivery_notification'}, 'on')
or (
tools::smart_eq(
Sympa::Tools::Data::smart_eq(
$self->{'admin'}{'tracking'}->{'message_delivery_notification'},
'on_demand')
and $message->get_header('Disposition-Notification-To')
......@@ -2036,8 +2043,11 @@ sub distribute_msg {
## store msg in digest if list accept digest mode (encrypted message can't
## be included in digest)
if ($self->is_digest()
and not tools::smart_eq($message->{'smime_crypted'}, 'smime_crypted'))
{
and not Sympa::Tools::Data::smart_eq(
$message->{'smime_crypted'},
'smime_crypted'
)
) {
$self->store_digest($message);
}
......@@ -2481,7 +2491,8 @@ sub send_msg {
my $verp_rate = $self->{'admin'}{'verp_rate'};
# force VERP if tracking is requested.
$verp_rate = '100%'
if tools::smart_eq($message->{shelved}{tracking}, qr/dsn|mdn/);
if Sympa::Tools::Data::smart_eq($message->{shelved}{tracking},
qr/dsn|mdn/);
my $xsequence = $self->{'stats'}->[0];
my $tags_to_use;
......@@ -2635,7 +2646,8 @@ sub _mail_message {
# Shelve personalization.
$message->{shelved}{merge} = 1
if tools::smart_eq($list->{'admin'}{'merge_feature'}, 'on');
if Sympa::Tools::Data::smart_eq($list->{'admin'}{'merge_feature'},
'on');
# Shelve re-encryption with S/MIME.
$message->{shelved}{smime_encrypt} = 1
if $message->{'smime_crypted'};
......@@ -3232,8 +3244,9 @@ sub archive_send {
$param->{'boundary2'} = tools::get_message_id($self->{'domain'});
$param->{'from'} = Conf::get_robot_conf($self->{'domain'}, 'sympa');
# open TMP2, ">/tmp/digdump"; tools::dump_var($param, 0, \*TMP2); close
# TMP2;
# open TMP2, ">/tmp/digdump";
# Sympa::Tools::Data::dump_var($param, 0, \*TMP2);
# close TMP2;