--- kickstart.py | 4 +++- network.py | 57 ++++++++++++++++++++++++++++++++++++++------------------- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/kickstart.py b/kickstart.py index a233e07..2278b7e 100644 --- a/kickstart.py +++ b/kickstart.py @@ -594,7 +594,9 @@ class NetworkData(commands.network.F8_NetworkData): if self.essid: dev.set(("essid", self.essid)) if self.wepkey: - dev.set(("wepkey", self.wepkey)) + dev.set(("defaultkey", "1")) + dev.wepkey = self.wepkey + dev.writeWepkeyFile() if self.hostname != "": anaconda.network.setHostname(self.hostname) diff --git a/network.py b/network.py index bf600a4..9ad9338 100644 --- a/network.py +++ b/network.py @@ -33,6 +33,7 @@ import struct import os import time import dbus +import tempfile from flags import flags from simpleconfig import IfcfgFile @@ -276,14 +277,16 @@ class NetworkDevice(IfcfgFile): def __init__(self, dir, iface, logfile='/tmp/ifcfg.log'): IfcfgFile.__init__(self, dir, iface) self.logfile = logfile + self.description = "" if iface.startswith('ctc'): self.info["TYPE"] = "CTC" - self.description = "" + self.wepkey = "" def clear(self): IfcfgFile.clear(self) if self.iface.startswith('ctc'): self.info["TYPE"] = "CTC" + self.wepkey = "" def __str__(self): s = "" @@ -314,6 +317,29 @@ class NetworkDevice(IfcfgFile): def writeIfcfgFile(self, dir=None): IfcfgFile.write(self, dir) + def writeWepkeyFile(self, dir=None, overwrite=True): + if not self.wepkey: + return False + if not dir: + dir = os.path.dirname(self.path) + keyfile = os.path.join(dir, "keys-%s" % self.iface) + + if not overwrite and os.path.isfile(keyfile): + return False + + fd, newifcfg = tempfile.mkstemp(prefix="keys-%s" % self.iface, text=False) + os.write(fd, "KEY1=%s\n" % self.wepkey) + os.close(fd) + + os.chmod(newifcfg, 0644) + try: + os.remove(keyfile) + except OSError, e: + if e.errno != 2: + raise + shutil.move(newifcfg, keyfile) + + def log(self, header="\n"): lf = open(self.logfile, 'a') lf.write(header) @@ -559,6 +585,7 @@ class Network: iutil.mkdirChain(netscripts) # /etc/sysconfig/network-scripts/ifcfg-* + # /etc/sysconfig/network-scripts/keys-* for dev in devices: device = dev.get('DEVICE') @@ -593,24 +620,16 @@ class Network: dev.writeIfcfgFile(netscripts) dev.log_file("===== write\n") - # TODORV: handle keys files properly (they will be written - # by nm-c-e, stage1 if we support it and perhaps ks? - need - # to check. Particularly ensure their copying to /mnt/sysimage. - # XXX: is this necessary with NetworkManager? - # handle the keys* files if we have those - if dev.get("KEY"): - cfgfile = "%s/keys-%s" % (netscripts, device,) - if not instPath == '' and os.path.isfile(cfgfile): - continue - - newkey = "%s/keys-%s.new" % (netscripts, device,) - f = open(newkey, "w") - f.write("KEY=%s\n" % (dev.get('KEY'),)) - f.close() - os.chmod(newkey, 0600) - - destkey = "%s/keys-%s" % (netscripts, device,) - shutil.move(newkey, destkey) + # This is not needed for anaconda environment, because writing + # out keys is handled by stage1, kickstart, or nm-c-e. + # For installed system (instPath == /mnt/sysimage), the files + # should just be copied, not written again as the info we have + # in Network object will not reflect what nm-c-e + # could have changed (it has wider set of options like wpa, etc...) + # and it isn't worth to implement all this possibilities + # in Network object to be able to keep it updated. + if dev.wepkey: + dev.writeWepkeyFile(dir=netscripts, overwrite=False) # /etc/dhclient-DEVICE.conf dhclientconf = '/etc/dhclient-' + device + '.conf' -- 1.6.0.6 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list