From 8341108e180c0a7002893bf577dcae57791ecb4d Mon Sep 17 00:00:00 2001 From: Christoph Heiss Date: Mon, 9 Dec 2024 13:45:58 +0100 Subject: [PATCH] fix #5889: assistant: validate answer email & root password settings These checks are basically "free" and can be re-used from the auto-installer 1:1. Signed-off-by: Christoph Heiss --- proxmox-auto-install-assistant/src/main.rs | 9 +++++---- proxmox-auto-installer/src/utils.rs | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/proxmox-auto-install-assistant/src/main.rs b/proxmox-auto-install-assistant/src/main.rs index c837cba..6796c06 100644 --- a/proxmox-auto-install-assistant/src/main.rs +++ b/proxmox-auto-install-assistant/src/main.rs @@ -11,11 +11,11 @@ use std::{ }; use proxmox_auto_installer::{ - answer::Answer, - answer::FilterMatch, + answer::{Answer, FilterMatch}, sysinfo::SysInfo, utils::{ - get_matched_udev_indexes, get_nic_list, get_single_udev_index, AutoInstSettings, + get_matched_udev_indexes, get_nic_list, get_single_udev_index, + verify_email_and_root_password_settings, AutoInstSettings, FetchAnswerFrom, HttpOptions, }, }; @@ -591,7 +591,8 @@ fn parse_answer(path: impl AsRef + fmt::Debug) -> Result { } match toml::from_str(&contents) { Ok(answer) => { - println!("The file was parsed successfully, no syntax errors found!"); + verify_email_and_root_password_settings(&answer)?; + println!("The answer file was parsed successfully, no errors found!"); Ok(answer) } Err(err) => bail!("Error parsing answer file: {err}"), diff --git a/proxmox-auto-installer/src/utils.rs b/proxmox-auto-installer/src/utils.rs index 27bbc3b..c26b33c 100644 --- a/proxmox-auto-installer/src/utils.rs +++ b/proxmox-auto-installer/src/utils.rs @@ -320,7 +320,7 @@ fn verify_locale_settings(answer: &Answer, locales: &LocaleInfo) -> Result<()> { Ok(()) } -fn verify_email_and_root_password_settings(answer: &Answer) -> Result<()> { +pub fn verify_email_and_root_password_settings(answer: &Answer) -> Result<()> { info!("Verifying email and root password settings"); email_validate(&answer.global.mailto).with_context(|| answer.global.mailto.clone())?;