Commit 90bfbd63 authored by sikeda's avatar sikeda
Browse files

[svn] Retrieving recent modifications from sympa-6.1-branch.

git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@10631 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 5d49eddb
......@@ -464,13 +464,16 @@ my %list_option = (
# dmarc_protection.mode
'dkim_signature' => {'gettext_id' => 'DKIM signature exists'},
'dmarc_any' => {'gettext_id' => 'DMARC policy exists'},
'dmarc_reject' => {'gettext_id' => 'DMARC policy suggests rejection'},
'dmarc_quarantine' => {'gettext_id' => 'DMARC policy suggests quarantine'},
'domain_regex' => {'gettext_id' => 'domain matching regular expression'},
# dmarc_protection.phrase
'display_name' => {'gettext_id' => 'display name'},
'name_and_email' => {'gettext_id' => 'display name and e-mail'},
'name_via_list' => {'gettext_id' => '"via Mailing List"'},
'name_via_list' => {'gettext_id' => 'name "via Mailing List"'},
'name_email_via_list' => {'gettext_id' => 'e-mail "via Mailing List"'},
);
## Values for subscriber reception mode.
......@@ -1494,7 +1497,6 @@ sub distribute_msg {
}
}
# SJS START
## Munge the From header if we are using DMARC Protection mode
if ( $self->{'admin'}{'dmarc_protection'}{'mode'} ) {
my $dkimdomain = $self->{'admin'}{'dmarc_protection'}{'domain_regex'};
......@@ -1519,18 +1521,31 @@ sub distribute_msg {
$mungeFrom = 1 if( $origFrom =~ /$dkimdomain$/ );
}
if( !$mungeFrom and $origFrom
and &tools::is_in_array($self->{'admin'}{'dmarc_protection'}{'mode'},'dmarc_reject') ) {
and (
&tools::is_in_array($self->{'admin'}{'dmarc_protection'}{'mode'},'dmarc_reject')
or &tools::is_in_array($self->{'admin'}{'dmarc_protection'}{'mode'},'dmarc_any')
or &tools::is_in_array($self->{'admin'}{'dmarc_protection'}{'mode'},'dmarc_quarantine')
)) {
# Strict auto policy - is the sender domain policy to reject
my $dom = $origFrom; $dom =~ s/^.*\@//;
$hdr->add('X-DMARC-DNS-Check',$dom);
eval { # In case Net::DNS is not installed
require Net::DNS;
my $res = Net::DNS::Resolver->new;
my $packet = $res->query("_dmarc.$dom","TXT");
if ($packet) {
foreach my $rr (grep { $_->type eq 'TXT' } $packet->answer) {
$mungeFrom = 1 if($rr->string =~ /p=reject/);
next if($rr->string !~ /v=DMARC/);
if(!$mungeFrom and &tools::is_in_array($self->{'admin'}{'dmarc_protection'}{'mode'},'dmarc_reject')) {
$mungeFrom = 1 if($rr->string =~ /p=reject/);
}
if(!$mungeFrom and &tools::is_in_array($self->{'admin'}{'dmarc_protection'}{'mode'},'dmarc_quarantine')) {
$mungeFrom = 1 if($rr->string =~ /p=quarantine/);
}
if(!$mungeFrom and &tools::is_in_array($self->{'admin'}{'dmarc_protection'}{'mode'},'dmarc_any')) {
$mungeFrom = 1;
}
$hdr->add('X-Original-DMARC-Record',"domain=$dom; ".$rr->string);
last;
}
}
};
......@@ -1546,45 +1561,55 @@ sub distribute_msg {
}
# Identify default new From address
my $phraseMode = $self->{'admin'}{'dmarc_protection'}{'phrase'};
my $newAddr = '';
my $userName = $language->gettext('Anonymous');
my $newComment;
my $phraseMode = $self->{'admin'}{'dmarc_protection'}{'phrase'} ||
'name_via_list';
my $newAddr;
my $displayName;
my $newComment;
$anonaddr = $self->{'admin'}{'dmarc_protection'}{'other_email'};
$anonaddr = $name . '@' . $host if(!$anonaddr or $anonaddr !~/@/);
$anonaddr = $self->get_list_address()
unless $anonaddr and $anonaddr =~ /\@/;
@anonFrom = Mail::Address->parse($anonaddr);
if (@addresses) {
# We should always have a From address in reality, unless the
# message is from a badly-behaved automate
if ($addresses[0]->phrase) {
$userName = MIME::EncWords::decode_mimewords(
$displayName = MIME::EncWords::decode_mimewords(
$addresses[0]->phrase, Charset => 'UTF-8');
$newComment = $addresses[0]->address
if $phraseMode eq 'name_and_email';
if $phraseMode =~ /email/;
} else {
# If we dont have a Phrase, should we search the Sympa database
# for the sender to obtain their name that way? Might be difficult.
$userName = $addresses[0]->address;
$userName =~ s/\@.*// unless($phraseMode eq 'name_and_email');
$userName = $language->gettext('Anonymous') unless $userName =~ /\S/;
$displayName = $addresses[0]->address;
$displayName =~ s/\@.*// unless $phraseMode =~ /email/;
}
if($phraseMode eq 'name_and_email') { # NAME (EMAIL)
;
} elsif($phraseMode eq 'name_via_list') { # NAME (via LIST Mailing List)
$newComment =
$language->gettext_sprintf('via %s Mailing List', $name);
} else { # default: NAME
undef $newComment;
if($phraseMode =~ /list/) {
if ($newComment and $newComment =~ /\S/) {
$newComment = $language->gettext_sprintf(
'%s via %s Mailing List', $newComment, $name);
} else {
$newComment = $language->gettext_sprintf(
'via %s Mailing List', $name);
}
}
$hdr->add('Reply-To',$addresses[0]->address) unless($hdr->get('Reply-To'));
}
# If the new From email address has a Phrase component, then append it
$userName .= ' '.$anonFrom[0]->phrase if(@anonFrom and $anonFrom[0]->phrase);
if (@anonFrom and $anonFrom[0]->phrase) {
if ($displayName and $displayName =~ /\S/) {
$displayName .= ' ' . $anonFrom[0]->phrase;
} else {
$displayName = $anonFrom[0]->phrase;
}
}
$displayName = $language->gettext('Anonymous')
unless $displayName and $displayName =~ /\S/;
$newAddr = tools::addrencode(
(@anonFrom ? $anonFrom[0]->address : $anonaddr),
$userName, tools::lang2charset($language->get_lang),
$displayName, tools::lang2charset($language->get_lang),
$newComment);
$hdr->add('X-Original-From',"$originalFromHeader");
......@@ -1592,7 +1617,6 @@ sub distribute_msg {
}
}
# SJS END
## Hide the sender if the list is anonymoused
if ($self->{'admin'}{'anonymous_sender'}) {
......
......@@ -1791,26 +1791,29 @@ our %pinfo = (
'default' => {'conf' => 'dkim_signature_apply_on'}
},
# SJS START
'dmarc_protection' => {
'format' => {
'mode' => {
'format' => [
'none', 'all',
'dkim_signature', 'dmarc_reject',
'dmarc_any', 'dmarc_quarantine',
'domain_regex'
],
'synonym' => {
'dkim' => 'dkim_signature',
'domain' => 'domain_regex',
'dkim' => 'dkim_signature',
'dkim_exists' => 'dkim_signature',
'dmarc_exists' => 'dmarc_any',
'domain' => 'domain_regex',
'domain_match' => 'domain_regex',
},
'gettext_id' => "Protection modes",
'split_char' => ',',
'occurrence' => '0-n',
'default' => 'none',
'default' => {'conf' => 'dmarc_protection_mode'},
'gettext_comment' =>
'Select one or more operation modes. Domain matches the specified Domain regexp; Dkim matches any message with a DKIM signature header; Dmarc matches messages from sender domains with a reject DMARC policy; All matches all messages.',
'order' => 1,
'Select one or more operation modes. "Domain matching regular expression" (domain_regex) matches the specified Domain regexp; "DKIM signature exists" (dkim_signature) matches any message with a DKIM signature header; "DMARC policy ..." (dmarc_*) matches messages from sender domains with a DMARC policy as given; "all" (all) matches all messages.',
'order' => 1
},
'domain_regex' => {
'format' => '.+',
......@@ -1818,6 +1821,7 @@ our %pinfo = (
'occurrence' => '0-1',
'gettext_comment' => 'Regexp match pattern for From domain',
'order' => 2,
'default' => {'conf' => 'dmarc_protection_domain_regex'},
},
'other_email' => {
'format' => '.+',
......@@ -1825,13 +1829,16 @@ our %pinfo = (
'occurrence' => '0-1',
'gettext_comment' =>
'This is the email address to use when modifying the From header. It defaults to the list address. This is similar to Anonymisation but preserves the original sender details in the From address phrase.',
'order' => 3,
'order' => 3,
'default' => {'conf' => 'dmarc_protection_other_email'},
},
'phrase' => {
'format' =>
['display_name', 'name_and_email', 'name_via_list'],
'synonym' => {'name' => 'display_name'},
'default' => 'name_via_list',
'format' => [
'display_name', 'name_and_email',
'name_via_list', 'name_email_via_list'
],
'synonym' => {'name' => 'display_name'},
'default' => {'conf' => 'dmarc_protection_phrase'},
'gettext_id' => "New From name format",
'occurrence' => '0-1',
'gettext_comment' =>
......@@ -1842,10 +1849,9 @@ our %pinfo = (
'gettext_id' => "DMARC Protection",
'group' => 'dkim',
'gettext_comment' =>
"Parameters to define how to manage From address processing to avoid some domains' excessive DMARC protection",
'Parameters to define how to manage From address processing to avoid some domains\' excessive DMARC protection',
'occurrence' => '0-1',
},
# SJS END
### Others page ###
......
......@@ -1362,6 +1362,39 @@ our @params = (
##default => 'from:sender:reply-to:subject:date:message-id:to:cc:list-id:list-help:list-unsubscribe:list-subscribe:list-post:list-owner:list-archive:in-reply-to:references:resent-date:resent-from:resent-sender:resent-to:resent-cc:resent-message-id:mime-version:content-type:content-transfer-encoding:content-id:content-description',
##},
{
'name' => 'dmarc_protection_mode',
'gettext_id' => 'Test mode(s) for DMARC Protection',
'sample' => 'dmarc_reject,dkim_signature',
'vhost' => '1',
'edit' => '1',
'optional'=> '1',
'gettext_comment' => 'Do not set unless you want to use DMARC protection. This is a comma separated list of test modes; if multiple are selected then protection is activated if ANY match. Do not use dmarc_* modes unless you have a local DNS cache as they do a DNS lookup for each received message.',
},
{
'name' => 'dmarc_protection_domain_regex',
'gettext_id' => 'Regexp for domain name match',
'vhost' => '1',
'edit' => '1',
'optional'=> '1',
'gettext_comment' => 'This is used for the "domain_regex" protection mode.',
},
{
'name' => 'dmarc_protection_phrase',
'gettext_id' => 'Pattern used to create new From header phrase',
'vhost' => '1',
'edit' => '1',
'optional'=> '1',
'default' => 'name_via_list',
},
{
'name' => 'dmarc_protection_other_email',
'gettext_id' => 'Email to use for replacement From header',
'vhost' => '1',
'edit' => '1',
'optional'=> '1',
},
{ 'gettext_id' => 'Antivirus plug-in' },
{
......
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