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 <c.heiss@proxmox.com>
This commit is contained in:
Christoph Heiss 2024-12-09 13:45:58 +01:00 committed by Thomas Lamprecht
parent 3da534fd65
commit 8341108e18
2 changed files with 6 additions and 5 deletions

View File

@ -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}"),

View File

@ -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())?;