]> git.proxmox.com Git - pve-installer.git/commitdiff
tui: add some more field validation checks
authorChristoph Heiss <c.heiss@proxmox.com>
Tue, 13 Jun 2023 12:02:33 +0000 (14:02 +0200)
committerChristoph Heiss <c.heiss@proxmox.com>
Wed, 14 Jun 2023 08:39:56 +0000 (10:39 +0200)
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
proxmox-tui-installer/src/main.rs

index 460eb1fca8627cdc46e9acaee92681b073e0b516..e202211249af1fa5bb3555e19c79d449d9c44afa 100644 (file)
@@ -279,9 +279,12 @@ fn password_dialog(siv: &mut Cursive) -> InstallerView {
                     .get_value::<EditView, _>(2)
                     .ok_or("failed to retrieve email")?;
 
-                // TODO: proper validation
-                if root_password != confirm_password {
+                if root_password.len() < 5 {
+                    Err("password too short")
+                } else if root_password != confirm_password {
                     Err("passwords do not match")
+                } else if email.ends_with(".invalid") {
+                    Err("invalid email address")
                 } else {
                     Ok(PasswordOptions {
                         root_password,
@@ -363,6 +366,9 @@ fn network_dialog(siv: &mut Cursive) -> InstallerView {
                     Err("host and gateway IP address version must not differ".to_owned())
                 } else if address.addr().is_ipv4() != dns_server.is_ipv4() {
                     Err("host and DNS IP address version must not differ".to_owned())
+                } else if fqdn.chars().all(|c| c.is_ascii_digit()) {
+                    // Not supported/allowed on Debian
+                    Err("hostname cannot be purely numeric".to_owned())
                 } else {
                     Ok(NetworkOptions {
                         ifname,