]> git.proxmox.com Git - pve-container.git/commitdiff
Setup: order fqdn before hostname in /etc/hosts
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 14 Dec 2015 13:02:18 +0000 (14:02 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 18 Dec 2015 08:08:30 +0000 (09:08 +0100)
Some services seem to require this to lookup the local fqdn.
This only affects /etc/hosts while /etc/hostname still uses
the non-fqdn hostname.

This is also consistent with behavior in 4.0 (before commit
ce289e3c6e).

Fixes #845

src/PVE/LXC/Setup/Base.pm
src/test/test-debian-004/etc/hosts.exp

index 7627f552d31257ffb8e8a185a0300caaad1f25e2..8991b29849c9db5af0447a98113dc218ab3b4b64 100644 (file)
@@ -62,14 +62,16 @@ sub update_etc_hosts {
 
     my $namepart = ($newname =~ s/\..*$//r);
 
-    my $extra_names = '';
+    my $all_names = '';
     if ($newname =~ /\./) {
-       $extra_names .= $namepart;
+       $all_names .= "$newname $namepart";
     } else {
        foreach my $domain (PVE::Tools::split_list($searchdomains)) {
-           $extra_names .= ' ' if $extra_names;
-           $extra_names .= "$newname.$domain";
+           $all_names .= ' ' if $all_names;
+           $all_names .= "$newname.$domain";
        }
+       $all_names .= ' ' if $all_names;
+       $all_names .= $newname;
     }
     
     foreach my $line (split(/\n/, $etc_hosts_data)) {
@@ -97,7 +99,7 @@ sub update_etc_hosts {
        if ($found) {
            if (!$done) {
                if (defined($hostip)) {
-                   push @lines, "$hostip $extra_names $newname";
+                   push @lines, "$hostip $all_names";
                } else {
                    push @lines, "127.0.1.1 $namepart";
                }
@@ -111,7 +113,7 @@ sub update_etc_hosts {
 
     if (!$done) {
        if (defined($hostip)) {
-           push @lines, "$hostip $extra_names $newname";
+           push @lines, "$hostip $all_names";
        } else {
            push @lines, "127.0.1.1 $namepart";
        }       
index 988a1e7c0ef84db5c944962b6f6dc4bb1f93138c..cd65bdf0302600da1ecdfe4ca02747e11aca02a3 100644 (file)
@@ -1,2 +1,2 @@
 127.0.0.1 localhost.localnet localhost
-1.2.3.2 test3 test3.use-fqdn.com
+1.2.3.2 test3.use-fqdn.com test3