all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Mira Limbeck <m.limbeck@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH firewall] fix #2358: allow --<opt> in firewall rule config files
Date: Mon, 22 Feb 2021 13:00:18 +0100	[thread overview]
Message-ID: <20210222120018.14608-1-m.limbeck@proxmox.com> (raw)

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 | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm
index 0bbe7d2..92ea33d 100644
--- a/src/PVE/Firewall.pm
+++ b/src/PVE/Firewall.pm
@@ -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;
 	}
-- 
2.20.1





             reply	other threads:[~2021-02-22 12:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-22 12:00 Mira Limbeck [this message]
2021-02-22 13:43 ` [pve-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210222120018.14608-1-m.limbeck@proxmox.com \
    --to=m.limbeck@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal