From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id D2F7D926B2 for ; Thu, 29 Dec 2022 10:21:24 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B23835267 for ; Thu, 29 Dec 2022 10:21:24 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 29 Dec 2022 10:21:23 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id B892F44316 for ; Thu, 29 Dec 2022 10:21:23 +0100 (CET) Date: Thu, 29 Dec 2022 10:21:19 +0100 From: Christoph Heiss To: Stoiko Ivanov Cc: pmg-devel@lists.proxmox.com Message-ID: <20221229092119.ajzs3ujegdtvukig@maui.proxmox.com> References: <20221228115259.215030-1-c.heiss@proxmox.com> <20221228180843.0c7671b7@rosa.proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221228180843.0c7671b7@rosa.proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL -0.005 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pmg-devel] [PATCH pmg-api v3] fix #4410: Remove non-null host bits from CIDR when writing postfix config X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Dec 2022 09:21:24 -0000 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 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 > > > > >