* [PATCH common] fix #6357: inotify: resolv.conf: parse all search domains
@ 2026-11-07 22:30 Lucas Barros
2026-11-11 23:15 ` Thomas Lamprecht
0 siblings, 1 reply; 8+ messages in thread
From: Lucas Barros @ 2026-11-07 22:30 UTC (permalink / raw)
To: pve-devel
The 'search' line of /etc/resolv.conf can list multiple domains, but
the parser only kept the first one. Writing the DNS settings of a node
with multiple search domains worked, but reading them back, for example
in the node's DNS panel in the web UI, only showed the first domain, so
saving the dialog again silently dropped the others.
Keep the whole list, with the domains separated by a single space. This
is the format the DNS API already accepts when writing, and the in-tree
users of the value that fall back to the host's search domains for
guests, cloud-init in qemu-server and the container setup code in
pve-container, already split it on whitespace.
Add a small test for the parser.
Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
---
The users of the parsed value that I found are the DNS API of the node
in pve-manager, get_dns_conf() in qemu-server's cloud-init code and
get_dns_settings() / update_etc_hosts() in pve-container's setup code.
The last two already treat it as a whitespace separated list. Note that
this means guests without their own 'searchdomain' now get all search
domains of the host instead of only the first one, both in their
resolv.conf and, for containers, as additional names in /etc/hosts.
That is what the host itself uses, so I think it is the expected
behavior, but please tell me if you prefer to keep that path as is.
Ran the new test/resolv_conf_test.pl, which fails on the parser before
this change (3 of 7) and passes with it. I ran it on perl 5.34 with
stubs for the Linux-only modules (Linux::Inotify2, syscall.ph), not on
a Debian system, and did not run the rest of 'make check'. proxmox-
perltidy was not available, the code was formatted by hand.
This patch was prepared with the help of an LLM based coding assistant; I
reviewed the change and ran the tests mentioned above myself.
src/PVE/INotify.pm | 4 +--
test/Makefile | 1 +
test/resolv_conf_test.pl | 65 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 68 insertions(+), 2 deletions(-)
create mode 100755 test/resolv_conf_test.pl
diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index 53b4e21..4a0355e 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -609,8 +609,8 @@ sub read_etc_resolv_conf {
my $nscount = 0;
while (my $line = <$fh>) {
chomp $line;
- if ($line =~ m/^(search|domain)\s+(\S+)\s*/) {
- $res->{search} = $2;
+ if ($line =~ m/^(search|domain)\s+(\S.*)$/) {
+ $res->{search} = join(' ', split(/\s+/, $2));
} elsif ($line =~ m/^\s*nameserver\s+($PVE::Tools::IPRE)\s*/) {
$nscount++;
if ($nscount <= 3) {
diff --git a/test/Makefile b/test/Makefile
index 9caba10..416bc0c 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -19,6 +19,7 @@ TESTS = lock_file.test \
ticket_test.test \
check_pem_test.test \
split_pem_test.test \
+ resolv_conf_test.test \
all:
diff --git a/test/resolv_conf_test.pl b/test/resolv_conf_test.pl
new file mode 100755
index 0000000..87dd716
--- /dev/null
+++ b/test/resolv_conf_test.pl
@@ -0,0 +1,65 @@
+#!/usr/bin/perl
+
+use v5.36;
+
+use lib '../src';
+
+use Test::More;
+
+use PVE::INotify;
+
+my $read_tests = [
+ {
+ name => 'single search domain',
+ input => "search example.com\nnameserver 192.0.2.1\n",
+ expected => { search => 'example.com', dns1 => '192.0.2.1' },
+ },
+ {
+ name => 'multiple search domains',
+ input => "search a.example b.example c.example\nnameserver 192.0.2.1\n",
+ expected => { search => 'a.example b.example c.example', dns1 => '192.0.2.1' },
+ },
+ {
+ name => 'multiple search domains with extra whitespace',
+ input => "search\ta.example b.example \t\nnameserver 192.0.2.1\n",
+ expected => { search => 'a.example b.example', dns1 => '192.0.2.1' },
+ },
+ {
+ name => 'domain keyword',
+ input => "domain example.com\nnameserver 192.0.2.1\n",
+ expected => { search => 'example.com', dns1 => '192.0.2.1' },
+ },
+ {
+ name => 'only the first three name servers',
+ input => "nameserver 192.0.2.1\nnameserver 192.0.2.2\n"
+ . "nameserver 2001:db8::1\nnameserver 192.0.2.4\n",
+ expected => { dns1 => '192.0.2.1', dns2 => '192.0.2.2', dns3 => '2001:db8::1' },
+ },
+];
+
+for my $test ($read_tests->@*) {
+ open(my $fh, '<', \$test->{input}) or die "failed to open in-memory file - $!\n";
+ my $res = PVE::INotify::read_etc_resolv_conf('/etc/resolv.conf', $fh);
+ is_deeply($res, $test->{expected}, "read: $test->{name}");
+}
+
+{
+ my $input = "search old.example\nnameserver 192.0.2.1\noptions rotate\n";
+ open(my $fh, '<', \$input) or die "failed to open in-memory file - $!\n";
+ my $data = PVE::INotify::update_etc_resolv_conf(
+ '/etc/resolv.conf',
+ $fh,
+ { search => 'a.example b.example', dns1 => '192.0.2.2' },
+ );
+ is(
+ $data,
+ "search a.example b.example\nnameserver 192.0.2.2\noptions rotate\n",
+ 'update: write multiple search domains',
+ );
+
+ open($fh, '<', \$data) or die "failed to open in-memory file - $!\n";
+ my $res = PVE::INotify::read_etc_resolv_conf('/etc/resolv.conf', $fh);
+ is($res->{search}, 'a.example b.example', 'update: read back multiple search domains');
+}
+
+done_testing();
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH common] fix #6357: inotify: resolv.conf: parse all search domains
2026-11-07 22:30 [PATCH common] fix #6357: inotify: resolv.conf: parse all search domains Lucas Barros
@ 2026-11-11 23:15 ` Thomas Lamprecht
2026-11-16 1:00 ` [PATCH cluster/qemu-server/common v2 0/3] fix #6357: parse all search domains of resolv.conf Lucas Barros
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Lamprecht @ 2026-11-11 23:15 UTC (permalink / raw)
To: Lucas Barros, pve-devel
Am 07.11.26 um 23:30 schrieb Lucas Barros:
> The 'search' line of /etc/resolv.conf can list multiple domains, but
> the parser only kept the first one. Writing the DNS settings of a node
> with multiple search domains worked, but reading them back, for example
> in the node's DNS panel in the web UI, only showed the first domain, so
> saving the dialog again silently dropped the others.
>
> Keep the whole list, with the domains separated by a single space. This
> is the format the DNS API already accepts when writing, and the in-tree
> users of the value that fall back to the host's search domains for
> guests, cloud-init in qemu-server and the container setup code in
> pve-container, already split it on whitespace.
Thanks for your patch, this can be fine, but needs some special care to
ensure we do not have any use site where this causes problems, see
inline below.
>
> Add a small test for the parser.
>
> Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
> ---
>
> The users of the parsed value that I found are the DNS API of the node
> in pve-manager, get_dns_conf() in qemu-server's cloud-init code and
> get_dns_settings() / update_etc_hosts() in pve-container's setup code.
> The last two already treat it as a whitespace separated list. Note that
> this means guests without their own 'searchdomain' now get all search
> domains of the host instead of only the first one, both in their
> resolv.conf and, for containers, as additional names in /etc/hosts.
> That is what the host itself uses, so I think it is the expected
> behavior, but please tell me if you prefer to keep that path as is.
>
> Ran the new test/resolv_conf_test.pl, which fails on the parser before
> this change (3 of 7) and passes with it. I ran it on perl 5.34 with
> stubs for the Linux-only modules (Linux::Inotify2, syscall.ph), not on
> a Debian system, and did not run the rest of 'make check'. proxmox-
> perltidy was not available, the code was formatted by hand.
>
> This patch was prepared with the help of an LLM based coding assistant; I
> reviewed the change and ran the tests mentioned above myself.
>
> src/PVE/INotify.pm | 4 +--
> test/Makefile | 1 +
> test/resolv_conf_test.pl | 65 ++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 68 insertions(+), 2 deletions(-)
> create mode 100755 test/resolv_conf_test.pl
>
> diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
> index 53b4e21..4a0355e 100644
> --- a/src/PVE/INotify.pm
> +++ b/src/PVE/INotify.pm
> @@ -609,8 +609,8 @@ sub read_etc_resolv_conf {
> my $nscount = 0;
> while (my $line = <$fh>) {
> chomp $line;
> - if ($line =~ m/^(search|domain)\s+(\S+)\s*/) {
> - $res->{search} = $2;
> + if ($line =~ m/^(search|domain)\s+(\S.*)$/) {
> + $res->{search} = join(' ', split(/\s+/, $2));
The node certificate generator in src/PVE/Cluster/Setup.pm builds the
certificate FQDN by appending the whole search value to the node name, for
both the subject CN and a DNS subject alternative name. With a multi-domain
search list this now yields a CN and SAN like `node.a.example b.example` -
so that needs to cope with this. Maybe there are other sites, checking the
behavior in the rust side (PBS, PDM) might be good to, even just to ensure
consistency.
> } elsif ($line =~ m/^\s*nameserver\s+($PVE::Tools::IPRE)\s*/) {
> $nscount++;
> if ($nscount <= 3) {
> diff --git a/test/Makefile b/test/Makefile
> index 9caba10..416bc0c 100644
> --- a/test/Makefile
> +++ b/test/Makefile
> @@ -19,6 +19,7 @@ TESTS = lock_file.test \
> ticket_test.test \
> check_pem_test.test \
> split_pem_test.test \
> + resolv_conf_test.test \
>
> all:
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH cluster/qemu-server/common v2 0/3] fix #6357: parse all search domains of resolv.conf
2026-11-11 23:15 ` Thomas Lamprecht
@ 2026-11-16 1:00 ` Lucas Barros
2026-11-16 1:00 ` [PATCH cluster v2 1/3] setup: node certificate: only use the first search domain for the FQDN Lucas Barros
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Lucas Barros @ 2026-11-16 1:00 UTC (permalink / raw)
To: pve-devel; +Cc: t.lamprecht, Lucas Barros
The resolv.conf parser in pve-common only keeps the first domain of the
'search' line, so the DNS panel of a node shows only that one and saving
it again drops the others.
Thomas pointed out that the node certificate appends the value to the
node name [0]. I went through all users of the value (and of FQDNs
built from a search list) and used one rule: the API and the guests'
DNS settings get the whole list, an FQDN only uses the first domain.
That is what the certificates got so far, as the parser only returned
the first domain.
* 1/3 pve-cluster: node certificate uses the first domain; has to be
applied before 3/3
* 2/3 qemu-server: cloud-init 'fqdn' used the whole 'searchdomain' of
the VM ('vm.a.example b.example'); independent of 3/3, same mistake
* 3/3 pve-common: the parser fix, unchanged code from v1
Other users need no change: the cloud-init and container setup code
already split the value into a list, pveperf reads resolv.conf on its
own, and PVE::Notify takes its FQDN from getaddrinfo(). Details in the
notes of 3/3.
Tested on a PVE 9 node (pve-cluster 9.1.9, qemu-server 9.2.15,
libpve-common-perl 9.2.8, files patched in place), search domains set
with resolvectl, certificate regenerated with 'pvecm updatecerts
--force':
GET .../dns cert CN / DNS SAN cloud-init
search fqdn (*)
stock, 1 domain dom node.dom vm.x y
stock, 3 domains dom node.dom vm.x y
3/3 only, 3 domains dom b c node.dom b c (bad) vm.x y
1-3/3, 3 domains dom b c node.dom vm.x
1-3/3, 1 domain dom node.dom vm.x
(*) VM with 'searchdomain: x y'
With 3/3 VMs without their own DNS settings get all three domains in
the network config, before only the first. pveproxy came up with every
certificate. 'make check' in pve-common passes before and after (the
new test fails 3 of 7 without 3/3), the qemu-server tests give the
same result before and after, proxmox-perltidy reports no changes.
The Rust side has the same first-domain-only parser in proxmox-dns-api
(used by PDM) and in proxmox-backup, and builds the FQDN of the
self-signed certificate (and of the PBS notification links) the same
way. So it is consistent with the old behavior. I have patches to
align it with this rule and can send them to pbs-devel/pdm-devel if
you want that.
v1: https://lore.proxmox.com/pve-devel/20261107223019.21361-1-lucasbarros.kam@gmail.com/
[0] https://lore.proxmox.com/pve-devel/f981f39c-2604-4a34-9b0e-4fc0e0bb3373@proxmox.com/
This series was prepared with the help of an LLM based coding
assistant; I reviewed the changes and ran the tests mentioned above
myself.
cluster:
Lucas Barros (1):
setup: node certificate: only use the first search domain for the FQDN
src/PVE/Cluster/Setup.pm | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
qemu-server:
Lucas Barros (1):
cloudinit: only use the first search domain for the FQDN
src/PVE/QemuServer/Cloudinit.pm | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
common:
Lucas Barros (1):
fix #6357: inotify: resolv.conf: parse all search domains
src/PVE/INotify.pm | 4 +--
test/Makefile | 1 +
test/resolv_conf_test.pl | 65 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 68 insertions(+), 2 deletions(-)
create mode 100755 test/resolv_conf_test.pl
--
2.50.1 (Apple Git-155)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH cluster v2 1/3] setup: node certificate: only use the first search domain for the FQDN
2026-11-16 1:00 ` [PATCH cluster/qemu-server/common v2 0/3] fix #6357: parse all search domains of resolv.conf Lucas Barros
@ 2026-11-16 1:00 ` Lucas Barros
2026-11-16 1:00 ` [PATCH qemu-server v2 2/3] cloudinit: " Lucas Barros
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Lucas Barros @ 2026-11-16 1:00 UTC (permalink / raw)
To: pve-devel; +Cc: t.lamprecht, Lucas Barros
The certificate of a node gets the node name plus the search domain of
/etc/resolv.conf as subject CN and as DNS subject alternative name. The
search line can list multiple domains, and once the resolv.conf parser
in pve-common returns all of them, appending the whole list results in
a certificate with 'CN=node.a.example b.example' and a SAN with the
same, invalid, DNS name.
Use only the first domain. That is what the certificate got so far, as
the parser only returned the first domain, and it is the domain the
installer writes, so for the common setups it is the domain the node
lives in.
Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
---
changes since v1:
* new patch: with 3/3 applied alone, the certificate got
'CN=node.a.example b.example c.example' and the same invalid name as
DNS SAN, as Thomas pointed out
Using the first domain keeps today's certificates, as the parser only
returned that one so far. I also looked at the canonical name from
getaddrinfo() (PVE::Tools::get_fqdn()), but that can change the CN on
nodes where /etc/hosts or DNS do not match resolv.conf, so I kept the
current source. This has to be applied before 3/3, or pve-common needs
a Breaks on older pve-cluster.
Tested with 'pvecm updatecerts --force' on a PVE 9 node with three
search domains, see the cover letter.
This patch was prepared with the help of an LLM based coding assistant; I
reviewed the change and ran the tests mentioned above myself.
src/PVE/Cluster/Setup.pm | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/PVE/Cluster/Setup.pm b/src/PVE/Cluster/Setup.pm
index 8a398d3..f6cc689 100644
--- a/src/PVE/Cluster/Setup.pm
+++ b/src/PVE/Cluster/Setup.pm
@@ -640,8 +640,9 @@ sub gen_pve_ssl_cert {
my $fqdn = $nodename;
my $rc = PVE::INotify::read_file('resolvconf');
- if ($rc && $rc->{search}) {
- $fqdn .= ".$rc->{search}";
+ # the search list can hold more than one domain, only the first one is used for the FQDN
+ if ($rc && (my ($domain) = split(' ', $rc->{search} // ''))) {
+ $fqdn .= ".$domain";
$names .= ",DNS:$fqdn";
}
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH qemu-server v2 2/3] cloudinit: only use the first search domain for the FQDN
2026-11-16 1:00 ` [PATCH cluster/qemu-server/common v2 0/3] fix #6357: parse all search domains of resolv.conf Lucas Barros
2026-11-16 1:00 ` [PATCH cluster v2 1/3] setup: node certificate: only use the first search domain for the FQDN Lucas Barros
@ 2026-11-16 1:00 ` Lucas Barros
2026-11-16 1:00 ` [PATCH common v2 3/3] fix #6357: inotify: resolv.conf: parse all search domains Lucas Barros
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Lucas Barros @ 2026-11-16 1:00 UTC (permalink / raw)
To: pve-devel; +Cc: t.lamprecht, Lucas Barros
The 'searchdomain' option takes a list of domains, separated by spaces,
and the DNS configuration passed to the guest already splits it like
that. The FQDN for the user-data, however, is built by appending the
whole value to the name of the VM, so with 'searchdomain: a.example
b.example' the guest gets 'fqdn: vm.a.example b.example', which is not
a valid host name, and with manage_etc_hosts the second domain can end
up in /etc/hosts as a name for the guest's own address.
Use only the first domain for the FQDN, which is the same result as
before for a single domain.
Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
---
changes since v1:
* new patch. It is not caused by 3/3, it is about the VM's own
'searchdomain' option, but it is the same mistake as in 1/3 and I
found it while going through the users. Can be applied on its own.
Tested with 'qm cloudinit dump <vmid> user' on a PVE 9 node:
'searchdomain: x.example y.example' gave 'fqdn: vm.x.example
y.example' before and gives 'fqdn: vm.x.example' now; one domain and
no searchdomain give the same output as before. The network config
still gets both domains as search list. I did not boot a guest with it.
This patch was prepared with the help of an LLM based coding assistant; I
reviewed the change and ran the tests mentioned above myself.
src/PVE/QemuServer/Cloudinit.pm | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/PVE/QemuServer/Cloudinit.pm b/src/PVE/QemuServer/Cloudinit.pm
index f7f8c8e1..7febdcb2 100644
--- a/src/PVE/QemuServer/Cloudinit.pm
+++ b/src/PVE/QemuServer/Cloudinit.pm
@@ -116,8 +116,9 @@ sub get_hostname_fqdn {
if ($hostname =~ /\./) {
$fqdn = $hostname;
$hostname =~ s/\..*$//;
- } elsif (my $search = $conf->{searchdomain}) {
- $fqdn = "$hostname.$search";
+ } elsif (my ($domain) = split(' ', $conf->{searchdomain} // '')) {
+ # 'searchdomain' can hold a list, only the first domain belongs to the FQDN
+ $fqdn = "$hostname.$domain";
} else {
$fqdn = $hostname;
}
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH common v2 3/3] fix #6357: inotify: resolv.conf: parse all search domains
2026-11-16 1:00 ` [PATCH cluster/qemu-server/common v2 0/3] fix #6357: parse all search domains of resolv.conf Lucas Barros
2026-11-16 1:00 ` [PATCH cluster v2 1/3] setup: node certificate: only use the first search domain for the FQDN Lucas Barros
2026-11-16 1:00 ` [PATCH qemu-server v2 2/3] cloudinit: " Lucas Barros
@ 2026-11-16 1:00 ` Lucas Barros
2026-11-16 1:48 ` [PATCH cluster/qemu-server/common v2 0/3] fix #6357: parse all search domains of resolv.conf Thomas Lamprecht
2026-11-16 13:32 ` superseded: " Lucas Barros
4 siblings, 0 replies; 8+ messages in thread
From: Lucas Barros @ 2026-11-16 1:00 UTC (permalink / raw)
To: pve-devel; +Cc: t.lamprecht, Lucas Barros
The 'search' line of /etc/resolv.conf can list multiple domains, but
the parser only kept the first one. Writing the DNS settings of a node
with multiple search domains worked, but reading them back, for example
in the node's DNS panel in the web UI, only showed the first domain, so
saving the dialog again silently dropped the others.
Keep the whole list, with the domains separated by a single space. This
is the format the DNS API already accepts when writing.
The other users of the value: the node certificate generation in
pve-cluster appends it to the node name, so it needs to only take the
first domain before this is applied. The cloud-init code in qemu-server
and the container setup code in pve-container use it as the DNS search
list of guests without their own setting and already split it on
whitespace, so those guests now get the full list of the host.
Add a small test for the parser.
Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
---
changes since v1:
* commit message: describe all users of the value
* depends on 1/3, which keeps the node certificate on the first domain
* tested on a PVE 9 node and with 'make check' there
Users of the value, in all repos that read 'resolvconf':
* pve-manager, GET /nodes/{node}/dns: now returns the whole list
* pve-cluster, gen_pve_ssl_cert(): FQDN for CN and SAN, see 1/3
* qemu-server, Cloudinit get_dns_conf(): search list for VMs without
their own searchdomain/nameserver, split on whitespace
* pve-container, Setup::Base lookup_dns_conf(): same for containers,
used for their resolv.conf and /etc/hosts, split with split_list()
bin/pveperf in pve-manager reads /etc/resolv.conf itself and keeps
using the first domain for its DNS test.
Behavior change for guests without their own setting: they get all
search domains of the host instead of only the first. For containers
this also adds 'ct.b.example' etc. to /etc/hosts, the same as when the
container's own searchdomain has several entries (bug #5605 asked to
avoid that, Fabian answered the file can be overridden). If you would
rather keep the guest fallback on the first domain, I can do that in
qemu-server and pve-container instead.
This patch was prepared with the help of an LLM based coding assistant; I
reviewed the change and ran the tests mentioned above myself.
src/PVE/INotify.pm | 4 +--
test/Makefile | 1 +
test/resolv_conf_test.pl | 65 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 68 insertions(+), 2 deletions(-)
create mode 100755 test/resolv_conf_test.pl
diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index 53b4e21..4a0355e 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -609,8 +609,8 @@ sub read_etc_resolv_conf {
my $nscount = 0;
while (my $line = <$fh>) {
chomp $line;
- if ($line =~ m/^(search|domain)\s+(\S+)\s*/) {
- $res->{search} = $2;
+ if ($line =~ m/^(search|domain)\s+(\S.*)$/) {
+ $res->{search} = join(' ', split(/\s+/, $2));
} elsif ($line =~ m/^\s*nameserver\s+($PVE::Tools::IPRE)\s*/) {
$nscount++;
if ($nscount <= 3) {
diff --git a/test/Makefile b/test/Makefile
index 9caba10..416bc0c 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -19,6 +19,7 @@ TESTS = lock_file.test \
ticket_test.test \
check_pem_test.test \
split_pem_test.test \
+ resolv_conf_test.test \
all:
diff --git a/test/resolv_conf_test.pl b/test/resolv_conf_test.pl
new file mode 100755
index 0000000..87dd716
--- /dev/null
+++ b/test/resolv_conf_test.pl
@@ -0,0 +1,65 @@
+#!/usr/bin/perl
+
+use v5.36;
+
+use lib '../src';
+
+use Test::More;
+
+use PVE::INotify;
+
+my $read_tests = [
+ {
+ name => 'single search domain',
+ input => "search example.com\nnameserver 192.0.2.1\n",
+ expected => { search => 'example.com', dns1 => '192.0.2.1' },
+ },
+ {
+ name => 'multiple search domains',
+ input => "search a.example b.example c.example\nnameserver 192.0.2.1\n",
+ expected => { search => 'a.example b.example c.example', dns1 => '192.0.2.1' },
+ },
+ {
+ name => 'multiple search domains with extra whitespace',
+ input => "search\ta.example b.example \t\nnameserver 192.0.2.1\n",
+ expected => { search => 'a.example b.example', dns1 => '192.0.2.1' },
+ },
+ {
+ name => 'domain keyword',
+ input => "domain example.com\nnameserver 192.0.2.1\n",
+ expected => { search => 'example.com', dns1 => '192.0.2.1' },
+ },
+ {
+ name => 'only the first three name servers',
+ input => "nameserver 192.0.2.1\nnameserver 192.0.2.2\n"
+ . "nameserver 2001:db8::1\nnameserver 192.0.2.4\n",
+ expected => { dns1 => '192.0.2.1', dns2 => '192.0.2.2', dns3 => '2001:db8::1' },
+ },
+];
+
+for my $test ($read_tests->@*) {
+ open(my $fh, '<', \$test->{input}) or die "failed to open in-memory file - $!\n";
+ my $res = PVE::INotify::read_etc_resolv_conf('/etc/resolv.conf', $fh);
+ is_deeply($res, $test->{expected}, "read: $test->{name}");
+}
+
+{
+ my $input = "search old.example\nnameserver 192.0.2.1\noptions rotate\n";
+ open(my $fh, '<', \$input) or die "failed to open in-memory file - $!\n";
+ my $data = PVE::INotify::update_etc_resolv_conf(
+ '/etc/resolv.conf',
+ $fh,
+ { search => 'a.example b.example', dns1 => '192.0.2.2' },
+ );
+ is(
+ $data,
+ "search a.example b.example\nnameserver 192.0.2.2\noptions rotate\n",
+ 'update: write multiple search domains',
+ );
+
+ open($fh, '<', \$data) or die "failed to open in-memory file - $!\n";
+ my $res = PVE::INotify::read_etc_resolv_conf('/etc/resolv.conf', $fh);
+ is($res->{search}, 'a.example b.example', 'update: read back multiple search domains');
+}
+
+done_testing();
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH cluster/qemu-server/common v2 0/3] fix #6357: parse all search domains of resolv.conf
2026-11-16 1:00 ` [PATCH cluster/qemu-server/common v2 0/3] fix #6357: parse all search domains of resolv.conf Lucas Barros
` (2 preceding siblings ...)
2026-11-16 1:00 ` [PATCH common v2 3/3] fix #6357: inotify: resolv.conf: parse all search domains Lucas Barros
@ 2026-11-16 1:48 ` Thomas Lamprecht
2026-11-16 13:32 ` superseded: " Lucas Barros
4 siblings, 0 replies; 8+ messages in thread
From: Thomas Lamprecht @ 2026-11-16 1:48 UTC (permalink / raw)
To: Lucas Barros, pve-devel
Thanks for the v2, still some issues though, see below.
Am 16.11.26 um 02:00 schrieb Lucas Barros:
> The resolv.conf parser in pve-common only keeps the first domain of the
> 'search' line, so the DNS panel of a node shows only that one and saving
> it again drops the others.
>
> Thomas pointed out that the node certificate appends the value to the
> node name [0]. I went through all users of the value (and of FQDNs
> built from a search list) and used one rule: the API and the guests'
> DNS settings get the whole list, an FQDN only uses the first domain.
> That is what the certificates got so far, as the parser only returned
> the first domain.
>
> * 1/3 pve-cluster: node certificate uses the first domain; has to be
> applied before 3/3
> * 2/3 qemu-server: cloud-init 'fqdn' used the whole 'searchdomain' of
> the VM ('vm.a.example b.example'); independent of 3/3, same mistake
> * 3/3 pve-common: the parser fix, unchanged code from v1
Please sent v2 as new thread, i.e. without in-reply-to header for the
previous revision. A reply to the old thread with a superseded: in
the subject and
superseded-by: https://lore.proxmox.com/pve-devel/20261107223019.21361-1-lucasbarros.kam@gmail.com/
in the body then tells all where they can find the new one (git send-email
can be made to generate such a reply too, i.e. your LLM can help here
if in doubt).
Anyway, back to the change at hand:
I overlooked that PMG also uses this and would need changing too, i.e.
in PMG::Config::get_host_dns_info() would and also in
PMG::Utils::gen_proxmox_tls_cert() and pmg-smtp-filter and maybe more.
Starting to think it might be easier to keep this as is, add a new
method with the multi-search-domain behavior and switch over the
API for dns edit to that one?
Oh and resolv.conf(5) specifies that the obsolete domain directive
handles only one search-list entry. The shared branch now treats
"domain a.example b.example" as two domains, whereas the previous parser
retained only "a.example". Consequently, the API and guest fallback
settings can acquire an additional domain that the host resolver does
not use; saving the node DNS settings also converts that value into a
multi-entry search directive. So consider keeping first-token parsing
for domain and applying whole-list parsing only to search. A regression
test with trailing words after a domain entry could cover the
distinction; the current single-domain test cannot detect it.
^ permalink raw reply [flat|nested] 8+ messages in thread
* superseded: [PATCH cluster/qemu-server/common v2 0/3] fix #6357: parse all search domains of resolv.conf
2026-11-16 1:00 ` [PATCH cluster/qemu-server/common v2 0/3] fix #6357: parse all search domains of resolv.conf Lucas Barros
` (3 preceding siblings ...)
2026-11-16 1:48 ` [PATCH cluster/qemu-server/common v2 0/3] fix #6357: parse all search domains of resolv.conf Thomas Lamprecht
@ 2026-11-16 13:32 ` Lucas Barros
4 siblings, 0 replies; 8+ messages in thread
From: Lucas Barros @ 2026-11-16 13:32 UTC (permalink / raw)
To: pve-devel; +Cc: t.lamprecht
Superseded-by: https://lore.proxmox.com/pve-devel/20261116133000.6357-0-lucasbarros.kam@gmail.com/
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-16 13:32 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-07 22:30 [PATCH common] fix #6357: inotify: resolv.conf: parse all search domains Lucas Barros
2026-11-11 23:15 ` Thomas Lamprecht
2026-11-16 1:00 ` [PATCH cluster/qemu-server/common v2 0/3] fix #6357: parse all search domains of resolv.conf Lucas Barros
2026-11-16 1:00 ` [PATCH cluster v2 1/3] setup: node certificate: only use the first search domain for the FQDN Lucas Barros
2026-11-16 1:00 ` [PATCH qemu-server v2 2/3] cloudinit: " Lucas Barros
2026-11-16 1:00 ` [PATCH common v2 3/3] fix #6357: inotify: resolv.conf: parse all search domains Lucas Barros
2026-11-16 1:48 ` [PATCH cluster/qemu-server/common v2 0/3] fix #6357: parse all search domains of resolv.conf Thomas Lamprecht
2026-11-16 13:32 ` superseded: " Lucas Barros
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.