Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Fedora SELinux Support (http://www.linux-archive.org/fedora-selinux-support/)
-   -   (take II) Don't deactivate active device before running nm-c-e (#608773) (http://www.linux-archive.org/fedora-selinux-support/392458-take-ii-dont-deactivate-active-device-before-running-nm-c-e-608773-a.html)

Radek Vykydal 06-29-2010 12:00 PM

(take II) Don't deactivate active device before running nm-c-e (#608773)
 
ifcfg-rh is watching IN_CLOSE_WRITE event so we should
write directly into ifcfg file when updating it instead
of creating temporary, removing original and moving temporary.
---
simpleconfig.py | 18 +++---------------
1 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/simpleconfig.py b/simpleconfig.py
index 23fcaaa..3bc8d0b 100644
--- a/simpleconfig.py
+++ b/simpleconfig.py
@@ -16,7 +16,6 @@

import string
import os
-import tempfile
import shutil

# use our own ASCII only uppercase function to avoid locale issues
@@ -124,9 +123,8 @@ class IfcfgFile(SimpleConfigFile):

return len(self.info)

- # This method has to write file in a particular
- # way so that ifcfg-rh's inotify mechanism triggeres
- # TODORV: check that it is still true.
+ # ifcfg-rh is using inotify IN_CLOSE_WRITE event
+ # so we don't use temporary file for new configuration.
def write(self, dir=None):
"""Writes values into ifcfg file."""

@@ -135,15 +133,5 @@ class IfcfgFile(SimpleConfigFile):
else:
path = os.path.join(dir, os.path.basename(self.path))

- fd, newifcfg = tempfile.mkstemp(prefix="ifcfg-%s" % self.iface, text=False)
- os.write(fd, self.__str__())
- os.close(fd)
-
- os.chmod(newifcfg, 0644)
- try:
- os.remove(path)
- except OSError, e:
- if e.errno != 2:
- raise
- shutil.move(newifcfg, path)
+ SimpleConfigFile.write(self, path)

--
1.6.0.6

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


All times are GMT. The time now is 10:34 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.