[PATCH 1/2 master] Don't fail on write of nonexisting IfcfgFile(SimpleConfigFile) (#849012, #849095)

Brian C. Lane bcl at redhat.com
Mon Aug 20 16:07:12 UTC 2012


On Mon, Aug 20, 2012 at 02:38:05PM +0200, Radek Vykydal wrote:
> Due to commit 16a7c6e7af3df4816323a007f785155d307869bf,
> SimpleConfigFile.write of nonexisting files is failling.
> ---
>  pyanaconda/simpleconfig.py |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/pyanaconda/simpleconfig.py b/pyanaconda/simpleconfig.py
> index db0dea2..9fb1289 100644
> --- a/pyanaconda/simpleconfig.py
> +++ b/pyanaconda/simpleconfig.py
> @@ -95,9 +95,12 @@ class SimpleConfigFile(object):
>          # Move the temporary file (with 0600 permissions) over the top of the
>          # original and preserve the original's permissions
>          filename = os.path.realpath(filename)
> -        m = os.stat(filename)
> +        if os.path.exists(filename):
> +            m = os.stat(filename).st_mode
> +        else:
> +            m = int('0100644', 8)
>          shutil.move(tmpf.name, filename)
> -        os.chmod(filename, m.st_mode)
> +        os.chmod(filename, m)
>  
>      def set(self, *args):
>          for key, value in args:
> -- 
> 1.7.4

Could you add a test for this as well? The simpleconfig tests are
actually working so it just needs a new one for this.

-- 
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/20120820/6f1f538c/attachment.sig>


More information about the anaconda-patches mailing list