From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 3D82862B47 for ; Tue, 24 Nov 2020 13:19:50 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 31460BDB3 for ; Tue, 24 Nov 2020 13:19:50 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id AE40BBDAA for ; Tue, 24 Nov 2020 13:19:49 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 7C6D440ADE for ; Tue, 24 Nov 2020 13:19:49 +0100 (CET) From: Wolfgang Bumiller To: pve-devel@lists.proxmox.com Date: Tue, 24 Nov 2020 13:19:45 +0100 Message-Id: <20201124121945.23444-1-w.bumiller@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.022 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [lxc.pm, config.pm] Subject: [pve-devel] [PATCH container] fix #3140: allow iface suffix on link local dns address X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Nov 2020 12:19:50 -0000 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 --- 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