From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer v2 6/7] auto-installer: validate `global.mailto` answer option
Date: Wed, 2 Oct 2024 14:27:27 +0200 [thread overview]
Message-ID: <20241002122933.628461-7-c.heiss@proxmox.com> (raw)
In-Reply-To: <20241002122933.628461-1-c.heiss@proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
Changes v1 -> v2:
* instead of re-using/-naming the `verify_locale_settings()` for the
email validation, combine it the with root password validation
proxmox-auto-installer/src/utils.rs | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/proxmox-auto-installer/src/utils.rs b/proxmox-auto-installer/src/utils.rs
index cc483c9..afaad85 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, InstallRootPassword, InstallZfsOption, LocaleInfo, RuntimeInfo, SetupInfo,
},
@@ -303,7 +303,11 @@ fn verify_locale_settings(answer: &Answer, locales: &LocaleInfo) -> Result<()> {
Ok(())
}
-fn verify_root_password_settings(answer: &Answer) -> Result<()> {
+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())?;
+
if answer.global.root_password.is_some() && answer.global.root_password_hashed.is_some() {
bail!("`global.root_password` and `global.root_password_hashed` cannot be set at the same time");
} else if answer.global.root_password.is_none() && answer.global.root_password_hashed.is_none()
@@ -329,7 +333,7 @@ pub fn parse_answer(
let network_settings = get_network_settings(answer, udev_info, runtime_info, setup_info)?;
verify_locale_settings(answer, locales)?;
- verify_root_password_settings(answer)?;
+ verify_email_and_root_password_settings(answer)?;
let mut config = InstallConfig {
autoreboot: 1_usize,
--
2.46.0
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2024-10-02 12:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-02 12:27 [pve-devel] [PATCH installer v2 0/7] use email regex from HTML spec for validation Christoph Heiss
2024-10-02 12:27 ` [pve-devel] [PATCH installer v2 1/7] cargo: convert `anyhow` to workspace dependency Christoph Heiss
2024-10-02 12:27 ` [pve-devel] [PATCH installer v2 2/7] tui: fix new clippy lint Christoph Heiss
2024-10-02 12:27 ` [pve-devel] [PATCH installer v2 3/7] auto-installer: drop some unneeded `pub` modifiers Christoph Heiss
2024-10-02 12:27 ` [pve-devel] [PATCH installer v2 4/7] auto-installer: print full anyhow message on failure Christoph Heiss
2024-10-02 12:27 ` [pve-devel] [PATCH installer v2 5/7] tui: use email regex from HTML specification for validation Christoph Heiss
2024-10-02 12:27 ` Christoph Heiss [this message]
2024-10-02 12:27 ` [pve-devel] [PATCH installer v2 7/7] proxinstall: " Christoph Heiss
2024-11-10 18:18 ` [pve-devel] applied-series: [PATCH installer v2 0/7] use email regex from HTML spec " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241002122933.628461-7-c.heiss@proxmox.com \
--to=c.heiss@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.