Unverified Commit 16222846 authored by IKEDA Soji's avatar IKEDA Soji Committed by GitHub
Browse files

Merge pull request #1094 from ikedas/issue-1091 by ikedas

Obsolete `cookie` parameter (#1091)
parents a58ee68d 1a1df2a2
......@@ -32,7 +32,7 @@ nobase_default_DATA = \
create_list.conf \
edit_list.conf \
ldap_alias_entry.tt2 \
mhonarc-ressources.tt2 \
mhonarc_rc.tt2 \
mime.types \
nrcpt_by_domain.conf \
sympa.wsdl \
......
......@@ -1873,7 +1873,7 @@ div.admin_cmd a {
}
[%~ END # IF 0 ~%]
/* Calendar in mhonarc-ressources.tt2 */
/* Calendar in mhonarc_rc.tt2 */
ul.calendar {
margin-left:0!important;
padding-left:0!important;
......@@ -1919,7 +1919,7 @@ ul li.calendarLinksInactive {
ul li.calendarYear {
border: 1px solid;
}
/* end calendar in mhonarc-ressources.tt2 */
/* end calendar in mhonarc_rc.tt2 */
abbr,
acronym,
......
......@@ -165,7 +165,7 @@ foreach my $tpl (@templates) {
if ($tpl =~ /mhonarc\-ressources$/) {
rename $tpl, "$tpl.incompatible";
printf STDERR
"File $tpl could not be translated to TT2 ; it has been renamed $tpl.incompatible. You should customize a standard mhonarc-ressourses.tt2 file\n";
"File $tpl could not be translated to TT2 ; it has been renamed $tpl.incompatible. You should customize a standard mhonarc_rc.tt2 file\n";
next;
}
......
......@@ -58,6 +58,12 @@ unless (Conf::load(Conf::get_sympa_conf(), 'no_db')) {
die sprintf 'Configuration file %s has errors.\n', Conf::get_sympa_conf();
}
# Get obsoleted parameter.
open my $fh, '<', Conf::get_sympa_conf() or die $ERRNO;
my ($cookie) =
grep {defined} map { /\A\s*cookie\s+(\S+)/s ? $1 : undef } <$fh>;
close $fh;
# Set the User ID & Group ID for the process
$GID = $EGID = (getgrnam(Sympa::Constants::GROUP))[2];
$UID = $EUID = (getpwnam(Sympa::Constants::USER))[2];
......@@ -131,12 +137,7 @@ sub process {
sub sympa_checksum {
my $rcpt = shift;
return (
substr(
Digest::MD5::md5_hex(join('/', $Conf::Conf{'cookie'}, $rcpt)),
-10
)
);
return substr Digest::MD5::md5_hex(join '/', $cookie, $rcpt), -10;
}
__END__
......@@ -182,6 +183,8 @@ Following site configuration parameters in F<--CONFIG--> are referred.
=item cookie
(obsoleted by Sympa 6.2.61b)
=item queue
=item umask
......
......@@ -30,6 +30,7 @@ use lib split(/:/, $ENV{SYMPALIB} || ''), '--modulesdir--';
use strict;
use warnings;
use Digest::MD5;
use English qw(-no_match_vars);
use Getopt::Long;
use MIME::Base64 qw();
use Time::HiRes qw(gettimeofday tv_interval);
......@@ -82,6 +83,12 @@ if ($dry_run) {
die 'Error in configuration'
unless Conf::load($config, 'no_db');
# Get obsoleted parameter.
open my $fh, '<', $config or die $ERRNO;
my ($cookie) =
grep {defined} map { /\A\s*cookie\s+(\S+)/s ? $1 : undef } <$fh>;
close $fh;
my $password_hash = Conf::get_robot_conf('*', 'password_hash');
my $bcrypt_cost = Conf::get_robot_conf('*', 'bcrypt_cost');
......@@ -274,7 +281,7 @@ sub _decrypt_rc4_password {
return $inpasswd unless $inpasswd =~ /\Acrypt[.](.*)\z/;
$inpasswd = $1;
$rc4 = Crypt::CipherSaber->new($Conf::Conf{'cookie'}) unless $rc4;
$rc4 = Crypt::CipherSaber->new($cookie) unless $rc4;
return $rc4->decrypt(MIME::Base64::decode($inpasswd));
}
......
......@@ -1023,11 +1023,6 @@ unless (Conf::data_structure_uptodate()) {
$maintenance_mode = 1;
$log->syslog('err',
'WWSympa set to maintenance mode; you should run sympa.pl --upgrade');
} elsif (Conf::cookie_changed()) {
$maintenance_mode = 1;
$log->syslog('err',
'WWSympa set to maintenance mode; sympa.conf/cookie parameter has changed.'
);
}
 
our %in;
......@@ -1096,7 +1091,6 @@ while ($query = Sympa::WWW::FastCGI->new) {
## If in maintenance mode, check if the data structure is now uptodate
if ( $maintenance_mode
and Conf::data_structure_uptodate()
and not Conf::cookie_changed()
and ($EUID eq (getpwnam(Sympa::Constants::USER))[2])) {
$maintenance_mode = undef;
$log->syslog('notice',
......@@ -3994,44 +3988,8 @@ sub sendssopasswd {
 
my $url_redirect;
 
if ($param->{'newuser'} = Sympa::User::get_global_user($email)) {
## Create a password if none
unless ($param->{'newuser'}{'password'}) {
unless (
Sympa::User::update_global_user(
$email,
{ 'password' =>
Sympa::Tools::Password::tmp_passwd($email)
}
)
) {
Sympa::WWW::Report::reject_report_web('intern',
'db_update_failed',
{}, $param->{'action'}, '', $param->{'user'}{'email'},
$robot);
wwslog('info', 'Update failed');
web_db_log(
{ 'parameters' => $email,
'target_email' => $email,
'status' => 'error',
'error_type' => "internal"
}
);
return undef;
}
$param->{'newuser'}{'password'} =
Sympa::Tools::Password::tmp_passwd($email);
}
} else {
$param->{'newuser'} = {
'email' => $email,
'password' => Sympa::Tools::Password::tmp_passwd($email)
};
}
$param->{'newuser'} =
Sympa::User::get_global_user($email) || {'email' => $email};
 
$param->{'init_passwd'} = 1
if ($param->{'user'}{'password'} =~ /^init/);
......
......@@ -705,45 +705,8 @@ sub data_structure_uptodate {
# Check if cookie parameter was changed.
# Old name: tools::cookie_changed().
sub cookie_changed {
my $current = $Conf::Conf{'cookie'};
$current = '' unless defined $current;
my $changed = 1;
if (-f "$Conf::Conf{'etc'}/cookies.history") {
my $fh;
unless (open $fh, "$Conf::Conf{'etc'}/cookies.history") {
$log->syslog('err', 'Unable to read %s/cookies.history',
$Conf::Conf{'etc'});
return undef;
}
my $oldcook = <$fh>;
close $fh;
($oldcook) = reverse split /\s+/, $oldcook;
$oldcook = '' unless defined $oldcook;
if ($oldcook eq $current) {
$log->syslog('debug2', 'Cookie is stable');
$changed = 0;
}
return $changed;
} else {
my $umask = umask 037;
unless (open COOK, ">$Conf::Conf{'etc'}/cookies.history") {
umask $umask;
$log->syslog('err', 'Unable to create %s/cookies.history',
$Conf::Conf{'etc'});
return undef;
}
umask $umask;
chown [getpwnam(Sympa::Constants::USER)]->[2],
[getgrnam(Sympa::Constants::GROUP)]->[2],
"$Conf::Conf{'etc'}/cookies.history";
print COOK "$current ";
close COOK;
return (0);
}
}
# Deprecated: No longer used.
#sub cookie_changed;
## Check a few files
sub checkfiles {
......
......@@ -30,7 +30,6 @@ package Sympa::Archive;
use strict;
use warnings;
use Cwd qw();
use Digest::MD5 qw();
use Encode qw();
use English qw(-no_match_vars);
use File::Path qw();
......@@ -490,8 +489,7 @@ sub html_store {
return undef;
}
my $mhonarc_ressources =
Sympa::search_fullpath($list, 'mhonarc-ressources.tt2');
my $mhonarc_rc = Sympa::search_fullpath($list, 'mhonarc_rc.tt2');
$log->syslog(
'debug',
......@@ -499,18 +497,16 @@ sub html_store {
Conf::get_robot_conf($list->{'domain'}, 'mhonarc'), $list
);
my $tag = _get_tag($list);
# Call mhonarc on cleaned message source to make clean htlm view of
# message.
my @cmd = (
Conf::get_robot_conf($list->{'domain'}, 'mhonarc'),
'-add',
'-addressmodifycode' => '1', # w/a: Clear old cache in .mhonarc.db.
'-rcfile' => $mhonarc_ressources,
'-rcfile' => $mhonarc_rc,
'-outdir' => $self->{arc_directory},
'-definevars' => sprintf(
"listname='%s' hostname=%s yyyy=%s mois=%s yyyymm=%s-%s wdir=%s base=%s/arc tag=%s with_tslice=1 with_powered_by=1",
"listname='%s' hostname=%s yyyy=%s mois=%s yyyymm=%s-%s wdir=%s base=%s/arc with_tslice=1 with_powered_by=1",
$list->{'name'},
$list->{'domain'},
$yyyy,
......@@ -519,7 +515,6 @@ sub html_store {
$mm,
Conf::get_robot_conf($list->{'domain'}, 'arc_path'),
(Conf::get_robot_conf($list->{'domain'}, 'wwsympa_url') || ''),
$tag
),
'-umask' => $Conf::Conf{'umask'}
);
......@@ -645,9 +640,7 @@ sub html_rebuild {
my $robot_id = $list->{'domain'};
my $arc_directory = $self->{arc_directory};
my $tag = _get_tag($list);
my $mhonarc_ressources =
Sympa::search_fullpath($list, 'mhonarc-ressources.tt2');
my $mhonarc_rc = Sympa::search_fullpath($list, 'mhonarc_rc.tt2');
# Remove existing HTML files and .mhonarc.db.
my $dh;
......@@ -675,10 +668,10 @@ sub html_rebuild {
my @cmd = (
Conf::get_robot_conf($robot_id, 'mhonarc'),
'-addressmodifycode' => '1', # w/a: Clear old cache in .mhonarc.db.
'-rcfile' => $mhonarc_ressources,
'-rcfile' => $mhonarc_rc,
'-outdir' => $arc_directory,
'-definevars' => sprintf(
"listname='%s' hostname=%s yyyy=%s mois=%s yyyymm=%s-%s wdir=%s base=%s/arc tag=%s with_tslice=1 with_powered_by=1",
"listname='%s' hostname=%s yyyy=%s mois=%s yyyymm=%s-%s wdir=%s base=%s/arc with_tslice=1 with_powered_by=1",
$listname,
$robot_id,
$yyyy,
......@@ -687,7 +680,6 @@ sub html_rebuild {
$mm,
Conf::get_robot_conf($robot_id, 'arc_path'),
(Conf::get_robot_conf($robot_id, 'wwsympa_url') || ''),
$tag
),
'-umask' => $Conf::Conf{'umask'},
$dir_to_rebuild
......@@ -890,10 +882,9 @@ sub html_format {
map { Sympa::Tools::Text::encode_uri($_) } @$attachment_url;
}
my $mhonarc_ressources =
Sympa::search_fullpath($that, 'mhonarc-ressources.tt2');
unless ($mhonarc_ressources) {
$log->syslog('notice', 'Cannot find any MhOnArc ressource file');
my $mhonarc_rc = Sympa::search_fullpath($that, 'mhonarc_rc.tt2');
unless ($mhonarc_rc) {
$log->syslog('notice', 'Cannot find any MHonArc resource file');
return undef;
}
......@@ -923,21 +914,19 @@ sub html_format {
return undef;
}
my $tag = _get_tag($that);
my $exitcode = system(
Conf::get_robot_conf($robot, 'mhonarc'),
'-single',
'-rcfile' => $mhonarc_ressources,
'-rcfile' => $mhonarc_rc,
'-definevars' => sprintf(
"listname='%s' hostname=%s yyyy='' mois='' tag=%s with_tslice='' with_powered_by=''",
$listname, $domain, $tag
"listname='%s' hostname=%s yyyy='' mois='' with_tslice='' with_powered_by=''",
$listname, $domain
),
'-outdir' => $destination_dir,
'-attachmentdir' => $destination_dir,
'-attachmenturl' =>
sprintf('(%s%% path_cgi %%%s)/%s', $tag, $tag, $attachment_url),
'-umask' => $Conf::Conf{'umask'},
'-stdout' => "$destination_dir/msg00000.html",
'-attachmenturl' => sprintf('<%% path_cgi %%>/%s', $attachment_url),
'-umask' => $Conf::Conf{'umask'},
'-stdout' => "$destination_dir/msg00000.html",
'--',
$msg_file
) >> 8;
......@@ -957,22 +946,8 @@ sub html_format {
}
# Old name: Sympa::Archive::get_tag(), get_tag() in archived.pl.
sub _get_tag {
my $that = shift;
my $name;
if (ref $that eq 'Sympa::List') {
$name = $that->{'name'};
} elsif (!ref($that) and $that and $that ne '*') {
$name = $that;
} elsif (!ref($that)) {
$name = '*';
}
my $cookie = $Conf::Conf{'cookie'};
$cookie = '' unless defined $cookie;
return substr(Digest::MD5::md5_hex(join '/', $cookie, $name), -10);
}
# No longer used.
#sub _get_tag;
sub get_id {
my $self = shift;
......
......@@ -4540,6 +4540,7 @@ our %pinfo = (
format => '\S+',
field_type => 'password',
length => 15,
obsolete => 1,
},
custom_attribute => {
......
......@@ -1677,10 +1677,7 @@ sub delete_list_admin {
#sub delete_all_list_admin;
# OBSOLETED: This may no longer be used.
# Returns the cookie for a list, if any.
sub get_cookie {
return shift->{'admin'}{'cookie'};
}
#sub get_cookie;
# OBSOLETED: No longer used.
# Returns the maximum size allowed for a message to the list.
......
......@@ -117,12 +117,6 @@ sub new {
}
}
}
unless ($data->{'user'}{'password'}) {
$data->{'user'}{'password'} =
Sympa::Tools::Password::tmp_passwd($who);
}
}
# Lang
......
......@@ -141,8 +141,6 @@ sub _twist {
my $user = Sympa::User->new($email);
$user->lang($list->{'admin'}{'lang'}) unless $user->lang;
$user->password(Sympa::Tools::Password::tmp_passwd($email))
unless $user->password;
$user->save;
## Now send the welcome file to the user if it exists and notification
......
......@@ -142,8 +142,6 @@ sub _twist {
my $user = Sympa::User->new($email);
$user->lang($list->{'admin'}{'lang'}) unless $user->lang;
$user->password(Sympa::Tools::Password::tmp_passwd($email))
unless $user->password;
$user->save;
## Now send the welcome file to the user
......
......@@ -35,15 +35,8 @@ BEGIN { eval 'use Data::Password'; }
use Conf;
use Sympa::Language;
sub tmp_passwd {
my $email = shift;
my $cookie = $Conf::Conf{'cookie'};
$cookie = '' unless defined $cookie;
return (
'init' . substr(Digest::MD5::md5_hex(join '/', $cookie, $email), -8));
}
# Deprecated. No longer used.
#sub tmp_passwd;
# No longer used, Use _decrypt_rc4_password() in upgrade_sympa_password.pl.
#sub ciphersaber_installed;
......
......@@ -2070,6 +2070,46 @@ sub upgrade {
}
}
# Variable tags "($tag$% ... %$tag$)" no longer used in
# mhonarc_rc.tt2 (ex. mhonarc-ressources.tt2) and were replaced with
# "<% ... %>".
if (lower_version($previous_version, '6.2.61b.1')) {
$log->syslog('notice', 'Converting mhonarc-ressources.tt2...');
my $oldfile = 'mhonarc-ressources.tt2';
my $newfile = 'mhonarc_rc.tt2';
my @dirs;
push @dirs, $Conf::Conf{'etc'}
if -f $Conf::Conf{'etc'} . '/' . $oldfile;
foreach my $robot (Sympa::List::get_robots()) {
my $dir = sprintf '%s/%s', $Conf::Conf{'etc'}, $robot;
push @dirs, $dir
if -f $dir . '/' . $oldfile;
foreach my $list (@{Sympa::List::get_lists($robot) || []}) {
push @dirs, $list->{'dir'}
if -f $list->{'dir'} . '/' . $oldfile;
}
}
foreach my $dir (@dirs) {
open my $ifh, '<', $dir . '/' . $oldfile
or die sprintf '%s: %s', $oldfile, $ERRNO;
my $text = do { local $RS; <$ifh> };
close $ifh;
$text =~ s{[(]\$tag\$%}{<%}g;
$text =~ s{%\$tag\$[)]}{%>}g;
open my $ofh, '>', $dir . '/' . $newfile
or die sprintf '%s: %s', $newfile, $ERRNO;
print $ofh $text;
close $ofh;
}
$log->syslog('notice', '...Done. Use new file(s) mhonarc_rc.tt2.');
}
return 1;
}
......
......@@ -282,7 +282,16 @@ Print this help message.
F<$SPOOLDIR/outgoing/> outgoing Sympa directory.
F<$DEFAULTDIR/mhonarc-ressources.tt2> template of MHonArc resource file.
F<$DEFAULTDIR/mhonarc_rc.tt2> template of MHonArc resource file.
=over
=item *
F<mhonarc-ressources.tt2> was replaced with F<mhonarc_rc.tt2>
on Sympa 6.2.61b.1.
=back
F<--CONFIG--> Sympa configuration file.
......
......@@ -209,12 +209,6 @@ if ($main::options{'upgrade_config_location'}) {
);
}
if (Conf::cookie_changed()) {
die sprintf
'sympa.conf/cookie parameter has changed. You may have severe inconsitencies into password storage. Restore previous cookie or write some tool to re-encrypt password in database and check spools contents (look at %s/cookies.history file).',
$Conf::Conf{'etc'};
}
## Check if db_type is not the boilerplate one
if ($Conf::Conf{'db_type'} eq '(You must define this parameter)') {
die sprintf
......@@ -1142,12 +1136,6 @@ sub _load {
);
}
if (Conf::cookie_changed()) {
die sprintf
'sympa.conf/cookie parameter has changed. You may have severe inconsitencies into password storage. Restore previous cookie or write some tool to re-encrypt password in database and check spools contents (look at %s/cookies.history file).',
$Conf::Conf{'etc'};
}
# Check database connectivity.
unless (Sympa::DatabaseManager->instance) {
die sprintf
......
......@@ -227,12 +227,6 @@ sub _load {
);
}
if (Conf::cookie_changed()) {
die sprintf
'sympa.conf/cookie parameter has changed. You may have severe inconsitencies into password storage. Restore previous cookie or write some tool to re-encrypt password in database and check spools contents (look at %s/cookies.history file).',
$Conf::Conf{'etc'};
}
# Check database connectivity.
unless (Sympa::DatabaseManager->instance) {
die sprintf
......
......@@ -307,12 +307,6 @@ sub _load {
);
}
if (Conf::cookie_changed()) {
die sprintf
'sympa.conf/cookie parameter has changed. You may have severe inconsitencies into password storage. Restore previous cookie or write some tool to re-encrypt password in database and check spools contents (look at %s/cookies.history file).',
$Conf::Conf{'etc'};
}
# Check database connectivity.
unless (Sympa::DatabaseManager->instance) {
die sprintf
......
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