From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 0FE0A1FF0DE for ; Thu, 19 Nov 2026 15:15:09 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 166C721685; Thu, 19 Nov 2026 15:14:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=genua.de; s=202307; t=1795097655; bh=nU8lOG1aVybGqPCa5fXVUiMbzVyAUNLZGz/HSCfxKwc=; h=Date:From:To:Subject:References:In-Reply-To:From; b=W7OiZtPBgpK2dISQRf3yjuxb+XCaXq3xQkbuAKPZRxBPGHV77WHcgxNdQEOQjuG/G JB6aVFQ1Xyx/37UqDhg+XeS3okm0F99z/9t6k24hZX41cVZI3minULJkO5PclxEBbJ XGzWt1X5ZUrCz2sFq0YsTKiAI6xhoG2TpA6xnLSyE5XaVHVXIiwZ/h/n4Z6wn/5h1m rjghwMALn4p78O9Dy2Gxoivzpu4T3624b+c0j4FK2vBVQeFKXSti1VANpt8Fl5oncf 3kQkkJOD/Gny3kH9wOLt1wHpxXxDY2LVHQJ0KzF6RBXlGRgFVQH7wRFUM4wI1JwNkQ F69ykc4gL/bkg== Date: Thu, 19 Nov 2026 15:14:14 +0100 From: Christian Ludwig To: Subject: [PATCH pve-storage v4 06/20] api: status: support efi-firmware in upload and download-url Message-ID: <558bfdffe1424c14c45e5a6fad96f7b7391ace03.1795092172.git.christian_ludwig@genua.de> References: MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [192.168.217.185] X-ClientProxiedBy: kch1-mta07.win.genua.de (10.208.16.107) 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.058 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: NPK2G5YKB47X4DT727RSLWPB4LCGZLQM X-Message-ID-Hash: NPK2G5YKB47X4DT727RSLWPB4LCGZLQM 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: Allow the content type in both endpoints. File names must consist of the safe character class and end with '.fd'. Validate the image after the transfer, like for other content types, and reject anything that is not detected as a raw image. The format check has no timeout, like the ISO content check, whose qemu-img call (auto-detected format, untrusted) it mirrors. A timeout would only limit qemu-img info on the already transferred temporary file, not the upload or download itself. Reviewed-by: Fiona Ebner Signed-off-by: Christian Ludwig --- src/PVE/API2/Storage/Status.pm | 22 ++++++++++++++++++++-- src/PVE/Storage.pm | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/PVE/API2/Storage/Status.pm b/src/PVE/API2/Storage/Status.pm index 57ab92b..0039d81 100644 --- a/src/PVE/API2/Storage/Status.pm +++ b/src/PVE/API2/Storage/Status.pm @@ -534,7 +534,7 @@ __PACKAGE__->register_method({ description => "Content type.", type => 'string', format => 'pve-storage-content', - enum => ['iso', 'vztmpl', 'import'], + enum => ['iso', 'vztmpl', 'import', 'efi-firmware'], }, filename => { description => @@ -619,6 +619,13 @@ __PACKAGE__->register_method({ } $path = PVE::Storage::get_import_dir($cfg, $storage); + } elsif ($content eq 'efi-firmware') { + if ($filename !~ + m!^${PVE::Storage::SAFE_CHAR_CLASS_RE}+$PVE::Storage::EFI_FIRMWARE_EXT_RE_1$! + ) { + raise_param_exc({ filename => "invalid filename or wrong extension" }); + } + $path = PVE::Storage::get_efi_firmware_dir($cfg, $storage); } else { raise_param_exc({ content => "upload content type '$content' not allowed" }); } @@ -690,6 +697,8 @@ __PACKAGE__->register_method({ if ($content eq 'iso') { PVE::Storage::assert_iso_content($tmpfilename); + } elsif ($content eq 'efi-firmware') { + PVE::Storage::assert_efi_firmware_content($tmpfilename); } if ($is_ova) { @@ -767,7 +776,7 @@ __PACKAGE__->register_method({ description => "Content type.", # TODO: could be optional & detected in most cases type => 'string', format => 'pve-storage-content', - enum => ['iso', 'vztmpl', 'import'], + enum => ['iso', 'vztmpl', 'import', 'efi-firmware'], }, filename => { description => @@ -856,6 +865,13 @@ __PACKAGE__->register_method({ } $path = PVE::Storage::get_import_dir($cfg, $storage); + } elsif ($content eq 'efi-firmware') { + if ($filename !~ + m!^${PVE::Storage::SAFE_CHAR_CLASS_RE}+$PVE::Storage::EFI_FIRMWARE_EXT_RE_1$! + ) { + raise_param_exc({ filename => "invalid filename or wrong extension" }); + } + $path = PVE::Storage::get_efi_firmware_dir($cfg, $storage); } else { raise_param_exc({ content => "upload content-type '$content' is not allowed" }); } @@ -882,6 +898,8 @@ __PACKAGE__->register_method({ if ($content eq 'iso') { PVE::Storage::assert_iso_content($tmp_path); + } elsif ($content eq 'efi-firmware') { + PVE::Storage::assert_efi_firmware_content($tmp_path); } if ($is_ova) { diff --git a/src/PVE/Storage.pm b/src/PVE/Storage.pm index 8c79c13..d02141d 100755 --- a/src/PVE/Storage.pm +++ b/src/PVE/Storage.pm @@ -622,6 +622,15 @@ sub get_iso_dir { return $plugin->get_subdir($scfg, 'iso'); } +sub get_efi_firmware_dir { + my ($cfg, $storeid) = @_; + + my $scfg = storage_config($cfg, $storeid); + my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); + + return $plugin->get_subdir($scfg, 'efi-firmware'); +} + sub get_import_dir { my ($cfg, $storeid) = @_; @@ -2642,4 +2651,14 @@ sub assert_iso_content { return 1; } +sub assert_efi_firmware_content { + my ($path) = @_; + + my (undef, $format) = file_size_info($path, undef, 'auto-detect', 1); + die "efi-firmware image format could not be detected\n" if !defined($format); + die "efi-firmware image is not in raw format, detected '$format'\n" if $format ne 'raw'; + + return 1; +} + 1; -- 2.34.1