From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer 1/5] net: move hostname/fqdn regexes into common code
Date: Fri, 20 Oct 2023 11:46:44 +0200 [thread overview]
Message-ID: <20231020094651.432513-2-c.heiss@proxmox.com> (raw)
In-Reply-To: <20231020094651.432513-1-c.heiss@proxmox.com>
Such that they can be re-used by other parts.
No functional changes.
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
Proxmox/Sys/Net.pm | 3 +++
proxinstall | 9 +++++----
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/Proxmox/Sys/Net.pm b/Proxmox/Sys/Net.pm
index ba368c1..f5a9885 100644
--- a/Proxmox/Sys/Net.pm
+++ b/Proxmox/Sys/Net.pm
@@ -6,6 +6,9 @@ use warnings;
use base qw(Exporter);
our @EXPORT_OK = qw(parse_ip_address parse_ip_mask);
+our $HOSTNAME_RE = "(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?)";
+our $FQDN_RE = "(?:${HOSTNAME_RE}\.)*${HOSTNAME_RE}";
+
my $IPV4OCTET = "(?:25[0-5]|(?:2[0-4]|1[0-9]|[1-9])?[0-9])";
my $IPV4RE = "(?:(?:$IPV4OCTET\\.){3}$IPV4OCTET)";
my $IPV6H16 = "(?:[0-9a-fA-F]{1,4})";
diff --git a/proxinstall b/proxinstall
index d5b2565..88f194f 100755
--- a/proxinstall
+++ b/proxinstall
@@ -429,8 +429,6 @@ sub create_ipconf_view {
$text =~ s/^\s+//;
$text =~ s/\s+$//;
- my $namere = "([a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?)";
-
# Debian does not support purely numeric hostnames
if ($text && $text =~ /^[0-9]+(?:\.|$)/) {
Proxmox::UI::message("Purely numeric hostnames are not allowed.");
@@ -438,8 +436,11 @@ sub create_ipconf_view {
return;
}
- if ($text && $text =~ m/^(${namere}\.)*${namere}$/ && $text !~ m/.example.invalid$/ &&
- $text =~ m/^([^\.]+)\.(\S+)$/) {
+ if ($text
+ && $text =~ m/^${Proxmox::Sys::Net::FQDN_RE}$/
+ && $text !~ m/.example.invalid$/
+ && $text =~ m/^([^\.]+)\.(\S+)$/
+ ) {
Proxmox::Install::Config::set_hostname($1);
Proxmox::Install::Config::set_domain($2);
} else {
--
2.42.0
next prev parent reply other threads:[~2023-10-20 9:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-20 9:46 [pve-devel] [PATCH installer 0/5] use hostname from DHCP lease if available Christoph Heiss
2023-10-20 9:46 ` Christoph Heiss [this message]
2023-10-20 9:46 ` [pve-devel] [PATCH installer 2/5] run env: retrieve and store " Christoph Heiss
2023-10-20 9:46 ` [pve-devel] [PATCH installer 3/5] proxinstall: use hostname from run env " Christoph Heiss
2023-10-20 9:46 ` [pve-devel] [PATCH installer 4/5] tui: " Christoph Heiss
2023-10-20 9:46 ` [pve-devel] [PATCH installer 5/5] tui: add some tests for `NetworkInfo` -> `NetworkOptions` conversion Christoph Heiss
2023-10-20 15:21 ` [pve-devel] applied-series: [PATCH installer 0/5] use hostname from DHCP lease if available Thomas Lamprecht
2023-10-24 7:45 ` Christoph Heiss
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=20231020094651.432513-2-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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal