[blivet rhel7/master] escrow: make sure the output directory exists (#1026653)

Brian C. Lane bcl at redhat.com
Mon Jan 27 19:09:39 UTC 2014


On Mon, Jan 27, 2014 at 12:29:53PM -0500, Will Woods wrote:
> writeEscrowPackets() gets called from turnOnFilesystems() immediately
> after it mounts all the filesystems. So under normal circumstances, when
> we run writeEscrowPackets() the ROOT_PATH is completely empty.
> 
> So when we do device.format.escrow(ROOT_PATH + "/root",...) that path
> doesn't exist yet, and so it ends up raising IOError when it tries to
> open a file there.
> 
> The simple solution is to ensure the path exists before we pass it to
> device.format.escrow().
> 
> (This won't interfere with the installer; when RPM tries to create
> /root in the course of installing the "filesystem" package it should
> happily just chmod the existing directory to the proper mode and leave
> the contents as-is.)
> ---
>  blivet/__init__.py | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/blivet/__init__.py b/blivet/__init__.py
> index 95b29a7..b05e73d 100644
> --- a/blivet/__init__.py
> +++ b/blivet/__init__.py
> @@ -201,11 +201,15 @@ def writeEscrowPackets(storage):
>      nss.nss.nss_init_nodb() # Does nothing if NSS is already initialized
>  
>      backupPassphrase = generateBackupPassphrase()
> +
>      try:
> +        escrowDir = ROOT_PATH + "/root"
> +        log.debug("escrow: writing escrow packets to %s", escrowDir)
> +        util.makedirs(escrowDir)
>          for device in escrowDevices:
>              log.debug("escrow: device %s: %s" %
>                        (repr(device.path), repr(device.format.type)))
> -            device.format.escrow(ROOT_PATH + "/root",
> +            device.format.escrow(escrowDir,
>                                   backupPassphrase)
>  
>      except (IOError, RuntimeError) as e:
> -- 
> 1.8.5.3

Ack

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)


More information about the anaconda-patches mailing list