Hello,

This really bit me in config/relayclients:

# Format is IP, or IP part with trailing dot
# e.g. "127.0.0.1", or "192.168."
127.0.0.1
10.

Notice the space in the "10. " line?  Did you know it was significant? Neither 
did I.

I have attached a diff file that contains the code (and tests) to trim spaces 
from the beginning and end of lines in the config file.

Regards,
Henry
Index: config.sample/relayclients
===================================================================
--- config.sample/relayclients	(revision 961)
+++ config.sample/relayclients	(working copy)
@@ -1,4 +1,4 @@
 # Format is IP, or IP part with trailing dot
 # e.g. "127.0.0.1", or "192.168."
-127.0.0.1
-192.168.
+127.0.0.1 
+ 192.168. 
Index: t/config.t
===================================================================
--- t/config.t	(revision 961)
+++ t/config.t	(working copy)
@@ -17,6 +17,9 @@
 
 is($smtpd->config('me'), 'some.host.example.org', 'config("me")');
 
+my $relayclients = join ",", sort $smtpd->config('relayclients');
+is($relayclients, '127.0.0.1,192.168.', 'config("relayclients") are trimmed');
+
 unlink "./config.sample/me";
 
 
Index: lib/Qpsmtpd.pm
===================================================================
--- lib/Qpsmtpd.pm	(revision 961)
+++ lib/Qpsmtpd.pm	(working copy)
@@ -239,7 +239,7 @@
   open CF, "<$configfile" or warn "$$ could not open configfile $configfile: $!" and return;
   my @config = <CF>;
   chomp @config;
-  @config = grep { length($_) and $_ !~ m/^\s*#/ and $_ =~ m/\S/} @config;
+  @config = grep { length($_) and $_ !~ m/^\s*#/ and $_ =~ m/\S/} map {s/^\s+//; s/\s+$//; $_} @config;
   close CF;
 
   my $pos = 0;

Reply via email to