[PATCH 2/2] Don't use temporary file and move when writing out an ifcfg file
Vratislav Podzimek
vpodzime at redhat.com
Tue Sep 10 09:56:56 UTC 2013
NetworkManager uses IN_CLOSE_WRITE inotify event which is not triggered if a new
file is moved to the place of the watched file. Also the SELinux context is
wrong when a file from /tmp is used to the /etc tree.
Related: rhbz#972362
Based on the patch from Hans de Goede <hdegoede at redhat.com>.
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
pyanaconda/simpleconfig.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/pyanaconda/simpleconfig.py b/pyanaconda/simpleconfig.py
index d0757cf..8d51db3 100644
--- a/pyanaconda/simpleconfig.py
+++ b/pyanaconda/simpleconfig.py
@@ -176,8 +176,6 @@ class IfcfgFile(SimpleConfigFile):
SimpleConfigFile.read(self, self.path)
return len(self.info)
- # ifcfg-rh is using inotify IN_CLOSE_WRITE event
- # so we don't use temporary file for new configuration.
def write(self, directory=None):
""" Writes values into ifcfg file.
"""
@@ -187,5 +185,8 @@ class IfcfgFile(SimpleConfigFile):
else:
path = os.path.join(directory, os.path.basename(self.path))
- SimpleConfigFile.write(self, path)
+ # ifcfg-rh is using inotify IN_CLOSE_WRITE event so we don't use
+ # temporary file for new configuration
+ with open(path, "w") as fobj:
+ fobj.write(str(self))
--
1.7.11.7
More information about the anaconda-patches
mailing list