2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-03 16:15:27 +00:00

3287. [port] Update ans.pl to work with Net::DNS 0.68. [RT #28028]

This commit is contained in:
Mark Andrews
2012-02-22 14:22:54 +00:00
parent afe2009552
commit 490b05960c
5 changed files with 201 additions and 147 deletions

View File

@@ -1,3 +1,5 @@
3287. [port] Update ans.pl to work with Net::DNS 0.68. [RT #28028]
3286. [bug] Managed key maintenance timer could fail to start
after 'rndc reconfig'. [RT #26786]

View File

@@ -14,7 +14,7 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# $Id: ans.pl,v 1.4 2011/03/18 04:41:15 each Exp $
# $Id: ans.pl,v 1.5 2012/02/22 14:22:54 marka Exp $
#
# This is the name server from hell. It provides canned
@@ -108,19 +108,23 @@ my @rules;
sub handleUDP {
my ($buf) = @_;
my ($packet, $err) = new Net::DNS::Packet(\$buf, 0);
my ($request, $err) = new Net::DNS::Packet(\$buf, 0);
$err and die $err;
$packet->header->qr(1);
$packet->header->aa(1);
my @questions = $packet->question;
my @questions = $request->question;
my $qname = $questions[0]->qname;
my $qtype = $questions[0]->qtype;
my $qclass = $questions[0]->qclass;
my $id = $request->header->id;
my $packet = new Net::DNS::Packet($qname, $qtype, $qclass);
$packet->header->qr(1);
$packet->header->aa(1);
$packet->header->id($id);
# get the existing signature if any, and clear the additional section
my $prev_tsig;
while (my $rr = $packet->pop("additional")) {
while (my $rr = $request->pop("additional")) {
if ($rr->type eq "TSIG") {
$prev_tsig = $rr;
}
@@ -193,19 +197,51 @@ sub packetlen {
my ($data) = @_;
my $q;
my $rr;
my $header;
my $offset;
#
# decode/encode were introduced in Net::DNS 0.68
# parse is no longer a method and calling it here makes perl croak.
#
my $decode = 0;
$decode = 1 if ($Net::DNS::VERSION >= 0.68);
if ($decode) {
($header, $offset) = Net::DNS::Header->decode(\$data);
} else {
($header, $offset) = Net::DNS::Header->parse(\$data);
}
my ($header, $offset) = Net::DNS::Header->parse(\$data);
for (1 .. $header->qdcount) {
($q, $offset) = Net::DNS::Question->parse(\$data, $offset);
if ($decode) {
($q, $offset) =
Net::DNS::Question->decode(\$data, $offset);
} else {
($q, $offset) =
Net::DNS::Question->parse(\$data, $offset);
}
}
for (1 .. $header->ancount) {
($rr, $offset) = Net::DNS::RR->parse(\$data, $offset);
if ($decode) {
($q, $offset) = Net::DNS::RR->decode(\$data, $offset);
} else {
($q, $offset) = Net::DNS::RR->parse(\$data, $offset);
}
}
for (1 .. $header->nscount) {
($rr, $offset) = Net::DNS::RR->parse(\$data, $offset);
if ($decode) {
($q, $offset) = Net::DNS::RR->decode(\$data, $offset);
} else {
($q, $offset) = Net::DNS::RR->parse(\$data, $offset);
}
}
for (1 .. $header->arcount) {
($rr, $offset) = Net::DNS::RR->parse(\$data, $offset);
if ($decode) {
($q, $offset) = Net::DNS::RR->decode(\$data, $offset);
} else {
($q, $offset) = Net::DNS::RR->parse(\$data, $offset);
}
}
return $offset;
}
@@ -253,20 +289,24 @@ sub sign_tcp_continuation {
sub handleTCP {
my ($buf) = @_;
my ($packet, $err) = new Net::DNS::Packet(\$buf, 0);
my ($request, $err) = new Net::DNS::Packet(\$buf, 0);
$err and die $err;
$packet->header->qr(1);
$packet->header->aa(1);
my @questions = $packet->question;
my @questions = $request->question;
my $qname = $questions[0]->qname;
my $qtype = $questions[0]->qtype;
my $qclass = $questions[0]->qclass;
my $id = $request->header->id;
my $packet = new Net::DNS::Packet($qname, $qtype, $qclass);
$packet->header->qr(1);
$packet->header->aa(1);
$packet->header->id($id);
# get the existing signature if any, and clear the additional section
my $prev_tsig;
my $signer;
while (my $rr = $packet->pop("additional")) {
while (my $rr = $request->pop("additional")) {
if ($rr->type eq "TSIG") {
$prev_tsig = $rr;
}
@@ -322,9 +362,10 @@ sub handleTCP {
}
#$packet->print;
push(@results,$packet->data);
$packet = new Net::DNS::Packet(\$buf, 0);
$packet = new Net::DNS::Packet($qname, $qtype, $qclass);
$packet->header->qr(1);
$packet->header->aa(1);
$packet->header->id($id);
}
}
print " A total of $count_these patterns matched\n";

View File

@@ -15,7 +15,7 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# $Id: tests.sh,v 1.10 2012/02/07 23:47:24 tbox Exp $
# $Id: tests.sh,v 1.11 2012/02/22 14:22:54 marka Exp $
# WARNING: The test labelled "testing request-ixfr option in view vs zone"
@@ -65,7 +65,12 @@ EOF
$RNDCCMD reload
sleep 2
for i in 0 1 2 3 4 5 6 7 8 9
do
$DIGCMD nil. SOA > dig.out
grep "SOA" dig.out > /dev/null && break
sleep 1
done
$DIGCMD nil. TXT | grep 'initial AXFR' >/dev/null || {
echo "I:failed"

View File

@@ -15,13 +15,13 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# $Id: clean.sh,v 1.17 2011/12/01 00:53:58 marka Exp $
# $Id: clean.sh,v 1.18 2012/02/22 14:22:54 marka Exp $
#
# Clean up after zone transfer tests.
#
rm -f dig.out.ns1 dig.out.ns2 dig.out.ns3
rm -f dig.out.ns1 dig.out.ns2 dig.out.ns3 dig.out.ns4
rm -f dig.out.ns5 dig.out.ns6 dig.out.ns7
rm -f axfr.out
rm -f ns1/slave.db

View File

@@ -15,7 +15,7 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# $Id: tests.sh,v 1.35 2011/12/01 00:53:58 marka Exp $
# $Id: tests.sh,v 1.36 2012/02/22 14:22:54 marka Exp $
SYSTEMTESTTOP=..
. $SYSTEMTESTTOP/conf.sh
@@ -234,7 +234,13 @@ EOF
$RNDCCMD reload | sed 's/^/I:ns4 /'
sleep 2
for i in 0 1 2 3 4 5 6 7 8 9
do
$DIGCMD nil. SOA > dig.out.ns4
grep SOA dig.out.ns4 > /dev/null && break
sleep 1
done
$DIGCMD nil. TXT | grep 'initial AXFR' >/dev/null || {
echo "I:failed"