]> git.proxmox.com Git - pve-firewall.git/commitdiff
generate warnings when we read the configuration file
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 2 Jun 2014 11:14:42 +0000 (13:14 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 2 Jun 2014 11:14:42 +0000 (13:14 +0200)
src/PVE/Firewall.pm

index b2bcc32e5ca685cfafd84cc05019094c3ee6a925..153a91eae70c1766b7ce7753514e4d0e2bca38e3 100644 (file)
@@ -1971,8 +1971,6 @@ for (my $i = 0; $i < $MAX_NETS; $i++)  {
 sub parse_fw_rule {
     my ($prefix, $line, $cluster_conf, $fw_conf, $rule_env, $verbose) = @_;
 
-    chomp $line;
-
     my $orig_line = $line;
 
     my $rule = {};
@@ -2066,7 +2064,6 @@ sub parse_vmfw_option {
        $opt = lc($1);
        $value = $2;
     } else {
-       chomp $line;
        die "can't parse option '$line'\n"
     }
 
@@ -2090,7 +2087,6 @@ sub parse_hostfw_option {
        $opt = lc($1);
        $value = int($2);
     } else {
-       chomp $line;
        die "can't parse option '$line'\n"
     }
 
@@ -2109,7 +2105,6 @@ sub parse_clusterfw_option {
        $opt = lc($1);
        $value = uc($3);
     } else {
-       chomp $line;
        die "can't parse option '$line'\n"
     }
 
@@ -2164,6 +2159,8 @@ sub generic_fw_config_parser {
        next if $line =~ m/^#/;
        next if $line =~ m/^\s*$/;
 
+       chomp $line;
+
        my $linenr = $fh->input_line_number();
        my $prefix = "$filename (line $linenr)";
 
@@ -2284,6 +2281,7 @@ sub generic_fw_config_parser {
                }
            };
            if (my $err = $@) {
+               chomp $err;
                $errors->{cidr} = $err;
            }
 
@@ -2292,6 +2290,13 @@ sub generic_fw_config_parser {
            $entry->{comment} = $comment if $comment;
            $entry->{errors} =  $errors if $errors;
 
+           if ($verbose && $errors) {
+               warn "$prefix - errors in ipset: $line\n";
+               foreach my $p (keys %{$errors}) {
+                   warn "  $p: $errors->{$p}\n";
+               }
+           }
+
            push @{$res->{$section}->{$group}}, $entry;
        } else {
            warn "$prefix: skip line - unknown section\n";
@@ -2629,6 +2634,7 @@ sub generate_ipset {
     # remove duplicates
     my $nethash = {};
     foreach my $entry (@$options) {
+       next if $entry->{errors}; # skip entries with errors
        eval {
            my $cidr = resolve_alias($clusterfw_conf, $fw_conf, $entry->{cidr});
            $nethash->{$cidr} = { cidr => $cidr, nomatch => $entry->{nomatch} };