From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id E24DE1FF0DF for ; Fri, 28 Aug 2026 15:30:53 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 0A13B215C3; Fri, 28 Aug 2026 15:30:40 +0200 (CEST) From: Shannon Sterz To: pve-devel@lists.proxmox.com Subject: [PATCH container 06/21] setup: use parse_os_release from PVE::Systemd Date: Fri, 28 Aug 2026 15:30:15 +0200 Message-ID: <20260828133030.351140-7-s.sterz@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260828133030.351140-1-s.sterz@proxmox.com> References: <20260828133030.351140-1-s.sterz@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1787923824392 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.926 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: DVSVR7XM3YF7V4PZJGVUVIGR5ZE2IBUX X-Message-ID-Hash: DVSVR7XM3YF7V4PZJGVUVIGR5ZE2IBUX X-MailFrom: s.sterz@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: this was moved to PVE::Systemd to make the parse more re-usable and avoid multiple implementations. Signed-off-by: Shannon Sterz --- src/PVE/LXC/Setup.pm | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/src/PVE/LXC/Setup.pm b/src/PVE/LXC/Setup.pm index d936af2..c8c036d 100644 --- a/src/PVE/LXC/Setup.pm +++ b/src/PVE/LXC/Setup.pm @@ -7,6 +7,7 @@ use POSIX; use Cwd 'abs_path'; use PVE::RESTEnvironment; +use PVE::Systemd; use PVE::Tools; use PVE::LXC::Setup::Alpine; @@ -335,38 +336,6 @@ sub unified_cgroupv2_support { return $self->{plugin}->unified_cgroupv2_support($self->get_ct_init_path()); } -# os-release(5): -# (...) a newline-separated list of environment-like shell-compatible -# variable assignments. (...) beyond mere variable assignments, no shell -# features are supported (this means variable expansion is explicitly not -# supported) (...). Variable assignment values must be enclosed in double or -# single quotes *if* they include spaces, semicolons or other special -# characters outside of A-Z, a-z, 0-9. Shell special characters ("$", quotes, -# backslash, backtick) must be escaped with backslashes (...). All strings -# should be in UTF-8 format, and non-printable characters should not be used. -# It is not supported to concatenate multiple individually quoted strings. -# Lines beginning with "#" shall be ignored as comments. -my $parse_os_release = sub { - my ($data) = @_; - my $variables = {}; - while (defined($data) && $data =~ /^(.+)$/gm) { - next if $1 !~ /^\s*([a-zA-Z_][a-zA-Z0-9_]*)=(.*)$/; - my ($var, $content) = ($1, $2); - chomp $content; - - if ($content =~ /^'([^']*)'/) { - $variables->{$var} = $1; - } elsif ($content =~ /^"((?:[^"\\]|\\.)*)"/) { - my $s = $1; - $s =~ s/(\\["'`nt\$\\])/"\"$1\""/eeg; - $variables->{$var} = $s; - } elsif ($content =~ /^([A-Za-z0-9]*)/) { - $variables->{$var} = $1; - } - } - return $variables; -}; - sub get_ct_os_release { my ($self) = @_; @@ -379,7 +348,7 @@ sub get_ct_os_release { return undef; }); - return &$parse_os_release($data); + return PVE::Systemd::parse_os_release($data); } # Checks whether /sbin/init is a symlink, and if it is, resolves it to the actual binary -- 2.47.3