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 3713D1FF0A7 for ; Wed, 16 Sep 2026 16:49:45 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id AC6C921617; Wed, 16 Sep 2026 16:49:04 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com, pve-devel@lists.proxmox.com Subject: [PATCH proxmox-backup-qemu v2 4/8] commands: extend stricter type checks for guest config archive names Date: Wed, 16 Sep 2026 16:48:39 +0200 Message-ID: <20260916144843.567913-5-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260916144843.567913-1-c.ebner@proxmox.com> References: <20260916144843.567913-1-c.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1789570137659 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.499 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) POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_2 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_4 0.1 random spam to be learned in bayes 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: F6LVWHVAAVBJAYVW6DIQ72AMQ267HGXP X-Message-ID-Hash: F6LVWHVAAVBJAYVW6DIQ72AMQ267HGXP X-MailFrom: c.ebner@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 Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Further extends the stricter BackupArchiveName type as introduced in [0] to also apply to internal add_config() helper for guest config. Due to the stricter checks, add_config() now allows the server side extensions as defined in the type for blobs and auto-expands the server side `.blob` extension when required, the archive type is explicitley checked instead. While at it, make sure to always use the latest stricter check by depending on version 1.0.20, which is not strictly required here but the submodule already depends on it as well and it protects against building future versions with the still more relaxed archive name parsing. The api type changes affect internal API's only, public API's types remain unchanged. [0] https://git.proxmox.com/?p=proxmox-backup.git;a=commit;h=b57274a5a64791e7245bc0655ce0f133668db145 Signed-off-by: Christian Ebner --- Cargo.toml | 2 +- src/backup.rs | 3 ++- src/commands.rs | 18 ++++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c50a0a2..d73324f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ proxmox-schema = { version = "5", features = [ "api-macro" ] } proxmox-sortable-macro = "1" proxmox-sys = "1" -pbs-api-types = { version = "1" } +pbs-api-types = { version = "1.0.20" } pbs-client = { path = "submodules/proxmox-backup/pbs-client" } pbs-datastore = { path = "submodules/proxmox-backup/pbs-datastore" } diff --git a/src/backup.rs b/src/backup.rs index 61ebcfb..3a591ea 100644 --- a/src/backup.rs +++ b/src/backup.rs @@ -10,7 +10,7 @@ use tokio::runtime::Runtime; use proxmox_async::runtime::get_runtime_with_builder; use proxmox_sys::fs::file_get_contents; -use pbs_api_types::{BackupType, CryptMode}; +use pbs_api_types::{BackupArchiveName, BackupType, CryptMode}; use pbs_client::{BackupWriter, BackupWriterOptions, HttpClient, HttpClientOptions}; use pbs_datastore::BackupManifest; use pbs_key_config::{load_and_decrypt_key, rsa_encrypt_key_config, KeyConfig}; @@ -186,6 +186,7 @@ impl BackupTask { pub async fn add_config(&self, name: String, data: Vec) -> Result { self.check_aborted()?; + let name: BackupArchiveName = name.parse()?; let command_future = add_config( self.need_writer()?, diff --git a/src/commands.rs b/src/commands.rs index d482fd5..1b009d5 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -6,7 +6,9 @@ use std::sync::{Arc, Mutex}; use futures::future::{Future, TryFutureExt}; use serde_json::json; -use pbs_api_types::{BackupArchiveName, CryptMode, ENCRYPTED_KEY_BLOB_NAME, MANIFEST_BLOB_NAME}; +use pbs_api_types::{ + ArchiveType, BackupArchiveName, CryptMode, ENCRYPTED_KEY_BLOB_NAME, MANIFEST_BLOB_NAME, +}; use pbs_client::{BackupWriter, H2Client, UploadOptions}; use pbs_datastore::data_blob::DataChunkBuilder; use pbs_datastore::index::IndexFile; @@ -94,14 +96,19 @@ async fn register_zero_chunk( pub(crate) async fn add_config( client: Arc, manifest: Arc>, - name: String, + config_blob_name: BackupArchiveName, data: Vec, compress: bool, crypt_mode: CryptMode, ) -> Result { //println!("add config {} size {}", name, size); - let blob_name = format!("{}.blob", name); + if config_blob_name.archive_type() != ArchiveType::Blob { + bail!( + "cannot add '{}' as config blob.", + config_blob_name.to_string() + ); + } let options = UploadOptions { compress, @@ -109,13 +116,12 @@ pub(crate) async fn add_config( ..UploadOptions::default() }; - let blob_name: BackupArchiveName = blob_name.parse()?; let stats = client - .upload_blob_from_data(data, &blob_name, options) + .upload_blob_from_data(data, &config_blob_name, options) .await?; let mut guard = manifest.lock().unwrap(); - guard.add_file(&blob_name, stats.size, stats.csum, crypt_mode)?; + guard.add_file(&config_blob_name, stats.size, stats.csum, crypt_mode)?; Ok(0) } -- 2.47.3