[pve-devel] [PATCH installer 5/6] fix #5889: assistant: validate answer email & root password settings
Christoph Heiss
c.heiss at proxmox.com
Mon Dec 9 13:45:58 CET 2024
These checks are basically "free" and can be re-used from the
auto-installer 1:1.
Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
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<Path> + fmt::Debug) -> Result<Answer> {
}
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())?;
--
2.47.0
More information about the pve-devel
mailing list