Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Sympa
Commits
2268c06f
Unverified
Commit
2268c06f
authored
Nov 16, 2018
by
Luc Didry
Browse files
#295 — Create Sympa::Tools::Domains and add blacklist domain check in subscribe handler
parent
101b3d62
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/lib/Sympa/ConfDef.pm
View file @
2268c06f
...
...
@@ -2132,17 +2132,15 @@ our @params = (
'
file
'
=>
'
sympa.conf
',
'
optional
'
=>
1
,
},
{
'
name
'
=>
'
domains_blacklist
',
{
'
name
'
=>
'
domains_blacklist
',
'
gettext_id
'
=>
'
Prevent people to subscribe to a list with adresses using these domains
',
'
gettext_comment
'
=>
'
This parameter is a comma-separated list.
',
'
default
'
=>
undef
,
'
sample
'
=>
'
example.org,spammer.com
',
'
split_char
'
=>
'
,
',
'
file
'
=>
'
sympa.conf
',
'
optional
'
=>
1
,
'
gettext_comment
'
=>
'
This parameter is a comma-separated list.
',
'
default
'
=>
undef
,
'
sample
'
=>
'
example.org,spammer.com
',
'
split_char
'
=>
'
,
',
'
file
'
=>
'
sympa.conf
',
'
optional
'
=>
1
,
},
## Not implemented yet.
...
...
src/lib/Sympa/List.pm
View file @
2268c06f
...
...
@@ -61,6 +61,7 @@ use Sympa::Spool::Auth;
use Sympa::Template;
use Sympa::Ticket;
use Sympa::Tools::Data;
use Sympa::Tools::Domains;
use Sympa::Tools::File;
use Sympa::Tools::Password;
use Sympa::Tools::SMIME;
...
...
@@ -3826,19 +3827,10 @@ sub add_list_member {
$new_user->{'email'});
next;
}
if (defined($Conf::Conf{'domains_blacklist'})) {
my @parts = split '@', $who;
my $next = 0;
foreach my $f (split ',', lc($Conf::Conf{'domains_blacklist'})) {
if ($parts[1] && $parts[1] eq $f) {
$log->syslog('err',
'Ignoring %s which uses a blacklisted domain',
$new_user->{'email'});
$next++;
next;
}
}
next if $next;
if (Sympa::Tools::Domains::is_blacklisted($who)) {
$log->syslog('err', 'Ignoring %s which uses a blacklisted domain',
$new_user->{'email'});
next;
}
unless (
$current_list_members_count < $self->{'admin'}{'max_list_members'}
...
...
src/lib/Sympa/Request/Handler/add.pm
View file @
2268c06f
...
...
@@ -35,6 +35,7 @@ use Sympa;
use
Conf
;
use
Sympa::
Language
;
use
Sympa::
Log
;
use
Sympa::Tools::
Domains
;
use
Sympa::Tools::
Password
;
use
Sympa::Tools::
Text
;
use
Sympa::
User
;
...
...
@@ -71,18 +72,12 @@ sub _twist {
return
undef
;
}
if
(
defined
(
$
Conf::
Conf
{'
domains_blacklist
'}))
{
my
@parts
=
split
'
@
',
Sympa::Tools::Text::
canonic_email
(
$email
);
foreach
my
$f
(
split
'
,
',
lc
(
$
Conf::
Conf
{'
domains_blacklist
'}))
{
if
(
$parts
[
1
]
&&
$parts
[
1
]
eq
$f
)
{
$self
->
add_stash
(
$request
,
'
user
',
'
blacklisted_domain
',
{'
email
'
=>
$email
});
$log
->
syslog
('
err
',
'
ADD command rejected; blacklisted domain for "%s"
',
$email
);
return
undef
;
}
}
if
(
Sympa::Tools::Domains::
is_blacklisted
(
$email
))
{
$self
->
add_stash
(
$request
,
'
user
',
'
blacklisted_domain
',
{'
email
'
=>
$email
});
$log
->
syslog
('
err
',
'
ADD command rejected; blacklisted domain for "%s"
',
$email
);
return
undef
;
}
if
(
$list
->
is_list_member
(
$email
))
{
...
...
src/lib/Sympa/Request/Handler/subscribe.pm
View file @
2268c06f
...
...
@@ -35,6 +35,7 @@ use Sympa;
use
Conf
;
use
Sympa::
Language
;
use
Sympa::
Log
;
use
Sympa::Tools::
Domains
;
use
Sympa::Tools::
Password
;
use
Sympa::
User
;
...
...
@@ -72,6 +73,15 @@ sub _twist {
undef
$comment
;
}
if
(
Sympa::Tools::Domains::
is_blacklisted
(
$email
))
{
$self
->
add_stash
(
$request
,
'
user
',
'
blacklisted_domain
',
{'
email
'
=>
$email
});
$log
->
syslog
('
err
',
'
SUBSCRIBE to %s command rejected; blacklisted domain for "%s"
',
$list
,
$email
);
return
undef
;
}
# Unless rejected by scenario, don't go further if the user is subscribed
# already.
my
$user_entry
=
$list
->
get_list_member
(
$email
);
...
...
src/lib/Sympa/Tools/Domains.pm
0 → 100644
View file @
2268c06f
# -*- indent-tabs-mode: nil; -*-
# vim:ft=perl:et:sw=4
# $Id$
# Sympa - SYsteme de Multi-Postage Automatique
#
# Copyright (c) 1997, 1998, 1999 Institut Pasteur & Christophe Wolfhugel
# 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
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
package
Sympa::Tools::
Domains
;
use
strict
;
use
warnings
;
use
Conf
;
use
Sympa::Tools::
Text
;
sub
is_blacklisted
{
my
$email
=
shift
;
if
(
defined
(
$
Conf::
Conf
{'
domains_blacklist
'}))
{
my
@parts
=
split
'
@
',
Sympa::Tools::Text::
canonic_email
(
$email
);
foreach
my
$f
(
split
'
,
',
lc
(
$
Conf::
Conf
{'
domains_blacklist
'}))
{
if
(
$parts
[
1
]
&&
$parts
[
1
]
eq
$f
)
{
return
1
;
}
}
}
return
0
;
}
1
;
__END__
=encoding utf-8
=head1 NAME
Sympa::Tools::Domains - Domains-related functions
=head1 DESCRIPTION
This package provides some email's domains-related functions.
=head2 Functions
=over
=item is_blacklisted ( $email )
Says if the domain of the given email is blacklisted (C<domains_blacklist>
setting).
Returns 1 if it's blacklisted, 0 otherwise
=back
=cut
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment