summaryrefslogtreecommitdiffstats
path: root/network.py
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2009-03-24 16:37:01 -1000
committerDavid Cantrell <dcantrell@redhat.com>2009-03-30 09:42:55 -1000
commitc1aaab41558216ea1ba16400aaad60657fa76dae (patch)
tree7a6df610dcb46a23aa4997631bfee8691da0044a /network.py
parent6f1dd2061e5700c873a6b95127f7f8087aa69634 (diff)
downloadanaconda-c1aaab41558216ea1ba16400aaad60657fa76dae.tar.gz
anaconda-c1aaab41558216ea1ba16400aaad60657fa76dae.tar.xz
anaconda-c1aaab41558216ea1ba16400aaad60657fa76dae.zip
Do not write /etc/hosts since setup owns that now (#491808)
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.
Diffstat (limited to 'network.py')
-rw-r--r--network.py61
1 files changed, 15 insertions, 46 deletions
diff --git a/network.py b/network.py
index 5dc9060f0..e9ba2bc8c 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]