public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH container] fix #3140: allow iface suffix on link local dns address
@ 2020-11-24 12:19 Wolfgang Bumiller
  2020-11-24 12:46 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Wolfgang Bumiller @ 2020-11-24 12:19 UTC (permalink / raw)
  To: pve-devel

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>
---
NOTE: GUI still needs to be adapted for this.

 src/PVE/LXC.pm        |  2 +-
 src/PVE/LXC/Config.pm | 19 ++++++++++++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 5cfcf28..e7a6951 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -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;
     }
 
diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
index db453f8..1277ef0 100644
--- a/src/PVE/LXC/Config.pm
+++ b/src/PVE/LXC/Config.pm
@@ -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 => {
-- 
2.20.1





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-24 12:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-24 12:19 [pve-devel] [PATCH container] fix #3140: allow iface suffix on link local dns address Wolfgang Bumiller
2020-11-24 12:46 ` [pve-devel] applied: " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal