Skip Menu |

This queue is for tickets about the DNS-ZoneParse CPAN distribution.

Report information
The Basics
Id: 2291
Status: resolved
Priority: 0/
Queue: DNS-ZoneParse

People
Owner: Nobody in particular
Requestors: alex.woods [...] concept2100.co.uk
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.85
Fixed in: (no value)



Subject: SOA gets NS and MX records belonging to A records
Broken in 0.86 too, but unfortunately it is not in the list yet for me to choose! If this sort of thing is encountered: asubdomain IN A 123.45.123.45 IN NS ns0 IN NS ns1 IN MX 10 mx0 IN MX 20 mx1 the NS and MX records end up with the SOA record, and because these records have no name, they end up 'belonging' to it. I have attached a patch (against 0.86 with patch from bug 2290) that gets around the problem by setting any empty names to the name given in the previous record, or @ if no records have appeared yet. In other words, my patch is a total hack ;) A better solution would be to attach these NS and MX records to arrays held on the A record. Alex
--- ZoneParse.pm.orig Wed Mar 26 10:55:20 2003 +++ ZoneParse.pm Wed Mar 26 11:01:18 2003 @@ -183,6 +183,7 @@ my $rr_types = qr/ns|a|cname/i; my $rr_ttl = qr/(?:\d+[wdhms]?)+/i; my $ttl_cls = qr/(?:($rr_ttl)\s+)?(?:\b($rr_class)\s+)?\s*/; + my $last_name = '@'; foreach (@$records) { if (/^($valid_name)? \s* $ttl_cls ($rr_types) \s+ ($valid_name)/ix) { @@ -192,6 +193,10 @@ $class = uc $name; undef $name; } + if (length($name) == 0) { + $name = $last_name; + } + $last_name = $name; my $dns_thing = uc $type eq 'NS' ? $dns_ns{$self} : uc $type eq 'A' ? $dns_a{$self} : $dns_cname{$self}; push @$dns_thing, @@ -206,6 +211,10 @@ $class = uc $name; undef $name; } + if (length($name) == 0) { + $name = $last_name; + } + $last_name = $name; push @{$dns_mx{$self}}, _massage({ name => $name, priority => $priority, host => $host, ttl => $ttl, class => $class}) @@ -230,6 +239,10 @@ } elsif (/($valid_name) \s+ $ttl_cls TXT \s+ \"([^\"]*)\"/ix) { + if (length($1) == 0) { + $1 = $last_name; + } + $last_name = $1; push @{$dns_txt{$self}}, _massage({ name => $1, ttl => $2, class => $3, text=> $4}); }
From: "Simon Flack" <perl [...] simonflack.com>
To: bug-DNS-ZoneParse [...] rt.cpan.org
Subject: Re: [cpan #2291] SOA gets NS and MX records belonging to A records
Date: Wed, 26 Mar 2003 11:56:58 +0000
RT-Send-Cc:
Hi Alex On Wed, 26 Mar 2003 06:26:06 -0500 (EST), Guest via RT wrote Show quoted text
> If this sort of thing is encountered: > > asubdomain IN A 123.45.123.45 > IN NS ns0 > IN NS ns1 > IN MX 10 mx0 > IN MX 20 mx1 > > the NS and MX records end up with the SOA record, and because these > records have no name, they end up 'belonging' to it.
I hadn't expected that you could/would do that with different types of records. I thought you'd only omit the name for similar types. Show quoted text
> I have attached a patch (against 0.86 with patch from bug 2290) that > gets around the problem by setting any empty names to the name given > in the previous record, or @ if no records have appeared yet. In > other words, my patch is a total hack ;)
I've been thinking about this for a while. It's probably a good interim solution. I've held back because I'm assuming that if you rename 'asubdomain' to 'bsubdomain', you'd want that change to cascade to all the dependents. Show quoted text
> A better solution would be to attach these NS and MX records to > arrays held on the A record.
This is some way off I think. You'd want $zonefile->a to only return A records. If you delete a record that is depended upon by others, what happens to them? I'll probably add the patch to set empty names to previous name or @, since that sounds like a reasonable expectation. Thanks --simon
From: alex.woods [...] concept2100.co.uk
Show quoted text
> > I hadn't expected that you could/would do that with different types of > records. I thought you'd only omit the name for similar types. >
Surprised me to see it too, but looking in O'Reilly DNS and BIND, it appears in the chapter on parenting (p. 227 in the 4th edition), so it's probably not too uncommon. Show quoted text
> > I've been thinking about this for a while. It's probably a good > interim > solution. I've held back because I'm assuming that if you rename > 'asubdomain' > to 'bsubdomain', you'd want that change to cascade to all the > dependents. >
Quite. I did wonder about holding a reference to the previous name, but I doubt that if you were changing the name on the sub-records you would want the top record to be adjusted too. Only thing I can think of is to have the sub-records hold a reference to the top record and use the name from there, if you always want to print the name. Show quoted text
> This is some way off I think. You'd want $zonefile->a to only return A > records. If you delete a record that is depended upon by others, what > happens > to them? >
Well, for these cases where the A record has NSs and MXs, those NS and MX records are specific to just that A record, so I think it is perfectly ok to delete them along with the A record. Show quoted text
> I'll probably add the patch to set empty names to previous name or @, > since > that sounds like a reasonable expectation. >
Note that the NS and MX records for the A records still end up at the top of the file with the SOA rather than under the A record, but that is just a niggle really. Alex