]> git.proxmox.com Git - pmg-api.git/commitdiff
fix #3712: strip trailing dot from searchdomain
authorStoiko Ivanov <s.ivanov@proxmox.com>
Mon, 22 Nov 2021 19:49:39 +0000 (20:49 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 23 Nov 2021 11:50:31 +0000 (12:50 +0100)
having a trailing '.' in the search domain is perfectly legal syntax
(for domain names in general). postfix refuses to use a fqdn with
trailing dot as hostname[0].

The restriction might be due to section 2.3.5 (Domain Names) of
RFC5321 (a top-level domain is a single string without any dots) [1]

[0] src/util/valid_hostname.c in the postfix source
[1] https://datatracker.ietf.org/doc/html/rfc5321#section-2.3.5

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
src/PMG/Config.pm

index cbcda6ecc3ed4a11b731e55acf67be327085d9d0..31f9c6f14147afa45e2a392ff64985987c15f64f 100755 (executable)
@@ -1278,6 +1278,8 @@ sub get_host_dns_info {
     my $resolv = PVE::INotify::read_file('resolvconf');
 
     my $domain = $resolv->{search} // 'localdomain';
+    # postfix will not parse a hostname with trailing '.'
+    $domain =~ s/^(.*)\.$/$1/;
     $dnsinfo->{domain} = $domain;
 
     $dnsinfo->{fqdn} = "$nodename.$domain";