[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH] Only write the short hostname to the localhost line (#474086)



Do not write the FQDN to the localhost line, only write the short
hostname if it's something other than 'localhost'.  Only write the
FQDN line to /etc/hosts if we have an IP address for the host.

Without this patch, users performing media installs who enter an
FQDN in the hostname field end up with their FQDN == 127.0.0.1,
which messes up things, such as sendmail.  Writing the short name
is what we really want here.

[rawhide]
---
 network.py |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/network.py b/network.py
index adde7cb..a2624cf 100644
--- a/network.py
+++ b/network.py
@@ -677,14 +677,9 @@ class Network:
                 domainname = None
 
             localline = "localhost.localdomain localhost"
-            if not ip or not fqdn:
-                # There is no ip or no fqdn, tie it to 127.0.0.1.
-                if fqdn:
-                    # add fqdn to 127.0.0.1
-                    localline += " " + fqdn
-                if hostname and hostname != "localhost":
-                    # add short hostname to 127.0.0.1
-                    localline += " " + hostname
+            if not ip and (hostname and hostname != "localhost"):
+                # add short hostname to 127.0.0.1
+                localline += " " + hostname
 
             f.write("# Do not remove the following line, or various programs\n")
             f.write("# that require network functionality will fail.\n")
-- 
1.6.0.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]