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 4D23B1FF0DE for ; Thu, 19 Nov 2026 15:15:01 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 894542176D; Thu, 19 Nov 2026 15:14:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=genua.de; s=202307; t=1795097652; bh=1ZpvcY9LNChbyZUYLDaxkLXAtCd4/cPxkSlUavnoLcs=; h=Date:From:To:Subject:References:In-Reply-To:From; b=DxLaqvo4NrNm87qQ0X6MZksAtuAAfE/yXzeFtfjB+WgEnGG0UtFdBTx4hVSP3b7D5 bvs3gLR+DOk0Gde67QdrsLwdS1TlJtu+EKzcaVuhfl7PV0Hc/FT2PHmKB3GJgtVro+ h85325RB6DLjeH6OGTnngZZTX9iuiEqahHYOzg7pYn5GSNWgCP27AZVr9btVyMZXk7 hg760Gz8xri9qOfVzORdMB09428Lab98OnY7tJB9/3T48kb/gg4X+Mt1doPsJiFVQG Vv6NhuMbRCTJtMslzw2Mec+iaVz0xFUe2f4W4uk+4R4ASRT9XQZ/4eo/UsifyK3QoU sl+p30sgdy2SQ== Date: Thu, 19 Nov 2026 15:14:11 +0100 From: Christian Ludwig To: Subject: [PATCH pve-storage v4 04/20] plugin: allow overriding the efi-firmware directory Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [192.168.217.185] X-ClientProxiedBy: kch1-mta08.win.genua.de (10.208.16.108) To kch1-mta07.win.genua.de (10.208.16.107) Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline X-SPAM-LEVEL: Spam detection results: 0 AWL 0.059 Adjusted score from AWL reputation of From: address DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust SPF_HELO_PASS -0.001 SPF: HELO matches SPF record SPF_PASS -0.001 SPF: sender matches SPF record UNPARSEABLE_RELAY 0.001 Informational: message has unparseable relay lines Message-ID-Hash: WIOCCS5XONMAGONSU4WC7AOLVEXHQXAT X-Message-ID-Hash: WIOCCS5XONMAGONSU4WC7AOLVEXHQXAT X-MailFrom: christian_ludwig@genua.de 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: The content type of a directory override must consist of lowercase letters only, so 'efi-firmware' could not be overridden like the other types with a directory. Worse, as the override list is invalid as a whole then, setting it through the API fails and a storage.cfg that contains it loses all directory overrides of that storage. Accept content types with hyphens. That would also accept the volume types of guests, though their volumes all share the directory of their generic type, so the override would be ignored silently. Reject those. Signed-off-by: Christian Ludwig --- src/PVE/Storage/Plugin.pm | 8 ++++++-- src/test/content_types_test.pm | 28 +++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm index fd4a2cc..20dbdbc 100644 --- a/src/PVE/Storage/Plugin.pm +++ b/src/PVE/Storage/Plugin.pm @@ -487,9 +487,13 @@ PVE::JSONSchema::register_format('pve-dir-override', \&verify_dir_override); sub verify_dir_override { my ($value, $noerr) = @_; - if ($value =~ m/^([a-z]+)=([^.]*(?:\.?[^.]+)+)$/) { + if ($value =~ m/^([a-z]+(?:-[a-z]+)*)=([^.]*(?:\.?[^.]+)+)$/) { my ($content_type, $relative_path) = ($1, $2); - if (verify_content($content_type, $noerr)) { + # the volumes of all guest volume types share the directory of their generic type + if ( + verify_content($content_type, $noerr) + && !defined(PVE::Storage::Common::generic_vtype($content_type)) + ) { # linux has 4k max-path, but limit total length to lower as its concat'd for full path if ( length($relative_path) < 1023 diff --git a/src/test/content_types_test.pm b/src/test/content_types_test.pm index 8aa13eb..2a7eec5 100644 --- a/src/test/content_types_test.pm +++ b/src/test/content_types_test.pm @@ -115,8 +115,8 @@ lvm: redundant dir: overrides path /srv/overrides - content iso,backup - content-dirs iso=images/iso,backup=dumps + content iso,backup,efi-firmware + content-dirs iso=images/iso,backup=dumps,efi-firmware=firmware CFG my $cfg = PVE::Storage::Plugin->parse_config('storage.cfg', $raw); @@ -256,7 +256,11 @@ for my $test ($api_tests->@*) { } my $content_dirs = PVE::API2::Storage::Config->read({ storage => 'overrides' })->{'content-dirs'}; -is($content_dirs, 'backup=dumps,iso=images/iso', 'overrides: content directories as read'); +is( + $content_dirs, + 'backup=dumps,efi-firmware=firmware,iso=images/iso', + 'overrides: content directories as read', +); eval { PVE::API2::Storage::Config->update({ storage => 'overrides', @@ -265,6 +269,24 @@ eval { }; is($@, '', 'overrides: content directories can be set as read'); +# each test is comprised of the following array keys: +# [0] => directory override +# [1] => whether it is valid +my $dir_override_tests = [ + ['efi-firmware=firmware', 1], + ['images=guests', 1], + # the volumes of all guest volume types share the directory of their generic type + ['vm-vol=disks', 0], + ['ct-vol=volumes', 0], +]; + +for my $test ($dir_override_tests->@*) { + my ($override, $expected) = $test->@*; + + my $valid = defined(PVE::Storage::Plugin::verify_dir_override($override, 1)) ? 1 : 0; + is($valid, $expected, "directory override $override"); +} + done_testing(); 1; -- 2.34.1