develooper Front page | perl.qpsmtpd | Postings from March 2006

Re: dnsbl or spamhaus occassionally blocks wrong IP

Thread Previous
From:
Peter J. Holzer
Date:
March 18, 2006 14:10
Subject:
Re: dnsbl or spamhaus occassionally blocks wrong IP
Message ID:
20060318221001.GD17342@teal.hjp.at
On 2006-03-15 09:33:03 -0500, Matt Sergeant wrote:
> On 14-Mar-06, at 5:50 PM, Peter J. Holzer wrote:
> >>There is code in trunk to deal with this specific issue, around  
> >>line 124
> >>of ~/qpsmtpd, where the _fork subroutine is defined.
> >
> >You are right. But I don't understand it:
[...]
> >which version of Net::DNS has a variable %Net::DNS::Resolver::global?
> >Neither 0.48 nor 0.57 seem to have it. Is this for some old version
> >or a new one which hasn't been released yet?
> 
> Old version IIRC. The newer versions of Net::DNS didn't require any  
> work on this as they fixed this bug.

I don't think so. I can still see the bug with 0.57 (which is
the current version according to CPAN and net-dns.org)

Here is a script to demonstrate it:

#!/usr/bin/perl
use warnings;
use strict;
use Net::DNS;
use Net::DNS::Header;

my $inc_id = 0;

for (1 .. 10) {
    if (my $pid = fork()) {
	waitpid($pid, 0);
	sleep(3);
    } else {
	print "--------------------------------\n";
	print "pid: $$\n";
	print "\n";
	if ($inc_id) {
	    srand();
	    for (0 .. rand(65536)) {
		Net::DNS::Header::nextid();
	    }
	}
	my $res = Net::DNS::Resolver->new;
	my $answer = $res->query('wsr.ac.at', 'MX');
	#$answer->print;
	$answer->header->print;
	sleep(1);
	$answer = $res->query('hjp.at', 'MX');
	#$answer->print;
	$answer->header->print;
	print "\n";
	print "\n";
	exit(0);
    }
}

It forks off 10 child processes, performs two queries in each and prints
the header of the replies. On my systems the IDs are always the same for
all child processes.

The section in «if ($inc_id) { ... }» is my proposed workaround.

	hp

-- 
   _  | Peter J. Holzer    | Ich sehe nun ein, dass Computer wenig
|_|_) | Sysadmin WSR       | geeignet sind, um sich was zu merken.
| |   | hjp@hjp.at         |
__/   | http://www.hjp.at/ |	-- Holger Lembke in dan-am


Thread Previous


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