Re: helo plugin fails to match badhelo
[email protected] (Matt Simerson via qpsmtpd) Thu, 17 Dec 2015 10:28:00 -0800
| Newsgroups | perl.qpsmtpd |
|---|---|
| Message-ID | <[email protected]> |
Hey Chris, See https://github.com/smtpd/qpsmtpd/pull/246 Matt > On Dec 17, 2015, at 9:17 AM, Chris Dallimore <[email protected]> = wrote: >=20 > The helo plugin fails to match any entries in badhelo, as the = is_regex_match sub returns after the first (usually unsuccessful) test. >=20 > This works for me: >=20 > --- a/plugins/helo > +++ b/plugins/helo > @@ -301,40 +301,27 @@ >=20 > sub is_in_badhelo { > my ($self, $host) =3D @_; > - > - my $error =3D "I do not believe you are $host."; > + my $error =3D "Your HELO hostname is not allowed"; >=20 > $host =3D lc $host; > foreach my $bad ($self->qp->config('badhelo')) { > if ($bad =3D~ /[\{\}\[\]\(\)\^\$\|\*\+\?\\\!]/) { # it's a = regexp > - return $self->is_regex_match($host, $bad); > + #$self->log( LOGDEBUG, "is regex ($bad)"); > + if (substr($bad, 0, 1) eq '!') { > + $bad =3D substr $bad, 1; > + if ($host !~ /$bad/) { > + #$self->log( LOGDEBUG, "matched negative pattern = (\!$bad)"); > + return $error, "badhelo negative pattern match = (\!$bad)"; > } > - if ($host eq lc $bad) { > - return $error, "in badhelo"; > } > + elsif ($host =3D~ /$bad/) { > + #$self->log( LOGDEBUG, "matched ($bad)"); > + return $error, "badhelo pattern match ($bad)"; > } > - return; > } > - > -sub is_regex_match { > - my ($self, $host, $pattern) =3D @_; > - > - my $error =3D "Your HELO hostname is not allowed"; > - > - #$self->log( LOGDEBUG, "is regex ($pattern)"); > - if (substr($pattern, 0, 1) eq '!') { > - $pattern =3D substr $pattern, 1; > - if ($host !~ /$pattern/) { > - > - #$self->log( LOGDEBUG, "matched ($pattern)"); > - return $error, "badhelo pattern match ($pattern)"; > + elsif ($host eq lc $bad) { > + return $error, "($bad) in badhelo"; > } > - return; > - } > - if ($host =3D~ /$pattern/) { > - > - #$self->log( LOGDEBUG, "matched ($pattern)"); > - return $error, "badhelo pattern match ($pattern)"; > } > return; > }