diff options
-rwxr-xr-x | dnsdbck/dnsdbck | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/dnsdbck/dnsdbck b/dnsdbck/dnsdbck index cf741ce..9e7ae70 100755 --- a/dnsdbck/dnsdbck +++ b/dnsdbck/dnsdbck @@ -1,5 +1,5 @@ #! /usr/bin/perl -# Copyright (C) 2011 Sergey Poznyakoff <gray@gnu.org> +# Copyright (C) 2011, 2015 Sergey Poznyakoff <gray@gnu.org> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -292,6 +292,7 @@ sub private_network($) { my @octet = split(/\./, $arg); $arg = "$octet[2].$octet[1].$octet[0].0/24"; } + return 0 unless Net::CIDR::cidrvalidate($arg); return Net::CIDR::cidrlookup($arg, @private_network_cidr_list); } @@ -303,6 +304,7 @@ sub create_soa_allowed($) { my @octet = split(/\./, $arg); $arg = "$octet[2].$octet[1].$octet[0].0/24"; } + return 0 unless Net::CIDR::cidrvalidate($arg); return Net::CIDR::cidrlookup($arg, @create_soa_allow_list); } @@ -325,8 +327,8 @@ if ($ENV{'DNSDBCK_CONF'}) { read_config_file("$sys_config_file"); } -GetOptions("help|h" => \$help, - "man" => \$man, +GetOptions("help|man" => \$man, + "h" => \$help, "debug|d:s" => sub { if (!$_[1]) { foreach my $key (keys %debug_level) { @@ -493,8 +495,9 @@ while (my ($key, $value) = each(%reverse_zone)) { my $canon_hostname; ($canon_hostname = $hostname) =~ s/\.$//; next if ($ignored_host{$canon_hostname}); - $canon_hostname =~ s/[^\.]+\.//; - next if ($ignored_zone{$canon_hostname}); + while ($canon_hostname =~ s/[^\.]+\.//) { + next REVLOOP if $ignored_zone{$canon_hostname}; + } my $fullkey = "$host.$key"; my $msg = "$ar[3]: $hostname => $fullkey: no corresponding reverse record and no SOA for $key in the database"; @@ -549,16 +552,14 @@ while (my ($key, $value) = each(%reverse_zone)) { my ($name,$aliases,$addrtype,$length,@addrs) = gethostbyname($row{'data'}); - if (defined(@addrs)) { - foreach my $addr (@addrs) { - my @oct = split(/\./, inet_ntoa($addr)); - my $revaddr = "$oct[3].$oct[2].$oct[1].$oct[0].in-addr.arpa"; - debug('DNS', 2, "$row{'data'} resolves to $revaddr"); + foreach my $addr (@addrs) { + my @oct = split(/\./, inet_ntoa($addr)); + my $revaddr = "$oct[3].$oct[2].$oct[1].$oct[0].in-addr.arpa"; + debug('DNS', 2, "$row{'data'} resolves to $revaddr"); # print STDERR "$revaddr eq $fullkey\n"; - if ($revaddr eq $fullkey) { - debug('GENERAL', 2, "$msg, but backresolve is OK"); - next DBLOOP; - } + if ($revaddr eq $fullkey) { + debug('GENERAL', 2, "$msg, but backresolve is OK"); + next DBLOOP; } } @@ -725,11 +726,11 @@ verbosity level. Valid categories are: C<GENERAL>, C<SQL>, C<DNS> and C<MISSING> (all case-insensitive). If B<level> is not supplied, 1 is used instead. -=item B<--help>, B<-h> +=item B<-h> Show a terse help summary and exit. -=item B<--man> +=item B<--help> Prints the manual page and exits. |