equal
deleted
inserted
replaced
40 print <> if @ARGV; |
40 print <> if @ARGV; |
41 } |
41 } |
42 exit 0; |
42 exit 0; |
43 }; |
43 }; |
44 while (<$z>) { |
44 while (<$z>) { |
|
45 /^#/ and next; # comment |
45 state $line; |
46 state $line; |
46 s/^\s*(.*?)\s*$/$1 /; |
47 s/^\s*(.*?)\s*$/$1 /; |
47 chomp($line .= $_); # continuation line |
48 chomp($line .= $_); # continuation line |
48 if (/\A\}/) { # config item done |
49 if (/\A\}/) { # config item done |
49 $line =~ s/\s$//; |
50 $line =~ s/\s$//; |
50 push @conf, $line; |
51 push @conf, $line; |
51 $line = ''; |
52 $line = ''; |
52 } |
53 } |
53 } |
54 } |
54 return grep { |
55 return grep { |
55 # FIXME: 172.0 .. 172.31 is missing |
56 # FIXME: 172.0 .. 172.31 is missing |
56 not /\b(?:0|127|10|168\.192|255)\.in-addr\.arpa$/ and |
57 not /\b(?:0|127|10|168\.192|255)\.in-addr\.arpa$/ and |
57 not /^localhost$/; |
58 not /^localhost$/; |
58 } map { /zone\s"?(\S+?)"?\s/ } grep { /type (?:master|slave)/ } @conf; |
59 } map { /zone\s"?(\S+?)"?\s/ } grep { /type (?:master|slave)/ } @conf; |
59 } |
60 } |
153 |
154 |
154 if (@errs or "@our" ne "@public") { |
155 if (@errs or "@our" ne "@public") { |
155 local $" = ', '; |
156 local $" = ', '; |
156 die sprintf "NS differ (%s: @our) vs (public: @public)\n", |
157 die sprintf "NS differ (%s: @our) vs (public: @public)\n", |
157 $is_override ? 'override' : 'our'; |
158 $is_override ? 'override' : 'our'; |
158 |
159 |
159 } |
160 } |
160 |
161 |
161 @ns = uniq sort @our, @public; |
162 @ns = uniq sort @our, @public; |
162 ### @ns |
163 ### @ns |
163 return @ns; |
164 return @ns; |
169 ### @serials |
170 ### @serials |
170 |
171 |
171 if (uniq(map { /(\d+)/ } @serials) != 1) { |
172 if (uniq(map { /(\d+)/ } @serials) != 1) { |
172 die "serials do not match: @serials\n"; |
173 die "serials do not match: @serials\n"; |
173 } |
174 } |
174 |
175 |
175 $serials[0] =~ /(\d+)/; |
176 $serials[0] =~ /(\d+)/; |
176 return $1; |
177 return $1; |
177 } |
178 } |
178 |
179 |
179 sub main { |
180 sub main { |
180 my @argv = @_; |
181 my @argv = @_; |
181 my $opt_reference = '127.0.0.1'; |
182 my $opt_reference = '127.0.0.1'; |
182 my $opt_progress = -t; |
183 my $opt_progress = -t; |
183 my ($opt_override)= grep { -f } '/etc/check_dns-delegation/override'; |
184 my ($opt_override)= grep { -f } '/etc/check_dns-delegation/override'; |
184 |
185 |
185 |
186 |
186 GetOptionsFromArray( |
187 GetOptionsFromArray( |
187 \@argv, |
188 \@argv, |
188 'reference=s' => \$opt_reference, |
189 'reference=s' => \$opt_reference, |
189 'progress!' => \$opt_progress, |
190 'progress!' => \$opt_progress, |
206 foreach my $domain (shuffle @domains) { |
207 foreach my $domain (shuffle @domains) { |
207 state $all = @domains; |
208 state $all = @domains; |
208 state $i++; |
209 state $i++; |
209 print STDERR "$domain ($i/$all) " if $opt_progress; |
210 print STDERR "$domain ($i/$all) " if $opt_progress; |
210 |
211 |
211 my @ns = eval { ns_ok($domain, $override{$domain} ? $override{$domain} : [$opt_reference], |
212 my @ns = eval { ns_ok($domain, $override{$domain} ? $override{$domain} : [$opt_reference], |
212 $override{$domain}) }; |
213 $override{$domain}) }; |
213 if ($@) { |
214 if ($@) { |
214 $CRITICAL{$domain} = $@; |
215 $CRITICAL{$domain} = $@; |
215 say STDERR 'fail(ns)' if $opt_progress; |
216 say STDERR 'fail(ns)' if $opt_progress; |
216 next; |
217 next; |
217 } |
218 } |
218 print STDERR 'ok(ns) ' if $opt_progress; |
219 print STDERR 'ok(ns) ' if $opt_progress; |