[PATCH 2/9] Do not write /etc/hosts since setup owns that now (#491808)

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

 



The setup package owns /etc/hosts and NetworkManager manages it once the
system is running, so anaconda no longer needs to write out information
to /etc/hosts during installation.
---
 network.py  |   61 ++++++++++++++--------------------------------------------
 packages.py |    2 +-
 2 files changed, 16 insertions(+), 47 deletions(-)

diff --git a/network.py b/network.py
index 5dc9060..e9ba2bc 100644
--- a/network.py
+++ b/network.py
@@ -648,57 +648,26 @@ class Network:
             f.close()
             shutil.move(newnetwork, destnetwork)
 
-        # /etc/hosts
+        # If the hostname was not looked up, but typed in by the user,
+        # domain might not be computed, so do it now.
         domainname = None
-        if (not instPath) or (not os.path.isfile(instPath + "/etc/hosts")):
-            f = open(instPath + "/etc/hosts", "w")
-
-            log.info("self.hostname = %s", self.hostname)
+        if "." in self.hostname:
+            fqdn = self.hostname
+        else:
+            fqdn = socket.getfqdn(self.hostname)
 
-            # IP address
-            ip = self.lookupHostname()
-            if ip in [ "127.0.0.1", "::1" ]:
-                ip = None
+        if fqdn in [ "localhost.localdomain", "localhost",
+                     "localhost6.localdomain6", "localhost6",
+                     self.hostname ] or "." not in fqdn:
+            fqdn = None
 
-            # fqdn and hostname
-            if "." in self.hostname:
-                fqdn = self.hostname
-                hostname = self.hostname.split('.', 1)[0]
-            else:
-                fqdn = socket.getfqdn(self.hostname)
-                hostname = self.hostname
-
-            if fqdn in [ "localhost.localdomain", "localhost",
-                         "localhost6.localdomain6", "localhost6", hostname ] \
-                         or "." not in fqdn:
-                fqdn = None
-
-            # domainname
-            if fqdn:
-                domainname = fqdn.split('.', 1)[1]
-                if domainname in [ "localdomain", "localdomain6" ]:
-                    domainname = None
-            else:
+        if fqdn:
+            domainname = fqdn.split('.', 1)[1]
+            if domainname in [ "localdomain", "localdomain6" ]:
                 domainname = None
+        else:
+            domainname = None
 
-            localline = "localhost.localdomain localhost"
-            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")
-            f.write("127.0.0.1\t\t" + localline + "\n")
-            f.write("::1\t\tlocalhost6.localdomain6 localhost6\n")
-
-            if ip and fqdn:
-                # Add an extra entry for ip, fqdn and hostname
-                f.write("%s\t\t%s %s\n" % (ip, fqdn, hostname))
-
-            f.close()
-
-        # If the hostname was not looked up, but typed in by the user,
-        # domain might not be computed, so do it now.
         if self.domains == ["localdomain"] or not self.domains:
             if domainname:
                 self.domains = [domainname]
diff --git a/packages.py b/packages.py
index 03e21b3..fcaec00 100644
--- a/packages.py
+++ b/packages.py
@@ -251,7 +251,7 @@ def setFileCons(anaconda):
                  "/etc/modprobe.conf", "/etc/modprobe.conf~",
                  "/var/log/wtmp", "/var/run/utmp", "/etc/crypttab",
                  "/dev/log", "/var/lib/rpm", "/", "/etc/raidtab",
-                 "/etc/mdadm.conf", "/etc/hosts", "/etc/sysconfig/network",
+                 "/etc/mdadm.conf", "/etc/sysconfig/network",
                  "/etc/udev/rules.d/70-persistent-net.rules",
                  "/root/install.log", "/root/install.log.syslog",
                  "/etc/shadow", "/etc/shadow-", "/etc/gshadow"] + \
-- 
1.6.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux