]> git.proxmox.com Git - pve-container.git/commitdiff
fix #3140: allow iface suffix on link local dns address
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 24 Nov 2020 12:19:45 +0000 (13:19 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 24 Nov 2020 12:44:22 +0000 (13:44 +0100)
Allows nameserver entries of the form `fe80::1%eth2`

Note that previously the schema allowed domain names here as
well, while only allowing IPs in the hotplug's verification
code.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/PVE/LXC.pm
src/PVE/LXC/Config.pm

index 5cfcf282524bd6c6674e4de991ab55fd6675c1df..e7a695136d7d3c15e0231abea156c8ae304aa184 100644 (file)
@@ -737,7 +737,7 @@ sub verify_nameserver_list {
 
     my @list = ();
     foreach my $server (PVE::Tools::split_list($nameserver_list)) {
-       PVE::JSONSchema::pve_verify_ip($server);
+       PVE::LXC::Config::verify_ip_with_ll_iface($server);
        push @list, $server;
     }
 
index db453f86292ea5e3878835ef67a7fb0e2e780ff2..1277ef0fa6734b7835f61186991d0d69e4d3520a 100644 (file)
@@ -341,6 +341,23 @@ PVE::JSONSchema::register_standard_option('pve-ct-rootfs', {
     optional => 1,
 });
 
+# IP address with optional interface suffix for link local ipv6 addresses
+PVE::JSONSchema::register_format('lxc-ip-with-ll-iface', \&verify_ip_with_ll_iface);
+sub verify_ip_with_ll_iface {
+    my ($addr, $noerr) = @_;
+
+    if (my ($addr, $iface) = ($addr =~ /^(fe80:[^%]+)%(.*)$/)) {
+       if (PVE::JSONSchema::pve_verify_ip($addr, 1)
+           && PVE::JSONSchema::pve_verify_iface($iface, 1))
+       {
+           return $addr;
+       }
+    }
+
+    return PVE::JSONSchema::pve_verify_ip($addr, $noerr);
+}
+
+
 my $features_desc = {
     mount => {
        optional => 1,
@@ -500,7 +517,7 @@ my $confdesc = {
     },
     nameserver => {
        optional => 1,
-       type => 'string', format => 'address-list',
+       type => 'string', format => 'lxc-ip-with-ll-iface-list',
        description => "Sets DNS server IP address for a container. Create will automatically use the setting from the host if you neither set searchdomain nor nameserver.",
     },
     timezone => {