From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id A4A521FF168 for ; Sun, 24 Aug 2025 00:54:33 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2443B2A17F; Sun, 24 Aug 2025 00:54:34 +0200 (CEST) To: pve-devel@lists.proxmox.com Date: Sun, 24 Aug 2025 00:15:39 +0200 In-Reply-To: <20250823221540.40342-1-09couplet.bitmap@icloud.com> References: <20250823221540.40342-1-09couplet.bitmap@icloud.com> MIME-Version: 1.0 Message-ID: List-Id: Proxmox VE development discussion List-Post: From: Guillaume via pve-devel Precedence: list Cc: Guillaume <09couplet.bitmap@icloud.com> X-Mailman-Version: 2.1.29 X-BeenThere: pve-devel@lists.proxmox.com List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Proxmox VE development discussion List-Help: Subject: [pve-devel] SPAM: [PATCH container 2/3] setup: add support of el10 and implementing NetworkManager instead fo network-scripts Content-Type: multipart/mixed; boundary="===============6760758798276469726==" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" --===============6760758798276469726== Content-Type: message/rfc822 Content-Disposition: inline Return-Path: <09couplet.bitmap@icloud.com> X-Original-To: pve-devel@lists.proxmox.com Delivered-To: pve-devel@lists.proxmox.com 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 0B6BCD4A35 for ; Sun, 24 Aug 2025 00:54:32 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D47042A235 for ; Sun, 24 Aug 2025 00:54:31 +0200 (CEST) Received: from 6.mo583.mail-out.ovh.net (6.mo583.mail-out.ovh.net [178.32.119.138]) (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 ; Sun, 24 Aug 2025 00:54:30 +0200 (CEST) Received: from director3.ghost.mail-out.ovh.net (unknown [10.110.54.21]) by mo583.mail-out.ovh.net (Postfix) with ESMTP id 4c8WbY3C3jz5x2C for ; Sat, 23 Aug 2025 22:15:53 +0000 (UTC) Received: from ghost-submission-5b5ff79f4f-shwm6 (unknown [10.108.54.44]) by director3.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 31427C04F2; Sat, 23 Aug 2025 22:15:53 +0000 (UTC) Received: from cours.cloud ([37.59.142.97]) by ghost-submission-5b5ff79f4f-shwm6 with ESMTPSA id YbMuNZc9qmg5CwAAMvZsGQ:T3 (envelope-from <09couplet.bitmap@icloud.com>); Sat, 23 Aug 2025 22:15:53 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-97G002f4431374-5c6a-4fe5-bdd9-e44095f8c593, BDBCFE6616532A0174FA04B38760FEAAF5AEB485) smtp.auth=guillaume@cours.cloud X-OVh-ClientIp: 90.50.10.13 From: Guillaume <09couplet.bitmap@icloud.com> To: pve-devel@lists.proxmox.com Cc: Guillaume <09couplet.bitmap@icloud.com> subject: SPAM: [PATCH container 2/3] setup: add support of el10 and implementing NetworkManager instead fo network-scripts Date: Sun, 24 Aug 2025 00:15:39 +0200 Message-ID: <20250823221540.40342-3-09couplet.bitmap@icloud.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250823221540.40342-1-09couplet.bitmap@icloud.com> References: <20250823221540.40342-1-09couplet.bitmap@icloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 4438578911955286136 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdduieejkeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefiuhhilhhlrghumhgvuceotdeltghouhhplhgvthdrsghithhmrghpsehitghlohhuugdrtghomheqnecuggftrfgrthhtvghrnhepuefftdduudetteefleeujeetleekgfetieduhfegudehhfehueeikedugfegveeknecukfhppeduvdejrddtrddtrddupdeltddrhedtrddutddrudefpdefjedrheelrddugedvrdeljeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomheptdeltghouhhplhgvthdrsghithhmrghpsehitghlohhuugdrtghomhdpnhgspghrtghpthhtohepuddprhgtphhtthhopehpvhgvqdguvghvvghlsehlihhsthhsrdhprhhogihmohigrdgtohhmpdfovfetjfhoshhtpehmohehkeefmgdpmhhouggvpehsmhhtphhouhht X-SPAM-LEVEL: Spam detection results: 3 AWL 0.174 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_QUAR 0.1 DMARC quarantine policy FREEMAIL_FROM 0.001 Sender email is commonly abused enduser mail provider KAM_DMARC_QUARANTINE 4 DKIM has Failed or SPF has failed on the message and the domain has a DMARC quarantine policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust RCVD_IN_MSPIKE_H3 0.001 Good reputation (+3) RCVD_IN_MSPIKE_WL 0.001 Mailspike good senders RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_SOFTFAIL 0.665 SPF: sender does not match SPF record (softfail) URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [centos.pm] Red Hat remove support for network configuration files in the ifcfg format until version 10. Signed-off-by: Guillaume <09couplet.bitmap@icloud.com> --- src/PVE/LXC/Setup/CentOS.pm | 108 +++++++++++++++++++++++++++++++++--- 1 file changed, 101 insertions(+), 7 deletions(-) diff --git a/src/PVE/LXC/Setup/CentOS.pm b/src/PVE/LXC/Setup/CentOS.pm index 446b49b..06b4dac 100644 --- a/src/PVE/LXC/Setup/CentOS.pm +++ b/src/PVE/LXC/Setup/CentOS.pm @@ -4,6 +4,7 @@ use strict; use warnings; use UUID; +use Net::IP; use PVE::Tools; use PVE::Network; @@ -19,16 +20,13 @@ sub new { my $release = PVE::Tools::file_read_firstline("$rootdir/etc/redhat-release"); die "unable to read version info\n" if !defined($release); - my $version; + my $version = get_centos_version($release); - if (($release =~ m/release\s+(\d+\.\d+)(\.\d+)?/) || ($release =~ m/release\s+(\d+)/)) { - if ($1 >= 5 && $1 < 10) { - $version = $1; - } + # check compatibility + if (!($version >= 5 && $version < 11)) { + die "unsupported centos version '$version'\n"; } - die "unsupported centos release '$release'\n" if !$version; - my $self = { conf => $conf, rootdir => $rootdir, version => $version }; $conf->{ostype} = "centos"; @@ -36,6 +34,16 @@ sub new { return bless $self, $class; } +sub get_centos_version { + my ($release) = @_; + + if (($release =~ m/release\s+(\d+\.\d+)(\.\d+)?/) || ($release =~ m/release\s+(\d+)/)) { + return $1; + } + + die "unable to parse centos version '$release'\n"; +} + my $tty_conf = <<__EOD__; # tty - getty # @@ -182,6 +190,92 @@ sub set_hostname { sub setup_network { my ($self, $conf) = @_; + my $release = $self->ct_file_get_contents('/etc/redhat-release'); + my $version = get_centos_version($release); + + if ($version >= 10) { + # Use NetworkManager files + setup_netork_with_networkmanager($self, $conf) + } else { + # Use network-scripts files + setup_netork_with_network_scripts($self, $conf) + } +} + +sub setup_netork_with_networkmanager { + my ($self, $conf) = @_; + + $self->ct_make_path('/etc/NetworkManager/system-connections'); + + foreach my $k (keys %$conf) { + next if $k !~ m/^net(\d+)$/; + my $d = PVE::LXC::Config->parse_lxc_network($conf->{$k}); + next if !$d->{name}; + + my $filename = "/etc/NetworkManager/system-connections/$d->{name}.nmconnection"; + + my ($searchdomains, $nameserver) = $self->lookup_dns_conf($conf); + my @nameservers = PVE::Tools::split_list($nameserver); + my @nameserversv4 = grep { + my $ip = Net::IP->new($_); + $ip && $ip->version == 4; + } @nameservers; + my @nameserversv6 = grep { + my $ip = Net::IP->new($_); + $ip && $ip->version == 6; + } @nameservers; + + + my $header = "[connection]\nid=$d->{name}\nuuid=" . UUID::uuid() . "\ntype=ethernet\ninterface-name=$d->{name}\n"; + my $data = ''; + + if ($d->{ip} && $d->{ip} ne 'manual') { + $data .= "[ipv4]\n"; + if ($d->{ip} eq 'dhcp') { + $data .= "method=auto\n"; + } else { + $data .= "method=manual\n"; + $data .= "addresses=$d->{ip}\n"; + if (defined($d->{gw})) { + $data .= "gateway=$d->{gw}\n"; + if (!PVE::Network::is_ip_in_cidr($d->{gw}, $d->{ip}, 4)) { + $data .= "routes=$d->{gw}\n"; + } + } + } + $data .= "dns=" . join(',', @nameserversv4) . "\n" if @nameserversv4; + $data .= "dns-search=" . join(' ', PVE::Tools::split_list($searchdomains)) . "\n" if @nameserversv4 && $searchdomains; + } + + if ($d->{ip6} && $d->{ip6} ne 'manual') { + $data .= "[ipv6]\n"; + if ($d->{ip6} eq 'auto' || $d->{ip6} eq 'dhcp') { + $data .= "method=auto\n"; + } else { + $data .= "method=manual\naddress=$d->{ip6}\n"; + if (defined($d->{gw6})) { + if ( + !PVE::Network::is_ip_in_cidr($d->{gw6}, $d->{ip6}, 6) + && !PVE::Network::is_ip_in_cidr($d->{gw6}, 'fe80::/10', 6) + ) { + $data .= "routes=$d->{gw6}\n"; + } else { + $data .= "gateway=$d->{gw6}\n"; + } + } + } + $data .= "dns=" . join(',', @nameserversv6) . "\n" if @nameserversv6; + $data .= "dns-search=" . join(' ', PVE::Tools::split_list($searchdomains)) . "\n" if @nameserversv6 && $searchdomains; + } + + next unless $data; + $self->ct_file_set_contents($filename, $header . $data, 0600); + } +} + +sub setup_netork_with_network_scripts { + my ($self, $conf) = @_; + my ($gw, $gw6); $self->ct_make_path('/etc/sysconfig/network-scripts'); -- 2.47.2 --===============6760758798276469726== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel --===============6760758798276469726==--