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 8CF5D1FF0ED for ; Fri, 31 Jul 2026 16:40:00 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 5EBBD21572; Fri, 31 Jul 2026 16:40:00 +0200 (CEST) From: Christoph Heiss To: pdm-devel@lists.proxmox.com Subject: [PATCH installer 07/16] post-hook: re-use low-level config retrieval from proxmox-chroot Date: Fri, 31 Jul 2026 16:35:30 +0200 Message-ID: <20260731143910.936881-8-c.heiss@proxmox.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260731143910.936881-1-c.heiss@proxmox.com> References: <20260731143910.936881-1-c.heiss@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1785508786791 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.009 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_LOW -0.7 Sender listed at https://www.dnswl.org/, low 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: HULX45FE46W4GDOBWXYCIA6NDIJOH46Q X-Message-ID-Hash: HULX45FE46W4GDOBWXYCIA6NDIJOH46Q X-MailFrom: c.heiss@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 Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: We load the file in both tools, so simpfify it a bit for the proxmox-post-hook side. While at it, add some context to its errors, as they don't include the path by default, making debugging unnecessary hard. Signed-off-by: Christoph Heiss --- proxmox-chroot/src/main.rs | 14 ++------------ proxmox-installer-common/src/setup.rs | 12 ++++++++++++ proxmox-post-hook/src/main.rs | 3 +-- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/proxmox-chroot/src/main.rs b/proxmox-chroot/src/main.rs index c329f1a..387bdf4 100644 --- a/proxmox-chroot/src/main.rs +++ b/proxmox-chroot/src/main.rs @@ -13,10 +13,7 @@ use std::{ process::{self, Command}, }; -use proxmox_installer_common::{ - RUNTIME_DIR, cli, - setup::{InstallConfig, SetupInfo}, -}; +use proxmox_installer_common::{RUNTIME_DIR, cli, setup::SetupInfo}; use proxmox_installer_types::answer::Filesystem; const ANSWER_MP: &str = "answer"; @@ -170,7 +167,7 @@ fn cleanup(args: &CommandCleanupArgs) -> Result<()> { fn get_fs(filesystem: Option) -> Result { let fs = match filesystem { None => { - let low_level_config = match get_low_level_config() { + let low_level_config = match proxmox_installer_common::setup::get_low_level_config() { Ok(c) => c, Err(_) => bail!( "Could not fetch config from previous installation. Please specify file system with -f." @@ -184,13 +181,6 @@ fn get_fs(filesystem: Option) -> Result { Ok(fs) } -fn get_low_level_config() -> Result { - let file = fs::File::open("/tmp/low-level-config.json")?; - let reader = io::BufReader::new(file); - let config: InstallConfig = serde_json::from_reader(reader)?; - Ok(config) -} - fn get_iso_info() -> Result { let path = PathBuf::from(RUNTIME_DIR).join("iso-info.json"); let reader = io::BufReader::new(fs::File::open(path)?); diff --git a/proxmox-installer-common/src/setup.rs b/proxmox-installer-common/src/setup.rs index b8af4e3..a5733bf 100644 --- a/proxmox-installer-common/src/setup.rs +++ b/proxmox-installer-common/src/setup.rs @@ -1,3 +1,4 @@ +use anyhow::{Context, Result}; use serde::{Deserialize, Deserializer, Serialize, Serializer, de}; use std::{ cmp, @@ -469,6 +470,17 @@ pub struct InstallFirstBootSetup { pub ordering_target: Option, } +pub fn get_low_level_config() -> Result { + const PATH: &str = "/tmp/low-level-config.json"; + let file = File::open(PATH).with_context(|| format!("while opening {PATH}"))?; + + let reader = io::BufReader::new(file); + let config: InstallConfig = + serde_json::from_reader(reader).with_context(|| format!("while parsing {PATH}"))?; + + Ok(config) +} + pub fn spawn_low_level_installer(test_mode: bool) -> io::Result { let (path, args, envs): (&str, &[&str], Vec<(&str, &str)>) = if test_mode { ( diff --git a/proxmox-post-hook/src/main.rs b/proxmox-post-hook/src/main.rs index ec9ab74..d0fb297 100644 --- a/proxmox-post-hook/src/main.rs +++ b/proxmox-post-hook/src/main.rs @@ -60,8 +60,7 @@ mod detail { pub fn gather(target_path: &str, answer: &AutoInstallerConfig) -> Result { println!("Gathering installed system data ..."); - let config: InstallConfig = - serde_json::from_reader(BufReader::new(File::open("/tmp/low-level-config.json")?))?; + let config = proxmox_installer_common::setup::get_low_level_config()?; let (setup_info, _, run_env) = load_installer_setup_files(proxmox_installer_common::RUNTIME_DIR) -- 2.54.0