X-Git-Url: http://gitweb.michael.orlitzky.com/?p=valtz.git;a=blobdiff_plain;f=valtz;h=adefae8ec3cf41a0696eb7e9dda49b97145aa68e;hp=26d516db4a8350b2b4ccb4173eb8cd6ce5196865;hb=908b69a476659a18ea097a8165fcf4ca1e8c50ed;hpb=097807e6b55527da495fa668a3c47fc938393743;ds=sidebyside diff --git a/valtz b/valtz index 26d516d..adefae8 100755 --- a/valtz +++ b/valtz @@ -48,14 +48,17 @@ my $COPYRIGHT = '; (C) 2003 Magnus Bodin, http://x42.com/software/'; $| = 1; my %opt; -getopts('?fFhHiIqrRstT:x', \%opt); +getopts('?fFhHiIqrRstT:', \%opt); my $FILESUFFIXREGEXP = '('.join('|', qw/ ,v ~ .bak .log .old .swp .tmp /).')$'; +# Validation errors my $verrs_total = 0; + +# "Permission" errors with respect to what record types are allowed my $perrs_total = 0; @@ -76,6 +79,7 @@ my %validation_msg = ( 1008 => 'integer out of bounds', 1009 => 'must have at least three labels to be valid as mail address', 1010 => 'must not be 2(NS), 5(CNAME), 6(SOA), 12(PTR), 15(MX) or 252(AXFR)', + 1011 => 'IP address found where hostname expected' ); # NOTE : ONLY translate the right-hand part @@ -238,6 +242,13 @@ my %token_validator = ( 'x' => [ 5, sub { my ($type, $s) = @_; my $result = 0; + + # Check to see if someone put an IP address in a hostname + # field. The motivation for this was MX records where many + # people expect an IP address to be a valid response, but I + # see no harm in enforcing it elsewhere. + return 1011 if $s =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\.?$/; + # check all parts for (split /\./, $s) { @@ -891,7 +902,7 @@ if ($opt{h} || $opt{H} || $opt{'?'}) valtz $VERSION, $COPYRIGHT validates tinydns-data zone files Usage: - $0 [-hfFqrRiItTx] + $0 [-hfFqrRiItT] -h shows this help. @@ -962,10 +973,6 @@ Usage: A commandline way to explicitly set the allowed recordtypes. This is _concatenated_ to the allowtype-allowed recordtypes. - -x Exit with non-null exit code on errors; i.e. make errors detectable by - e.g. shell scripts; 1 = validation error, 2 = permission error, - 3 = combination of 1 and 2. - All errors in the zonefiles are sent to STDERR. @@ -1104,7 +1111,7 @@ else } } -if ($opt{x} && ($verrs_total + $perrs_total)) +if ($verrs_total + $perrs_total) { my $exitcode = $verrs_total > 0 ? 1 : 0; $exitcode += $perrs_total > 0 ? 2 : 0;