INN commit: trunk/scripts (inncheck.in)

INN Commit rra at isc.org
Fri Jul 8 20:20:04 UTC 2011


    Date: Friday, July 8, 2011 @ 13:20:03
  Author: iulius
Revision: 9230

inncheck:  improvements in checks

* Allow uppercase characters in IPv6 addresses.
RFC 5952 section 4 / 4.3 says that all characters in an IPv6 address
MUST be textually represented in lowercase and advises that humans
should do so, too.  At the same time, all implementations must be able to
accept both lowercase and uppercase.

* Suppress (useless and misleading) error messages after an error
is detected, until the parser is back in sync.
The drawback is that it will hide two consecutive errors until the
first one gets fixed.

* Allow not to specify the maximum size in storage.conf.
"size: 16384," was treated as an error though it was totally valid
and meant "no upper limit".

* Recognize inclusions in readers.conf and innfeed.conf.
inncheck will ignore the include statement.
The drawback is that every file must be self-contained on its own:
a file must be a "complete" set of blocks and options.
In order to check the included file, inncheck has to be run again
on it (with for instance the option "readers.conf=/path/to/included/file").

Thanks to Florian Schlichting for the patch.

Modified:
  trunk/scripts/inncheck.in

-------------+
 inncheck.in |   27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

Modified: inncheck.in
===================================================================
--- inncheck.in	2011-07-07 11:43:41 UTC (rev 9229)
+++ inncheck.in	2011-07-08 20:20:03 UTC (rev 9230)
@@ -168,7 +168,7 @@
 my $ipv4 = "$ip$dot$ip$dot$ip$dot$ip";
 my $ipv4_cidr = "$ip(?:$dot$ip){0,3}\\/[1-3]?\\d";
 my $ipv4_wildmat = '[\d\[\]\*]+(?:\.[\d\[\]\*]+){0,3}';
-my $ipv6 = '[\da-f:.]+'; # e.g. ::ffff:192.168.0.10
+my $ipv6 = '[\da-fA-F:.]+'; # e.g. ::ffff:192.168.0.10
 my $ipv6_cidr = '[\da-f:.]+(?:\\/1?\d?\d)?'; # matches $ipv6 as well
 my $hostname = '[\w-]+|[\w.-]+\.[a-zA-Z]{2,}'; # hostname, FQDN
 my $hostnameRE = "(?:$hostname|$ipv4|$ipv6)";
@@ -182,8 +182,8 @@
     'IPv6 address / "any / "none"'      => '^(?:' . $ipv6 . '|any|none)$',
     'list of hostnames'                 => '^'.$hostnameRE.'(?:\s*,\s*'.$hostnameRE.')*$',
     'list of hostnames or netblocks'    => '^'.$hostblockRE.'(?:\s*,\s*'.$hostblockRE.')*$',
-    'minsize[,maxsize] definition'      => '^\d+(?:,\d+)?$',
-    'mintime[,maxtime] definition'      => '^(?:\d+[Mdhms])+(?:,(?:\d+[Mdhms])+)?$',
+    'minsize[,maxsize] definition'      => '^\d+(?:,\d*)?$',
+    'mintime[,maxtime] definition'      => '^(?:\d+[Mdhms])+(?:,(?:\d+[Mdhms])*)?$',
     'number'                            => '^\d+$',
     'number / "unlimited" / "none"'     => '^(?:\d+|unlimited|none)$',
     'path'                              => '.*', # useful?
@@ -201,11 +201,13 @@
     my @groups; # our stack of nested groups
     my %return; # flat hash of groups returned to caller for further examination
     my $group = { 'type' => '<global scope>', 'line' => 0, 'name' => '<global scope>' };
+    my $parse_error = 0; # stop printing errors when we've seen unknown text, until re-sync
 
     while (my $word = get_config_word()) {
         if (defined $options->{$word}) {
             # $word starts a new group definition:  "peer news.example.com {"
             my ($name, $curly);
+            $parse_error = 0;
 
             eprint "$file:$line: cannot nest $word in $group->{'type'}!\n"
                 unless ($group->{'type'} eq 'group'
@@ -234,6 +236,7 @@
         }
 
         if ($word eq '}') {
+            $parse_error = 0;
             if (scalar @groups == 0) {
                 eprint "$file:$line: extra closing brace";
             } else {
@@ -243,9 +246,16 @@
             next;
         }
 
+        # include-file hack:  ignore; user needs to check it separately
+        if (defined $options->{'<include>'}->{$word}) {
+            $parse_error = 0;
+            my $includefile = get_config_word();
+            next;
+        }
+
         # $word must be an option key by now
         eprint "$file:$line: option $word must be immediately followed by a colon\n"
-            unless $word =~ s/:$//;
+            unless $word =~ s/:$// or $parse_error;
         eprint "$file:$line: duplicate option $word in $group->{'type'} $group->{'name'}\n"
             if exists $group->{$word} and not defined $options->{'<multi>'}->{$word};
 
@@ -253,12 +263,15 @@
                  : defined $options->{'<anywhere>'}->{$word}     ? $options->{'<anywhere>'}->{$word}
                  : undef;
         if ($type) {
+            $parse_error = 0;
             my $value = get_config_word();
             $group->{$word} = $value;
             eprint "$file:$line: not a valid $type: '$value'\n"
                 unless $value =~ /$type_regex{$type}/;
         } else {
-            eprint "$file:$line: not a valid option name: $word\n";
+            eprint "$file:$line: not a valid option name: $word\n"
+                unless $parse_error;
+            $parse_error = 1;
         }
     }
     while (scalar @groups > 0) {
@@ -605,6 +618,7 @@
             'peer'              => {
                 'ip-name'               => 'hostname',
             },
+            '<include>'         => { '$INCLUDE' => 'ignore' },
         }
     );
     # check presence of required keys in global scope
@@ -971,7 +985,8 @@
                 'auth'          => 1,
                 'perl_auth'     => 1,
                 'python_auth'   => 1,
-            }
+            },
+            '<include>' => { 'include' => 'ignore' },
         }
     );
     return;




More information about the inn-committers mailing list