On 2006-12-16 01:36:47 -0800, Robert Spier wrote:
> > # all children should have different seeds, to prevent conflicts
> > - srand( time ^ ($$ + ($$ << 15)) );
> > + srand();
> > + for (0 .. rand(65536)) {
> > + Net::DNS::Header::nextid();
> > + }
>
> Um.
>
> I see why you want it - but the problem is that Net::DNS::Header is
> broken in this usage, it should be fixed instead of hacking us up.
>
> {
> my $id = int rand(MAX_ID);
> sub nextid {
> return $id++ % (MAX_ID + 1);
> }
> }
>
> Do the DNS request IDs need to be sequential?
No, they should be random (and preferrably hard to guess).
> If not, why not just
> replace that with:
> sub nextid {
> return rand(MAX_ID);
> }
> and hope it never comes back around?
Together with calling srand() just after the fork, this should work,
yes. Do you want to submit a bug report for Net::DNS or should I?
(I think I've already seen a bug report for this but I can't find it
now).
> I really don't like the "increment the counter somwehre between 1 and
> 64k times to get a unique number" thing you've got going here. It
> looks like a hack.
>
I'll be the first to admit that it is an ugly hack. I don't like it,
either. However, we need something which works with current (and even
old) versions of Net::DNS, not with some future version where the bug is
fixed.
Hmm, we could do something like:
lib/Qpsmtpd/Hack.pm:
----------------------------------------------------------------
package Qpsmtpd::Hack;
# this file is only to override Net::DNS::Header::nextid() with a
# fixed version.
package Net::DNS::Header;
sub nextid {
return rand(MAX_ID);
}
----------------------------------------------------------------
and
use Qpsmtpd::Hack;
somewhere else.
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
