On 2007-07-30 18:18:28 -0500, Peter Eisch wrote: > On 7/30/07 5:11 PM, "Peter J. Holzer" <[EMAIL PROTECTED]> wrote: > > > Have a look at > > http://svn.perl.org/viewcvs/qpsmtpd/contrib/hjp/config_me_localaddr/config_me_ > > localaddr?view=markup&rev=716 > > > > Does this do what you want? > > > > It does. I have to patch lib/Apache/Qpsmtpd.pm with: [...] > Then, in your plugin using Ask's suggestion: > > --- config_me_localaddr.orig 2007-07-30 18:03:10.000000000 -0500 > +++ config_me_localaddr 2007-07-30 17:56:59.000000000 -0500 > @@ -35,7 +35,7 @@ sub hook_config { > my $local_ip; > unless ($self->connection && $self->connection->local_ip) { > $self->log(LOGNOTICE, "cannot determnine locak IP address of > connection"); > - return DECLINED; > + return(DECLINED, `hostname`); > }
That's ok, I think. If the plugin returns DECLINED, the next plugin is
run. If none returns OK, Qpsmtpd::config finally calls get_qmail_config
and if that also fails it falls back to the default. So adding `hostname`
here has no effect except forking and execing quite often (config('me')
is called a lot).
> $local_ip = $self->connection->local_ip;
> my $local_name = gethostbyaddr(inet_aton($local_ip), AF_INET);
Here is the real problem. If gethostbyaddr fails, $local_name is undef.
In this case the plugin should either return DECLINED or the ip address
enclosed in brackets. I'm not sure which is better. Maybe an option.
Further nitpicks:
* The return value should probably be cached. Doing a DNS lookup every
time is wasteful. A connection note is probably the cleanest way to do
this.
* The LOGINFO messages should probably be LOGDEBUG.
hp
--
_ | Peter J. Holzer | I know I'd be respectful of a pirate
|_|_) | Sysadmin WSR | with an emu on his shoulder.
| | | [EMAIL PROTECTED] |
__/ | http://www.hjp.at/ | -- Sam in "Freefall"
signature.asc
Description: Digital signature
