[pve-devel] [PATCH container] add fqdn to /etc/hosts even with no ip

Dominik Csapak d.csapak at proxmox.com
Fri Jun 29 10:05:44 CEST 2018


so that if a container is set to dhcp, it still has its
fqdn set correctly

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/PVE/LXC/Setup/Base.pm              | 2 ++
 src/test/test-debian-001/etc/hosts.exp | 2 +-
 src/test/test-debian-003/etc/hosts.exp | 2 +-
 src/test/test-debian-005/etc/hosts.exp | 2 +-
 src/test/test-debian-007/etc/hosts.exp | 2 +-
 src/test/test-debian-009/etc/hosts.exp | 2 +-
 src/test/test-debian-010/etc/hosts.exp | 2 +-
 7 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/PVE/LXC/Setup/Base.pm b/src/PVE/LXC/Setup/Base.pm
index 62e37b9..a0ed8ec 100644
--- a/src/PVE/LXC/Setup/Base.pm
+++ b/src/PVE/LXC/Setup/Base.pm
@@ -90,6 +90,8 @@ sub update_etc_hosts {
 
     if (defined($hostip)) {
 	$section .= "$hostip $all_names\n";
+    } elsif ($namepart ne 'localhost') {
+	$section .= "127.0.1.1 $all_names\n";
     } else {
 	$section .= "127.0.1.1 $namepart\n";
     }
diff --git a/src/test/test-debian-001/etc/hosts.exp b/src/test/test-debian-001/etc/hosts.exp
index c0dd46e..c32502b 100644
--- a/src/test/test-debian-001/etc/hosts.exp
+++ b/src/test/test-debian-001/etc/hosts.exp
@@ -1,5 +1,5 @@
 # --- BEGIN PVE ---
 127.0.0.1 localhost.localnet localhost
 ::1 localhost.localnet localhost
-127.0.1.1 test1
+127.0.1.1 test1.proxmox.com test1
 # --- END PVE ---
diff --git a/src/test/test-debian-003/etc/hosts.exp b/src/test/test-debian-003/etc/hosts.exp
index 3f85d3f..b0c50ea 100644
--- a/src/test/test-debian-003/etc/hosts.exp
+++ b/src/test/test-debian-003/etc/hosts.exp
@@ -1,5 +1,5 @@
 # --- BEGIN PVE ---
 127.0.0.1 localhost.localnet localhost
 ::1 localhost.localnet localhost
-127.0.1.1 test3
+127.0.1.1 test3.proxmox.com test3
 # --- END PVE ---
diff --git a/src/test/test-debian-005/etc/hosts.exp b/src/test/test-debian-005/etc/hosts.exp
index c0dd46e..c32502b 100644
--- a/src/test/test-debian-005/etc/hosts.exp
+++ b/src/test/test-debian-005/etc/hosts.exp
@@ -1,5 +1,5 @@
 # --- BEGIN PVE ---
 127.0.0.1 localhost.localnet localhost
 ::1 localhost.localnet localhost
-127.0.1.1 test1
+127.0.1.1 test1.proxmox.com test1
 # --- END PVE ---
diff --git a/src/test/test-debian-007/etc/hosts.exp b/src/test/test-debian-007/etc/hosts.exp
index c0dd46e..c32502b 100644
--- a/src/test/test-debian-007/etc/hosts.exp
+++ b/src/test/test-debian-007/etc/hosts.exp
@@ -1,5 +1,5 @@
 # --- BEGIN PVE ---
 127.0.0.1 localhost.localnet localhost
 ::1 localhost.localnet localhost
-127.0.1.1 test1
+127.0.1.1 test1.proxmox.com test1
 # --- END PVE ---
diff --git a/src/test/test-debian-009/etc/hosts.exp b/src/test/test-debian-009/etc/hosts.exp
index ac7ee16..d9b20b6 100644
--- a/src/test/test-debian-009/etc/hosts.exp
+++ b/src/test/test-debian-009/etc/hosts.exp
@@ -1,5 +1,5 @@
 # --- BEGIN PVE ---
 127.0.0.1 localhost.localnet localhost
 ::1 localhost.localnet localhost
-127.0.1.1 test9
+127.0.1.1 test9.proxmox.com test9
 # --- END PVE ---
diff --git a/src/test/test-debian-010/etc/hosts.exp b/src/test/test-debian-010/etc/hosts.exp
index e540d5a..98ec0d3 100644
--- a/src/test/test-debian-010/etc/hosts.exp
+++ b/src/test/test-debian-010/etc/hosts.exp
@@ -1,5 +1,5 @@
 # --- BEGIN PVE ---
 127.0.0.1 localhost.localnet localhost
 ::1 localhost.localnet localhost
-127.0.1.1 test10
+127.0.1.1 test10.proxmox.com test10
 # --- END PVE ---
-- 
2.11.0




More information about the pve-devel mailing list