]> git.proxmox.com Git - pve-firewall.git/commitdiff
fix #2358: allow --<opt> in firewall rule config files
authorMira Limbeck <m.limbeck@proxmox.com>
Mon, 22 Feb 2021 12:00:18 +0000 (13:00 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 22 Feb 2021 13:42:23 +0000 (14:42 +0100)
The docs mention --<opt> as valid syntax for firewall rules, but the
code that parses the .fw files only accepts -<opt>. To make it
consistent with the docs and the API, also accept --<opt>.

In addition allow 'proto' as option, not only '-p'.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
src/PVE/Firewall.pm

index 0bbe7d2277db3e0cd231c27a46a199875c802d58..92ea33d6ca8e6ffd84dbba7adbba7227a0496a17 100644 (file)
@@ -2747,33 +2747,33 @@ sub parse_fw_rule {
 
        last if $rule->{type} eq 'group';
 
-       if ($line =~ s/^-p (\S+)\s*//) {
+       if ($line =~ s/^(?:-p|--?proto) (\S+)\s*//) {
            $rule->{proto} = $1;
            next;
        }
 
-       if ($line =~ s/^-dport (\S+)\s*//) {
+       if ($line =~ s/^--?dport (\S+)\s*//) {
            $rule->{dport} = $1;
            next;
        }
 
-       if ($line =~ s/^-sport (\S+)\s*//) {
+       if ($line =~ s/^--?sport (\S+)\s*//) {
            $rule->{sport} = $1;
            next;
        }
-       if ($line =~ s/^-source (\S+)\s*//) {
+       if ($line =~ s/^--?source (\S+)\s*//) {
            $rule->{source} = $1;
            next;
        }
-       if ($line =~ s/^-dest (\S+)\s*//) {
+       if ($line =~ s/^--?dest (\S+)\s*//) {
            $rule->{dest} = $1;
            next;
        }
-       if ($line =~ s/^-log (emerg|alert|crit|err|warning|notice|info|debug|nolog)\s*//) {
+       if ($line =~ s/^--?log (emerg|alert|crit|err|warning|notice|info|debug|nolog)\s*//) {
            $rule->{log} = $1;
            next;
        }
-       if ($line =~ s/^-icmp-type (\S+)\s*//) {
+       if ($line =~ s/^--?icmp-type (\S+)\s*//) {
            $rule->{'icmp-type'} = $1;
            next;
        }