[PATCH 2/2] Don't use temporary file and move when writing out an ifcfg file
Brian C. Lane
bcl at redhat.com
Tue Sep 10 18:44:40 UTC 2013
On Tue, Sep 10, 2013 at 11:56:56AM +0200, Vratislav Podzimek wrote:
> 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
I think I'd rather see SimpleConfigFile.write gain an option to skip
using temporary files. eg.
def write(self, filename=None, use_tmp=True)
that capability may be useful to other callers in the future.
--
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 482 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/anaconda-patches/attachments/20130910/642287d9/attachment.sig>
More information about the anaconda-patches
mailing list