Unverified Commit 101b3d62 authored by Luc Didry's avatar Luc Didry
Browse files

Fix #295 — Add domain blacklist feature

parent 3028d0fd
...@@ -597,6 +597,9 @@ Warning: this message may already have been sent by one of the list's moderators ...@@ -597,6 +597,9 @@ Warning: this message may already have been sent by one of the list's moderators
[%~ ELSIF report_entry == 'incorrect_email' ~%] [%~ ELSIF report_entry == 'incorrect_email' ~%]
[%|loc(report_param.email || report_param.value)%]Address "%1" is incorrect[%END%] [%|loc(report_param.email || report_param.value)%]Address "%1" is incorrect[%END%]
[%~ ELSIF report_entry == 'blacklisted_domain' ~%]
[%|loc(report_param.email || report_param.value)%]Address "%1" belongs to a blacklisted domain[%END%]
[%~ ELSIF report_entry == 'incorrect_passwd' ~%] [%~ ELSIF report_entry == 'incorrect_passwd' ~%]
[%|loc%]Provided password is incorrect[%END%] [%|loc%]Provided password is incorrect[%END%]
......
...@@ -2132,6 +2132,18 @@ our @params = ( ...@@ -2132,6 +2132,18 @@ our @params = (
'file' => 'sympa.conf', 'file' => 'sympa.conf',
'optional' => 1, 'optional' => 1,
}, },
{
'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,
},
## Not implemented yet. ## Not implemented yet.
## { ## {
......
...@@ -3826,6 +3826,20 @@ sub add_list_member { ...@@ -3826,6 +3826,20 @@ sub add_list_member {
$new_user->{'email'}); $new_user->{'email'});
next; 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;
}
unless ( unless (
$current_list_members_count < $self->{'admin'}{'max_list_members'} $current_list_members_count < $self->{'admin'}{'max_list_members'}
|| $self->{'admin'}{'max_list_members'} == 0) { || $self->{'admin'}{'max_list_members'} == 0) {
......
...@@ -71,6 +71,20 @@ sub _twist { ...@@ -71,6 +71,20 @@ sub _twist {
return undef; 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 ($list->is_list_member($email)) { if ($list->is_list_member($email)) {
$self->add_stash($request, 'user', 'already_subscriber', $self->add_stash($request, 'user', 'already_subscriber',
{'email' => $email, 'listname' => $list->{'name'}}); {'email' => $email, 'listname' => $list->{'name'}});
......
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