Commit 9f1a1b59 authored by sikeda's avatar sikeda
Browse files

[dev] Normalize function calls.

- Use "fn()" instead of "&fn" or "&fn()".
- Use fully-qualified name "PKG::fn" instead of exported "fn".

These changes are also to make current branch be more sync in trunk.


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@10697 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent e14a0772
......@@ -61,7 +61,7 @@ my $msg_count = 0;
$| = 1;
my %opt;
unless (&GetOptions(\%opt, 'input-directory=s')) {
unless (GetOptions(\%opt, 'input-directory=s')) {
die("Unknown options.");
}
......@@ -171,7 +171,7 @@ if ($opt{'input-directory'}) {
#}
## Store messages in web arc
&store_messages(\@msgs, $dest_dir);
store_messages(\@msgs, $dest_dir);
}
}
......
......@@ -58,7 +58,7 @@ while ($user = $sth->fetchrow_hashref('NAME_lc')) {
printf "\n%s", $user->{'email_user'};
my $crypted_password = &tools::crypt_password($user->{'password_user'});
my $crypted_password = tools::crypt_password($user->{'password_user'});
printf " => %s", $crypted_password;
......
......@@ -20,9 +20,9 @@ use SDM;
unless (Conf::load(Sympa::Constants::CONFIG)) {
die "Can't load Sympa configuration file";
}
&Log::do_openlog($Conf{'syslog'}, $Conf{'log_socket_type'}, 'sympa');
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'}, 'sympa');
if ($Conf{'db_name'} and $Conf{'db_type'}) {
if ($Conf::Conf{'db_name'} and $Conf::Conf{'db_type'}) {
unless (SDM::probe_db()) {
die "Sympa can't connect to database";
}
......@@ -33,10 +33,10 @@ $( = $) = (getgrnam(Sympa::Constants::GROUP))[2];
$< = $> = (getpwnam(Sympa::Constants::USER))[2];
# Sets the UMASK
umask(oct($Conf{'umask'}));
umask(oct($Conf::Conf{'umask'}));
## Loads message list
unless (opendir SPOOL, $Conf{'queuemod'}) {
unless (opendir SPOOL, $Conf::Conf{'queuemod'}) {
die "Unable to read spool";
}
......@@ -47,11 +47,11 @@ foreach my $msg ( sort grep(!/^\./, readdir SPOOL )) {
my ($listaddress, $modkey) = ($1, $2);
if (-d "$Conf{'queuemod'}/.$msg") {
if (-d "$Conf::Conf{'queuemod'}/.$msg") {
next;
}
print "Creating HTML version for $Conf{'queuemod'}/$msg\n";
print "Creating HTML version for $Conf::Conf{'queuemod'}/$msg\n";
my ($listname, $listrobot) = split /\@/, $listaddress;
my $self = new List ($listname, $listrobot);
......@@ -61,7 +61,7 @@ foreach my $msg ( sort grep(!/^\./, readdir SPOOL )) {
my $name = $self->{'name'};
my $host = $admin->{'host'};
my $robot = $self->{'domain'};
my $modqueue = $Conf{'queuemod'};
my $modqueue = $Conf::Conf{'queuemod'};
unless ($name && $admin) {
print STDERR "Unkown list $listaddress, skipping\n";
next;
......@@ -80,13 +80,13 @@ foreach my $msg ( sort grep(!/^\./, readdir SPOOL )) {
## generate HTML
chdir $tmp_dir;
my $mhonarc = &Conf::get_robot_conf($robot, 'mhonarc');
my $mhonarc = Conf::get_robot_conf($robot, 'mhonarc');
open ARCMOD, "$mhonarc -single -rcfile $mhonarc_ressources -definevars listname=$name -definevars hostname=$host $modqueue/$name\_$modkey|";
open MSG, ">msg00000.html";
print MSG <ARCMOD>;
close MSG;
close ARCMOD;
chdir $Conf{'home'};
chdir $Conf::Conf{'home'};
}
}
closedir SPOOL;
......
......@@ -36,25 +36,25 @@ use SDM;
my $sympa_conf_file = Sympa::Constants::CONFIG;
## Load sympa config
unless (&Conf::load($sympa_conf_file)) {
unless (Conf::load($sympa_conf_file)) {
die 'config_error';
}
## Probe Db if defined
if ($Conf{'db_name'} and $Conf{'db_type'}) {
if ($Conf::Conf{'db_name'} and $Conf::Conf{'db_type'}) {
unless (SDM::probe_db()) {
&die('Database %s defined in sympa.conf has not the right structure or is unreachable. If you don\'t use any database, comment db_xxx parameters in sympa.conf', $Conf{'db_name'});
die('Database %s defined in sympa.conf has not the right structure or is unreachable. If you don\'t use any database, comment db_xxx parameters in sympa.conf', $Conf::Conf{'db_name'});
}
}
my $openssl = $Conf{'openssl'};
my $home_sympa = $Conf{'home'};
my $outpass = $Conf{'key_passwd'};
my $etc_dir = $Conf{'etc'};
my $openssl = $Conf::Conf{'openssl'};
my $home_sympa = $Conf::Conf{'home'};
my $outpass = $Conf::Conf{'key_passwd'};
my $etc_dir = $Conf::Conf{'etc'};
## Check option
my %options;
&GetOptions(\%main::options, 'pkcs12=s','listname=s', 'robot=s', 'help|h');
GetOptions(\%main::options, 'pkcs12=s','listname=s', 'robot=s', 'help|h');
$main::options{'foreground'} = 1;
my $listname = $main::options{'listname'};
......@@ -68,7 +68,7 @@ if (($main::options{'help'} ne '') ||
!(-r $main::options{'pkcs12'}) ||
(($main::options{'listname'} ne '') && ($main::options{'robot'} ne ''))
){
&print_usage();
print_usage();
}else{
if ($listname) {
......@@ -80,12 +80,12 @@ if (($main::options{'help'} ne '') ||
die;
}
}elsif($robot) {
if (-d $Conf{'etc'}.'/'.$robot) {
$cert = $Conf{'etc'}.'/'.$robot.'/cert.pem';
$privatekey = $Conf{'etc'}.'/'.$robot.'/private_key';
if (-d $Conf::Conf{'etc'}.'/'.$robot) {
$cert = $Conf::Conf{'etc'}.'/'.$robot.'/cert.pem';
$privatekey = $Conf::Conf{'etc'}.'/'.$robot.'/private_key';
}else{
$cert = $Conf{'etc'}.'/cert.pem';
$privatekey = $Conf{'etc'}.'/private_key';
$cert = $Conf::Conf{'etc'}.'/cert.pem';
$privatekey = $Conf::Conf{'etc'}.'/private_key';
}
}
......@@ -147,8 +147,8 @@ For a list certificat, the file will be installed in
$home_sympa/<listname>/cert.pem and $home_sympa/<listname>/private_key
For Sympa itself a certificate will be installed in
$Conf{'etc'}/<robot>/cert.pem and $Conf{'etc'}/<robot>/private_key or
$Conf{'etc'}/cert.pem and Conf{'etc'}/private_key
$Conf::Conf{'etc'}/<robot>/cert.pem and $Conf::Conf{'etc'}/<robot>/private_key or
$Conf::Conf{'etc'}/cert.pem and Conf{'etc'}/private_key
You are then prompted for inpassword (the password used to encrypt the
......
......@@ -67,7 +67,7 @@ $0 --soap_url=<soap sympa server url> --cookie=sympauser=someone\@cru.fr
";
my %options;
unless (&GetOptions(\%main::options, 'soap_url=s', 'service=s', 'trusted_application=s', 'trusted_application_password=s','user_email=s', 'user_password=s','cookie=s','proxy_vars=s','service_parameters=s','session_id=s')) {
unless (GetOptions(\%main::options, 'soap_url=s', 'service=s', 'trusted_application=s', 'trusted_application_password=s','user_email=s', 'user_password=s','cookie=s','proxy_vars=s','service_parameters=s','session_id=s')) {
printf "";
}
......@@ -106,15 +106,15 @@ if (defined $trusted_application) {
exit;
}
&play_soap_as_trusted($soap_url, $trusted_application, $trusted_application_password, $service, $proxy_vars, $service_parameters);
play_soap_as_trusted($soap_url, $trusted_application, $trusted_application_password, $service, $proxy_vars, $service_parameters);
}elsif($service eq 'getUserEmailByCookie'){
&play_soap(soap_url => $soap_url,
play_soap(soap_url => $soap_url,
session_id => $session_id,
service => $service);
}elsif(defined $cookie){
printf "error : get_email_cookie\n";
&get_email($soap_url, $cookie);
get_email($soap_url, $cookie);
exit;
}else{
unless (defined $session_id || (defined $user_email && defined $user_password)){
......@@ -123,7 +123,7 @@ if (defined $trusted_application) {
exit;
}
&play_soap(soap_url => $soap_url,
play_soap(soap_url => $soap_url,
user_email => $user_email,
user_password => $user_password,
session_id => $session_id,
......@@ -153,7 +153,7 @@ sub play_soap_as_trusted{
printf "calling authenticateRemoteAppAndRun( $trusted_application, $trusted_application_password, $proxy_vars,$service,$p)\n";
my $reponse = $soap->authenticateRemoteAppAndRun( $trusted_application, $trusted_application_password, $proxy_vars,$service,\@parameters);
&print_result($reponse);
print_result($reponse);
}
sub get_email {
......@@ -179,7 +179,7 @@ sub get_email {
print "\n\ngetEmailUserByCookie....\n";
$reponse = $soap->getUserEmailByCookie($cookie);
&print_result($reponse);
print_result($reponse);
exit;
}
......@@ -232,7 +232,7 @@ sub play_soap{
#$reponse = $soap->casLogin($soap_url);
$reponse = $soap->login($user_email,$user_password);
$cookies->save;
&print_result($reponse);
print_result($reponse);
$session_id = $reponse->result;
}
......@@ -270,7 +270,7 @@ sub play_soap{
$reponse = $soap->authenticateAndRun($user_email,$session_id,$service,\@parameters);
}
&print_result($reponse);
print_result($reponse);
}
......@@ -294,7 +294,7 @@ sub print_result {
}else {
@ret = $r->result;
}
&tools::dump_var(\@ret, 0, \*STDOUT);
tools::dump_var(\@ret, 0, \*STDOUT);
}
return 1;
......
......@@ -28,7 +28,7 @@ use warnings;
use Getopt::Long;
my %opt;
unless (&GetOptions(\%opt, 'host=s', 'suffix=s', 'filter=s','attrs=s', 'ssl=s', 'scope=s')) {
unless (GetOptions(\%opt, 'host=s', 'suffix=s', 'filter=s','attrs=s', 'ssl=s', 'scope=s')) {
die "Unknown options.";
}
......
......@@ -32,7 +32,7 @@ use Conf;
use Log;
my %options;
&GetOptions(\%main::options, 'debug|d', 'log_level=s', 'config|f=s');
GetOptions(\%main::options, 'debug|d', 'log_level=s', 'config|f=s');
## Load configuration file
unless (Conf::load()) {
......@@ -42,14 +42,14 @@ unless (Conf::load()) {
## Open the syslog and say we're read out stuff.
&Log::do_openlog($Conf{'syslog'}, $Conf{'log_socket_type'}, 'sympa');
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'}, 'sympa');
# setting log_level using conf unless it is set by calling option
if ($main::options{'log_level'}) {
Log::do_log('info', "Logs seems OK, log level set using options : $main::options{'log_level'}");
}else{
&Log::set_log_level($Conf{'log_level'});
Log::do_log('info', "Logs seems OK, default log level $Conf{'log_level'}");
Log::set_log_level($Conf::Conf{'log_level'});
Log::do_log('info', "Logs seems OK, default log level $Conf::Conf{'log_level'}");
}
printf "Ok, now check logs \n";
......
......@@ -50,9 +50,9 @@ unless (Conf::load()) {
die 'config_error';
}
if ($Conf{'db_name'} and $Conf{'db_type'}) {
if ($Conf::Conf{'db_name'} and $Conf::Conf{'db_type'}) {
unless ($List::use_db = SDM::probe_db()) {
&die('Database %s defined in sympa.conf has not the right structure or is unreachable. If you don\'t use any database, comment db_xxx parameters in sympa.conf', $Conf{'db_name'});
die('Database %s defined in sympa.conf has not the right structure or is unreachable. If you don\'t use any database, comment db_xxx parameters in sympa.conf', $Conf::Conf{'db_name'});
}
}
......@@ -64,7 +64,7 @@ if ($#ARGV >=0) {
die "unable to find file $f";
}
&convert($f);
convert($f);
exit 0;
}
......@@ -122,7 +122,7 @@ foreach my $vr (keys %{$Conf::Conf{'robots'}}) {
}
## Search in V. Robot Lists
my $listOfLists = &List::get_lists($vr);
my $listOfLists = List::get_lists($vr);
foreach my $list ( @$listOfLists ) {
push @directories, $list->{'dir'};
......@@ -207,24 +207,24 @@ foreach my $tpl (@templates) {
## Create directory if required
unless (-d $dest_path) {
printf "Creating $dest_path directory\n";
unless (&my_mkdir ($dest_path)) {
unless (my_mkdir ($dest_path)) {
printf STDERR "Error : Cannot create $dest_path directory : $!\n";
next;
}
unless (&tools::set_file_rights(file => $dest_path,
unless (tools::set_file_rights(file => $dest_path,
user => Sympa::Constants::USER,
group => Sympa::Constants::GROUP,
mode => 0755,
))
{
&Log::do_log('err','Unable to set rights on %s',$Conf{'db_name'});
Log::do_log('err','Unable to set rights on %s',$Conf::Conf{'db_name'});
next;
}
}
my $tt2 = "$dest_path/$dest_file";
&convert($tpl, $tt2);
convert($tpl, $tt2);
$total++;
## Rename old files to .converted
......@@ -264,12 +264,12 @@ sub convert {
printf "Template file $in_file has been converted to $out_file\n";
unless (&tools::set_file_rights(file => $out_file,
unless (tools::set_file_rights(file => $out_file,
user => Sympa::Constants::USER,
group => Sympa::Constants::GROUP
))
{
&Log::do_log('err','Unable to set rights on %s',$Conf{'db_name'});
Log::do_log('err','Unable to set rights on %s',$Conf::Conf{'db_name'});
return undef;
}
}
......
......@@ -65,17 +65,17 @@ Log::do_log('info', 'SOAP server launched');
$< = $>; ## UID
$( = $); ## GID
unless (&SDM::check_db_connect()) {
&Log::do_log('err','SOAP server requires a RDBMS to run');
unless (SDM::check_db_connect()) {
Log::do_log('err','SOAP server requires a RDBMS to run');
}
## The process should not fork for sending mail
## Messages will be spooled instead
&mail::set_send_spool($Conf{'queue'});
mail::set_send_spool($Conf::Conf{'queue'});
## Loading all Lists at startup, in order to increase execution speed
my $all_lists = &List::get_lists('*');
my $all_lists = List::get_lists('*');
foreach my $list (@$all_lists){
## Nothing to do here
}
......
This diff is collapsed.
......@@ -27,9 +27,9 @@ package Archive;
use strict;
use warnings;
use Carp qw(croak);
use Cwd qw(getcwd);
use Encode qw(decode_utf8 encode_utf8);
use HTML::Entities qw(decode_entities);
use Cwd qw();
use Encode qw();
use HTML::Entities qw();
use Log;
......@@ -43,7 +43,7 @@ my $serial_number = 0; # incremented on each archived mail
sub store_last {
my($list, $msg) = @_;
&Log::do_log ('debug2','archive::store ()');
Log::do_log ('debug2','archive::store ()');
my($filename, $newfile);
......@@ -71,18 +71,18 @@ sub store_last {
sub list {
my $name = shift;
&Log::do_log ('debug',"archive::list($name)");
Log::do_log ('debug',"archive::list($name)");
my($filename, $newfile);
my(@l, $i);
unless (-d "$name") {
&Log::do_log ('warning',"archive::list($name) failed, no directory $name");
Log::do_log ('warning',"archive::list($name) failed, no directory $name");
# @l = ($msg::no_archives_available);
return @l;
}
unless (opendir(DIR, "$name")) {
&Log::do_log ('warning',"archive::list($name) failed, cannot open directory $name");
Log::do_log ('warning',"archive::list($name) failed, cannot open directory $name");
# @l = ($msg::no_archives_available);
return @l;
}
......@@ -100,10 +100,10 @@ sub scan_dir_archive {
my($dir, $month) = @_;
&Log::do_log ('info',"archive::scan_dir_archive($dir, $month)");
Log::do_log ('info',"archive::scan_dir_archive($dir, $month)");
unless (opendir (DIR, "$dir/$month/arctxt")){
&Log::do_log ('info',"archive::scan_dir_archive($dir, $month): unable to open dir $dir/$month/arctxt");
Log::do_log ('info',"archive::scan_dir_archive($dir, $month): unable to open dir $dir/$month/arctxt");
return undef;
}
......@@ -111,27 +111,27 @@ sub scan_dir_archive {
my $i = 0 ;
foreach my $file (sort readdir(DIR)) {
next unless ($file =~ /^\d+$/);
&Log::do_log ('debug',"archive::scan_dir_archive($dir, $month): start parsing message $dir/$month/arctxt/$file");
Log::do_log ('debug',"archive::scan_dir_archive($dir, $month): start parsing message $dir/$month/arctxt/$file");
my $mail = new Message({'file'=>"$dir/$month/arctxt/$file",'noxsympato'=>'noxsympato'});
unless (defined $mail) {
&Log::do_log('err', 'Unable to create Message object %s', $file);
Log::do_log('err', 'Unable to create Message object %s', $file);
return undef;
}
&Log::do_log('debug',"MAIL object : $mail");
Log::do_log('debug',"MAIL object : $mail");
$i++;
my $msg = {};
$msg->{'id'} = $i;
$msg->{'subject'} = &tools::decode_header($mail, 'Subject');
$msg->{'from'} = &tools::decode_header($mail, 'From');
$msg->{'date'} = &tools::decode_header($mail, 'Date');
$msg->{'subject'} = tools::decode_header($mail, 'Subject');
$msg->{'from'} = tools::decode_header($mail, 'From');
$msg->{'date'} = tools::decode_header($mail, 'Date');
$msg->{'full_msg'} = $mail->{'msg'}->as_string;
&Log::do_log('debug','Archive::scan_dir_archive adding message %s in archive to send', $msg->{'subject'});
Log::do_log('debug','Archive::scan_dir_archive adding message %s in archive to send', $msg->{'subject'});
push @{$all_msg}, $msg ;
}
......@@ -156,18 +156,18 @@ sub search_msgid {
my($dir, $msgid) = @_;
&Log::do_log ('info',"archive::search_msgid($dir, $msgid)");
Log::do_log ('info',"archive::search_msgid($dir, $msgid)");
if ($msgid =~ /NO-ID-FOUND\.mhonarc\.org/) {
&Log::do_log('err','remove_arc: no message id found');return undef;
Log::do_log('err','remove_arc: no message id found');return undef;
}
unless ($dir =~ /\d\d\d\d\-\d\d\/arctxt/) {
&Log::do_log ('info',"archive::search_msgid : dir $dir look unproper");
Log::do_log ('info',"archive::search_msgid : dir $dir look unproper");
return undef;
}
unless (opendir (ARC, "$dir")){
&Log::do_log ('info',"archive::scan_dir_archive($dir, $msgid): unable to open dir $dir");
Log::do_log ('info',"archive::scan_dir_archive($dir, $msgid): unable to open dir $dir");
return undef;
}
chomp $msgid ;
......@@ -205,7 +205,7 @@ sub last_path {
my $list = shift;
&Log::do_log('debug', 'Archived::last_path(%s)', $list->{'name'});
Log::do_log('debug', 'Archived::last_path(%s)', $list->{'name'});
return undef unless ($list->is_archived());
my $file = $list->{'dir'}.'/archives/last_message';
......@@ -220,11 +220,11 @@ sub last_path {
sub load_html_message {
my %parameters = @_;
&Log::do_log ('debug2',$parameters{'file_path'});
Log::do_log ('debug2',$parameters{'file_path'});
my %metadata;
unless (open ARC, $parameters{'file_path'}) {
&Log::do_log('err', "Failed to load message '%s' : $!", $parameters{'file_path'});
Log::do_log('err', "Failed to load message '%s' : $!", $parameters{'file_path'});
return undef;
}
......@@ -233,7 +233,7 @@ sub load_html_message {
if (/^<!--(\S+): (.*) -->$/) {
my ($key, $value) = ($1, $2);
$value = encode_utf8(decode_entities(decode_utf8($value)));
$value = Encode::encode_utf8(HTML::Entities::decode_entities(Encode::decode_utf8($value)));
if ($key eq 'X-From-R13') {
$metadata{'X-From'} = $value;
$metadata{'X-From'} =~ tr/N-Z[@A-Mn-za-m/@A-Z[a-z/; ## Mhonarc protection of email addresses
......@@ -258,12 +258,12 @@ 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(
my $number_of_copies = tools::copy_dir(
$answer->{'dir_to_rebuild'},
$answer->{'cleaned_dir'}
)
) {
&Log::do_log(
Log::do_log(
'err',
"Unable to create a temporary directory where to store files for HTML escaping (%s). Cancelling.",
$number_of_copies
......@@ -279,18 +279,18 @@ sub clean_archive_directory {
}
closedir DIR;
if ($files_left_uncleaned) {
&Log::do_log('err',
Log::do_log('err',
"HTML cleaning failed for %s files in the directory %s.",
$files_left_uncleaned, $answer->{'dir_to_rebuild'});
}
$answer->{'dir_to_rebuild'} = $answer->{'cleaned_dir'};
} else {
&Log::do_log(
Log::do_log(
'err',
'Unable to open directory %s: %s',
$answer->{'dir_to_rebuild'}, $!
);
&tools::del_dir($answer->{'cleaned_dir'});
tools::del_dir($answer->{'cleaned_dir'});
return undef;
}
return $answer;
......@@ -391,7 +391,7 @@ sub convert_single_message {
close OUT;
# mhonarc require du change workdir so this proc must retore it
my $pwd = getcwd();
my $pwd = Cwd::getcwd();
## generate HTML
unless (chdir $destination_dir) {
......
......@@ -38,13 +38,13 @@ use SDM;
## return the password finger print (this proc allow futur replacement of md5 by sha1 or ....)
sub password_fingerprint{
&Log::do_log('debug', 'Auth::password_fingerprint');
Log::do_log('debug', 'Auth::password_fingerprint');
my $pwd = shift;
if(&Conf::get_robot_conf('*','password_case') eq 'insensitive') {
return &tools::md5_fingerprint(lc($pwd));
if(Conf::get_robot_conf('*','password_case') eq 'insensitive') {
return tools::md5_fingerprint(lc($pwd));
}else{
return &tools::md5_fingerprint($pwd);
return tools::md5_fingerprint($pwd);
}
}
......@@ -54,19 +54,19 @@ sub password_fingerprint{
my $robot = shift;
my $auth = shift; ## User email or UID
my $pwd = shift; ## Password
&Log::do_log('debug', 'Auth::check_auth(%s)', $auth);
Log::do_log('debug', 'Auth::check_auth(%s)', $auth);
my ($canonic, $user);
if( &tools::valid_email($auth)) {
return &authentication($robot, $auth,$pwd);
if( tools::valid_email($auth)) {
return authentication($robot, $auth,$pwd);
}else{
## This is an UID
foreach my $ldap (@{$Conf{'auth_services'}{$robot}}){
foreach my $ldap (@{$Conf::Conf{'auth_services'}{$robot}}){
# only ldap service are to be applied here
next unless ($ldap->{'auth_type'} eq 'ldap');
$canonic = &ldap_authentication($robot, $ldap, $auth,$pwd,'uid_filter');
$canonic = ldap_authentication($robot, $ldap, $auth,$pwd,'uid_filter');
last if ($canonic); ## Stop at first match
}
if ($canonic){
......@@ -80,8 +80,8 @@ sub password_fingerprint{
};
}else{
&report::reject_report_web('user','incorrect_passwd',{}) unless ($ENV{'SYMPA_SOAP'});