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

Merge pull request #1067 from ikedas/issue-1036-add1 by ikedas

Correct fix for #1036
parents 632197fb f3c86671
......@@ -4067,7 +4067,7 @@ our %pinfo = (
},
dkim_feature => {
context => [qw(list domain site)],
context => [qw(domain site)],
order => 70.01,
group => 'dkim',
#gettext_id => 'Enable DKIM',
......
......@@ -58,7 +58,6 @@ use Sympa::Scenario;
use Sympa::Spool;
use Sympa::Template;
use Sympa::Tools::Data;
use Sympa::Tools::DKIM;
use Sympa::Tools::File;
use Sympa::Tools::Password;
use Sympa::Tools::SMIME;
......@@ -649,8 +648,15 @@ sub check_dkim_signature {
return unless $Mail::DKIM::Verifier::VERSION;
#FIXME: check should be done even if dkim_feature was not "on".
return unless Sympa::Tools::DKIM::get_dkim_parameters($self->{context});
my $robot_id =
(ref $self->{context} eq 'Sympa::List') ? $self->{context}->{'domain'}
: (ref $self->{context} eq 'Sympa::Family')
? $self->{context}->{'domain'}
: $self->{context};
return
unless Sympa::Tools::Data::smart_eq(
Conf::get_robot_conf($robot_id || '*', 'dkim_feature'), 'on');
my $dkim;
unless ($dkim = Mail::DKIM::Verifier->new()) {
......
......@@ -41,7 +41,6 @@ use Sympa::Log;
use Sympa::Spool;
use Sympa::Template;
use Sympa::Tools::Data;
use Sympa::Tools::DKIM;
use Sympa::Tools::Password;
use Sympa::Tools::SMIME;
use Sympa::Tools::Text;
......@@ -204,9 +203,8 @@ sub new {
# Shelve S/MIME signing.
$self->{shelved}{smime_sign} = 1
if $smime_sign;
# Shelve DKIM signing.
if (Sympa::Tools::DKIM::get_dkim_parameters($that)) {
if (Conf::get_robot_conf($robot_id, 'dkim_feature') eq 'on') {
my $dkim_add_signature_to =
Conf::get_robot_conf($robot_id, 'dkim_add_signature_to');
if ($list and $dkim_add_signature_to =~ /list/
......
......@@ -8,8 +8,8 @@
# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER
# Copyright 2017, 2019, 2020 The Sympa Community. See the AUTHORS.md
# file at the top-level directory of this distribution and at
# Copyright 2017, 2019 The Sympa Community. See the AUTHORS.md file at
# the top-level directory of this distribution and at
# <https://github.com/sympa-community/sympa.git>.
#
# This program is free software; you can redistribute it and/or modify
......@@ -330,7 +330,7 @@ sub _twist {
delete $new_message->{shelved}{smime_encrypt};
}
if ($dkim) {
if (Conf::get_robot_conf($robot, 'dkim_feature') eq 'on') {
$new_message->remove_invalid_dkim_signature;
}
if ($new_message->{shelved}{dkim_sign} and $dkim) {
......@@ -395,7 +395,7 @@ sub _twist {
delete $new_message->{shelved}{smime_sign};
}
if ($dkim) {
if (Conf::get_robot_conf($robot, 'dkim_feature') eq 'on') {
$new_message->remove_invalid_dkim_signature;
}
# Initial message
......
......@@ -8,9 +8,6 @@
# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER
# Copyright 2018, 2020 The Sympa Community. See the AUTHORS.md
# file at the top-level directory of this distribution and at
# <https://github.com/sympa-community/sympa.git>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -46,8 +43,6 @@ sub get_dkim_parameters {
if (ref $that eq 'Sympa::List') {
$robot_id = $that->{'domain'};
$list = $that;
} elsif (ref $that eq 'Sympa::Family') {
$robot_id = $that->{'domain'};
} elsif ($that and $that ne '*') {
$robot_id = $that;
} else {
......@@ -57,16 +52,6 @@ sub get_dkim_parameters {
my $data;
my $keyfile;
if ($list) {
# check if enabled for the list
$log->syslog(
'debug2',
'list DKIM feature %s',
$list->{'admin'}{'dkim_feature'}
);
return undef
unless $list->{'admin'}{'dkim_feature'} eq 'on';
# fetch dkim parameter in list context
$data->{'d'} = $list->{'admin'}{'dkim_parameters'}{'signer_domain'};
if ($list->{'admin'}{'dkim_parameters'}{'signer_identity'}) {
......@@ -80,14 +65,6 @@ sub get_dkim_parameters {
$keyfile = $list->{'admin'}{'dkim_parameters'}{'private_key_path'};
} else {
# in robot context
$log->syslog(
'debug2',
'robot DKIM feature %s',
Conf::get_robot_conf($robot_id, 'dkim_feature')
);
return undef
unless Conf::get_robot_conf($robot_id, 'dkim_feature') eq 'on';
$data->{'d'} = Conf::get_robot_conf($robot_id, 'dkim_signer_domain');
$data->{'i'} =
Conf::get_robot_conf($robot_id, 'dkim_signer_identity');
......
Markdown is supported
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