develooper Front page | perl.qpsmtpd | Postings from June 2015

hosts_allow plugin

From:
Chris Dallimore
Date:
June 9, 2015 17:51
Subject:
hosts_allow plugin
Message ID:
55772785.7050409@pigstrough.co.uk
Hi,

I'm still a novice and learning, but I'm playing with 0.95 and have come 
across an issue with the hosts_allow plugin.
Specifically this part in sub in_hosts_allow:

             $const = Qpsmtpd::Constants::return_code($const) || DECLINED;
             if ($const =~ /deny/i) {
                 $self->log(LOGINFO, "fail, $message");
             }

The second line can seemingly never be true, as the preceding line has 
replaced the value of $const read from the config file with a return 
/code/ (e.g. 901).

Should there also be a 'return $const, $message;' to return the failure 
before reaching:
             $self->log(LOGDEBUG, "pass, $const, $message");
             return $const, $message;

as always logs a 'pass', regardless of the actual response.


There'll undoubtedly be a more elegant way, but as a kludge for me, I've 
changed this to:

         if (join('.', unpack('C4', inet_aton($remote) & $mask)) eq $net) {
             my $action = $const;
             $const = Qpsmtpd::Constants::return_code($const) || DECLINED;
             if ($action =~ /deny/i) {
                 $self->log(LOGINFO, "fail, $message");
                 return $const, $message;
             }

Is there a particular reason for using codes rather than the keys in 
this section?

Chris.



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About