]> git.proxmox.com Git - pve-cluster.git/commitdiff
pvecm add: fix #1369 - re-allow using hostnames for ringX_addr
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 2 May 2017 09:51:22 +0000 (11:51 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 4 May 2017 08:13:54 +0000 (10:13 +0200)
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@proxmox.com>
data/PVE/CLI/pvecm.pm

index 436606613642cbeeceb7f1309981b8787363d5f4..e33a31128b03f8e373a1f89b738faaec919da2b6 100755 (executable)
@@ -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);