[pve-devel] [PATCH installer 6/7] auto-installer: validate `global.mailto` answer option

Christoph Heiss c.heiss at proxmox.com
Tue May 28 10:13:47 CEST 2024


Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
 proxmox-auto-installer/src/utils.rs | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/proxmox-auto-installer/src/utils.rs b/proxmox-auto-installer/src/utils.rs
index f752924..7241eec 100644
--- a/proxmox-auto-installer/src/utils.rs
+++ b/proxmox-auto-installer/src/utils.rs
@@ -1,4 +1,4 @@
-use anyhow::{bail, Context as _, Result};
+use anyhow::{bail, Context, Result};
 use clap::ValueEnum;
 use glob::Pattern;
 use log::info;
@@ -9,7 +9,7 @@ use crate::{
     udevinfo::UdevInfo,
 };
 use proxmox_installer_common::{
-    options::{FsType, NetworkOptions, ZfsChecksumOption, ZfsCompressOption},
+    options::{email_validate, FsType, NetworkOptions, ZfsChecksumOption, ZfsCompressOption},
     setup::{InstallConfig, InstallZfsOption, LocaleInfo, RuntimeInfo, SetupInfo},
 };
 use serde::{Deserialize, Serialize};
@@ -272,7 +272,10 @@ fn get_first_selected_disk(config: &InstallConfig) -> usize {
         .expect("could not parse key to usize")
 }
 
-fn verify_locale_settings(answer: &Answer, locales: &LocaleInfo) -> Result<()> {
+fn verify_global_settings(answer: &Answer, locales: &LocaleInfo) -> Result<()> {
+    info!("Verifying global settings");
+    email_validate(&answer.global.mailto).with_context(|| answer.global.mailto.clone())?;
+
     info!("Verifying locale settings");
     if !locales
         .countries
@@ -315,7 +318,7 @@ pub fn parse_answer(
 
     let network_settings = get_network_settings(answer, udev_info, runtime_info, setup_info)?;
 
-    verify_locale_settings(answer, locales)?;
+    verify_global_settings(answer, locales)?;
 
     let mut config = InstallConfig {
         autoreboot: 1_usize,
-- 
2.44.0





More information about the pve-devel mailing list