Remove some trailing whitespace and empty comments where it should (ha
ha) have no effect on the behavior of the program.
##
# global location registry
# (reset for every zone file)
##
# global location registry
# (reset for every zone file)
# NOTE : DO NOT CHANGE the id numbers
my %validation_msg = (
# NOTE : DO NOT CHANGE the id numbers
my %validation_msg = (
- $result = 1008 if $boundary && ($i >= $boundary);
+ $result = 1008 if $boundary && ($i >= $boundary);
if ($s =~ /^(\d+)(\.(\d+)(\.(\d+)(\.(\d+))?)?)?$/)
{
my ($a, $b, $c, $d) = ($1, $3, $5, $7);
if ($s =~ /^(\d+)(\.(\d+)(\.(\d+)(\.(\d+))?)?)?$/)
{
my ($a, $b, $c, $d) = ($1, $3, $5, $7);
- $a ||= 0;
- $b ||= 0;
- $c ||= 0;
- $d ||= 0;
- if (($a > 255) || ($b > 255) || ($c > 255) || ($d > 255))
+ $a ||= 0;
+ $b ||= 0;
+ $c ||= 0;
+ $d ||= 0;
+ if (($a > 255) || ($b > 255) || ($c > 255) || ($d > 255))
if ($s =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)\.?$/)
{
my ($a, $b, $c, $d) = ($1, $3, $5, $7);
if ($s =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)\.?$/)
{
my ($a, $b, $c, $d) = ($1, $3, $5, $7);
- $a ||= 0;
- $b ||= 0;
- $c ||= 0;
- $d ||= 0;
- if (($a > 255) || ($b > 255) || ($c > 255) || ($d > 255))
+ $a ||= 0;
+ $b ||= 0;
+ $c ||= 0;
+ $d ||= 0;
+ if (($a > 255) || ($b > 255) || ($c > 255) || ($d > 255))
's' => [ 10, sub {
my ($type, $s) = @_;
my $result = 0;
's' => [ 10, sub {
my ($type, $s) = @_;
my $result = 0;
- # TODO : Validation needed?
+ # TODO : Validation needed?
return $result;
}],
'p' => [ 11, sub {
return $result;
}],
'p' => [ 11, sub {
my ($type, $s) = @_;
my $result = 0;
# check all parts
my ($type, $s) = @_;
my $result = 0;
# check all parts
'rname' => [ 13, sub {
my ($type, $s) = @_;
my $result = 0;
'rname' => [ 13, sub {
my ($type, $s) = @_;
my $result = 0;
# check all parts
my @parts = split /\./, $s;
return 1009 if @parts < 3;
# check all parts
my @parts = split /\./, $s;
return 1009 if @parts < 3;
'n' => [ 19, sub {
my ($type, $s) = @_;
my $result = validate_integer($s, 65535);
'n' => [ 19, sub {
my ($type, $s) = @_;
my $result = validate_integer($s, 65535);
return 1010 if ($s==2)||($s==5)||($s==6)||($s==12)||($s==15)||($s==252);
return $result;
}],
'rdata' => [ 20, sub {
my ($type, $s) = @_;
return 1010 if ($s==2)||($s==5)||($s==6)||($s==12)||($s==15)||($s==252);
return $result;
}],
'rdata' => [ 20, sub {
my ($type, $s) = @_;
- # TODO : Validation needed?
+ # TODO : Validation needed?
my $result = 0;
return $result;
}],
my $result = 0;
return $result;
}],
#
if (length($ip) && ($mask[$c] eq 'x'))
{
#
if (length($ip) && ($mask[$c] eq 'x'))
{
$tmp =~ s/\.$//;
push @{$$result[3]}, $tmp;
}
$tmp =~ s/\.$//;
push @{$$result[3]}, $tmp;
}
my $tv = &{$$validator[1]}($type, $token);
if ($tv)
{
$$result[0] ^= (2 ** $$validator[0]);
my $tv = &{$$validator[1]}($type, $token);
if ($tv)
{
$$result[0] ^= (2 ** $$validator[0]);
"\npos $c; $mask[$c]; $validation_msg{$tv}";
}
}
"\npos $c; $mask[$c]; $validation_msg{$tv}";
}
}
- $$result[0] ^= (2 ** $$validator[0]);
+ $$result[0] ^= (2 ** $$validator[0]);
$$result[1] .= "\npos $c; $mask[$c]; ".
$token_name{$mask[$c]}.' is mandatory';
}
$$result[1] .= "\npos $c; $mask[$c]; ".
$token_name{$mask[$c]}.' is mandatory';
}
if ($$result[0])
{
$$result[1] = "expected: ".$line_type{$type}->[1]."\n".
if ($$result[0])
{
$$result[1] = "expected: ".$line_type{$type}->[1]."\n".
{
$result = [ 1, sprintf("unknown record type: #%02x",
ord($type)) ];
{
$result = [ 1, sprintf("unknown record type: #%02x",
ord($type)) ];
$$result[1] =~ s/^\n+//;
$$result[1] =~ s/\n+/\n/g;
$$result[1] =~ s/^\n+//;
$$result[1] =~ s/\n+/\n/g;
- # result is now [ iErrno, sErrtxt, sRecordType, [ sFQDN ] ]
+ # result is now [ iErrno, sErrtxt, sRecordType, [ sFQDN ] ]
chomp;
s/^\s+//;
s/\s+$//;
chomp;
s/^\s+//;
s/\s+$//;
if (/^(\w+)\s+(.+)$/)
{
my ($key, $value) = ($1, $2);
if (/^(\w+)\s+(.+)$/)
{
my ($key, $value) = ($1, $2);
$$f{allowtype} = (keys %{$$f{allowtype}})[0];
$$f{allowtype} .= $opt{T};
$$f{allowtype} = (keys %{$$f{allowtype}})[0];
$$f{allowtype} .= $opt{T};
my $allowtyperegex = make_char_regexp($$f{allowtype});
if ($$f{extralog})
my $allowtyperegex = make_char_regexp($$f{allowtype});
if ($$f{extralog})
{
next if $zonefile =~ /$FILESUFFIXREGEXP/i;
}
{
next if $zonefile =~ /$FILESUFFIXREGEXP/i;
}
my $info = 0;
my $filehandle = \*STDIN;
my $fopen = 1;
my $info = 0;
my $filehandle = \*STDIN;
my $fopen = 1;
{
my $temp = ($zonefile eq '-') ? '<STDIN>' : $zonefile;
p $output, "File $temp";
{
my $temp = ($zonefile eq '-') ? '<STDIN>' : $zonefile;
p $output, "File $temp";
%loreg = ();
my $errs = 0;
my $lno = 0;
%loreg = ();
my $errs = 0;
my $lno = 0;
# Check $$v[3] against allowed fqdn:s:wq!
if (keys %{$$f{deny}})
{
# Check $$v[3] against allowed fqdn:s:wq!
if (keys %{$$f{deny}})
{
my $patterns = regexped_patterns($$f{deny});
# Default ALLOW ALL
$ok = $fqdnok = 1;
$reason = 'default allow ^.*$';
my $patterns = regexped_patterns($$f{deny});
# Default ALLOW ALL
$ok = $fqdnok = 1;
$reason = 'default allow ^.*$';
for my $pat (@{$patterns})
{
for (@{$$v[3]})
for my $pat (@{$patterns})
{
for (@{$$v[3]})
if ($ok && length($line))
{
if ($ok && length($line))
{
{
$errs++;
$perrs_total++;
{
$errs++;
$perrs_total++;
- p $output, " line $lno; err -2; $line";
+ p $output, " line $lno; err -2; $line";
p $output, " use of fqdn denied; $reason";
if ($opt{I})
{
p $output, " use of fqdn denied; $reason";
if ($opt{I})
{
- print STDOUT "# line $lno; err -2; $line\n";
+ print STDOUT "# line $lno; err -2; $line\n";
print STDOUT "# use of fqdn denied; $reason\n";
print STDOUT "# use of fqdn denied; $reason\n";
-
- # Close all extra logfiles
+
+ # Close all extra logfiles
for my $el (@extralogs)
{
if (close($$el[0]))
for my $el (@extralogs)
{
if (close($$el[0]))
if ($opt{h} || $opt{H} || $opt{'?'})
{
print <<"--EOT";
if ($opt{h} || $opt{H} || $opt{'?'})
{
print <<"--EOT";
-valtz $VERSION, $COPYRIGHT
+valtz $VERSION, $COPYRIGHT
validates tinydns-data zone files
Usage:
$0 [-hfFqrRiItTx] <file(s)>
validates tinydns-data zone files
Usage:
$0 [-hfFqrRiItTx] <file(s)>
-f filter (don't just validate) file and output accepted lines to STDOUT.
-f filter (don't just validate) file and output accepted lines to STDOUT.
-F treat files as filter configuration files for more advanced filtering.
These filterfiles one or several of the following filter directives:
-F treat files as filter configuration files for more advanced filtering.
These filterfiles one or several of the following filter directives:
Multiple zonefile, allow- and deny-lines are allowed, but also the
alternative file:-line that points to a textfile containing one
value per line.
Multiple zonefile, allow- and deny-lines are allowed, but also the
alternative file:-line that points to a textfile containing one
value per line.
-r allows fqdn to be empty thus denoting the root.
This is also allowed per default when doing implict allow - see deny,
or when specifying 'allow .', i.e. explictly allowing root as such.
(cannot be combined with deny)
-r allows fqdn to be empty thus denoting the root.
This is also allowed per default when doing implict allow - see deny,
or when specifying 'allow .', i.e. explictly allowing root as such.
(cannot be combined with deny)
-R relaxes the validation and allows empty mname and p-fields.xi
This is probably not very useful.
-R relaxes the validation and allows empty mname and p-fields.xi
This is probably not very useful.
-i allows the ip-fields to be empty as well. These will then not generate any
records.
-I Include rejected lines as comments in output (valid when filtering).
-i allows the ip-fields to be empty as well. These will then not generate any
records.
-I Include rejected lines as comments in output (valid when filtering).
-q Do not echo valid lines to STDOUT.
-q Do not echo valid lines to STDOUT.
-s DO NOT ignore files ending with ,v ~ .bak .log .old .swp .tmp
which is done per default.
-s DO NOT ignore files ending with ,v ~ .bak .log .old .swp .tmp
which is done per default.
>/etc/tinydns/data.otto \
2>/var/log/tinydns/valtz.log
>/etc/tinydns/data.otto \
2>/var/log/tinydns/valtz.log
Example filterfile for using as import from primary (as above):
zonefile /var/zones/external/otto/zone-*
deny bodin.org
deny x42.com
Example filterfile for using as import from primary (as above):
zonefile /var/zones/external/otto/zone-*
deny bodin.org
deny x42.com
- extralog /var/log/tinydns/external-otto.log
+ extralog /var/log/tinydns/external-otto.log
Example #2, strict filter for a certain user editing just A-records
zonefile /home/felix/zones/zone-fl3x-net
allow fl3x.net
Example #2, strict filter for a certain user editing just A-records
zonefile /home/felix/zones/zone-fl3x-net
allow fl3x.net
extralog /var/log/tinydns/fl3x-net.log
Example #3, export filter to secondary
extralog /var/log/tinydns/fl3x-net.log
Example #3, export filter to secondary
elsif (@{$files} == 0)
{
print <<"--EOT";
elsif (@{$files} == 0)
{
print <<"--EOT";
-valtz $VERSION, $COPYRIGHT
+valtz $VERSION, $COPYRIGHT
validates tinydns-data zone files
Usage:
Simple validation:
validates tinydns-data zone files
Usage:
Simple validation:
{
next if $zonefile =~ /$FILESUFFIXREGEXP/i;
}
{
next if $zonefile =~ /$FILESUFFIXREGEXP/i;
}
my $filehandle = \*STDIN;
my $fopen = 1;
if ($zonefile ne '-')
my $filehandle = \*STDIN;
my $fopen = 1;
if ($zonefile ne '-')
{
print STDOUT "# line $lno; err $$v[0] $line
print STDOUT "# $$v[1]; \n";
{
print STDOUT "# line $lno; err $$v[0] $line
print STDOUT "# $$v[1]; \n";