Skip to content

Commit

Permalink
Obsolete cookie parameter (#1091): Changes on upgrade_send_spool.pl…
Browse files Browse the repository at this point in the history
… and upgrade_sympa_password.pl to read the obsoleted parameter by themselves
  • Loading branch information
ikedas committed Jan 22, 2021
1 parent e1555fc commit a285918
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/bin/upgrade_send_spool.pl.in
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ 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];
Expand Down Expand Up @@ -133,7 +138,7 @@ sub sympa_checksum {
my $rcpt = shift;
return (
substr(
Digest::MD5::md5_hex(join('/', $Conf::Conf{'cookie'}, $rcpt)),
Digest::MD5::md5_hex(join('/', $cookie, $rcpt)),
-10
)
);
Expand Down Expand Up @@ -182,6 +187,8 @@ Following site configuration parameters in F<--CONFIG--> are referred.
=item cookie
(obsoleted by Sympa 6.2.61b)
=item queue
=item umask
Expand Down
8 changes: 7 additions & 1 deletion src/bin/upgrade_sympa_password.pl.in
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -82,6 +83,11 @@ 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');
Expand Down Expand Up @@ -274,7 +280,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));
}

Expand Down

0 comments on commit a285918

Please sign in to comment.