Skip to content

Commit

Permalink
Merge pull request #1067 from ikedas/issue-1036-add1 by ikedas
Browse files Browse the repository at this point in the history
Correct fix for #1036
  • Loading branch information
ikedas authored Dec 29, 2020
2 parents 632197f + f3c8667 commit 2cdabaf
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/lib/Sympa/Config/Schema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
12 changes: 9 additions & 3 deletions src/lib/Sympa/Message.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()) {
Expand Down
4 changes: 1 addition & 3 deletions src/lib/Sympa/Message/Template.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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/
Expand Down
8 changes: 4 additions & 4 deletions src/lib/Sympa/Spindle/ProcessOutgoing.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
23 changes: 0 additions & 23 deletions src/lib/Sympa/Tools/DKIM.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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'}) {
Expand All @@ -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');
Expand Down

0 comments on commit 2cdabaf

Please sign in to comment.