public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christoph Heiss <c.heiss@proxmox.com>
To: Stoiko Ivanov <s.ivanov@proxmox.com>
Cc: pmg-devel@lists.proxmox.com
Subject: Re: [pmg-devel] [PATCH pmg-api v3] fix #4410: Remove non-null host bits from CIDR when writing postfix config
Date: Thu, 29 Dec 2022 10:21:19 +0100	[thread overview]
Message-ID: <20221229092119.ajzs3ujegdtvukig@maui.proxmox.com> (raw)
In-Reply-To: <20221228180843.0c7671b7@rosa.proxmox.com>

On Wed, Dec 28, 2022 at 06:08:43PM +0100, Stoiko Ivanov wrote:
> Looks good and minimal - one tiny nit/improvement:
>
> On Wed, 28 Dec 2022 12:52:59 +0100
> Christoph Heiss <c.heiss@proxmox.com> wrote:
>
> > [..]
> > @@ -1337,10 +1339,12 @@ sub get_template_vars {
> >
> >      my $netlist = PVE::INotify::read_file('mynetworks');
> >      foreach my $cidr (keys %$netlist) {
> > -	if ($cidr =~ m/^($IPV6RE)\/(\d+)$/) {
> > -	    $mynetworks->{"[$1]/$2"} = 1;
> > +	my $ip = PVE::Network::IP_from_cidr($cidr);
> this can return undef and we should check for it
> while our config-parser takes care of many edge-cases and broken cidrs I
> managed to get passed it with a mask of 148 (max would be 128 for ipv6)
>
> I would expect that at least part of our users do edit the config files
> manually and end up with invalid data there.
>
> Probably a `warn` and ignoring the entry might be appropriate here (afaict
> this is what happens when the mynetworks parser runs into a broken line as
> well)
Good point, really did not think of that.
Will send a v4 shortly!

>
>
> > +	if ($ip->version() == 4) {
> > +	    $mynetworks->{$ip->prefix()} = 1;
> >  	} else {
> > -	    $mynetworks->{$cidr} = 1;
> > +	    my $address = '[' . $ip->short() . ']/' . $ip->prefixlen();
> > +	    $mynetworks->{$address} = 1;
> >  	}
> >      }
> >
> > --
> > 2.30.2
> >
> >
> >
> > _______________________________________________
> > pmg-devel mailing list
> > pmg-devel@lists.proxmox.com
> > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
> >
> >
>




      reply	other threads:[~2022-12-29  9:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-28 11:52 Christoph Heiss
2022-12-28 17:08 ` Stoiko Ivanov
2022-12-29  9:21   ` Christoph Heiss [this message]

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=20221229092119.ajzs3ujegdtvukig@maui.proxmox.com \
    --to=c.heiss@proxmox.com \
    --cc=pmg-devel@lists.proxmox.com \
    --cc=s.ivanov@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal