[pve-devel] [PATCH cluster 3/3] pvecm add: re-allow using hostnames for #1369 ringX_addr

Thomas Lamprecht t.lamprecht at proxmox.com
Tue May 2 11:51:22 CEST 2017


If an user passed a hostname as ring0_addr or ring1_addr the check_ip
checked failed as it implicitly assumed IPs even if we allowed a
general address (i.e. IP or hostname) as a format for those
properties.

Fixes: #1369
Reported here: https://forum.proxmox.com/threads/34342/

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 data/PVE/CLI/pvecm.pm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/data/PVE/CLI/pvecm.pm b/data/PVE/CLI/pvecm.pm
index 4366066..e33a311 100755
--- a/data/PVE/CLI/pvecm.pm
+++ b/data/PVE/CLI/pvecm.pm
@@ -540,6 +540,15 @@ __PACKAGE__->register_method ({
 	my $check_ip = sub {
 	    my $ip = shift;
 	    if (defined($ip)) {
+		if (!PVE::JSONSchema::pve_verify_ip($ip, 1)) {
+		    my $host = $ip;
+		    eval { $ip = PVE::Network::get_ip_from_hostname($host); };
+		    if ($@) {
+			&$error("cannot use '$host': $@\n") ;
+			return;
+		    }
+		}
+
 		my $cidr = (Net::IP::ip_is_ipv6($ip)) ? "$ip/128" : "$ip/32";
 		my $configured_ips = PVE::Network::get_local_ip_from_cidr($cidr);
 
-- 
2.11.0





More information about the pve-devel mailing list