[master/f21-branch][PATCH] Add some sanity checking to live payload

Vratislav Podzimek vpodzime at redhat.com
Fri Aug 8 13:19:31 UTC 2014


If mounting the install tree fails in the live payload it is a fatal error we
should report and terminate the installation. The same applies to an attempt to
install no data.

Related: rhbz#1127280
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 pyanaconda/packaging/livepayload.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/pyanaconda/packaging/livepayload.py b/pyanaconda/packaging/livepayload.py
index f5fb6a9..d6db00b 100644
--- a/pyanaconda/packaging/livepayload.py
+++ b/pyanaconda/packaging/livepayload.py
@@ -76,7 +76,9 @@ class LiveImagePayload(ImagePayload):
             exn = PayloadSetupError("%s is not a valid block device" % (self.data.method.partition,))
             if errorHandler.cb(exn) == ERROR_RAISE:
                 raise exn
-        blivet.util.mount(osimg.path, INSTALL_TREE, fstype="auto", options="ro")
+        rc = blivet.util.mount(osimg.path, INSTALL_TREE, fstype="auto", options="ro")
+        if rc != 0:
+            raise PayloadInstallError("Failed to mount the install tree")
 
         source = os.statvfs(INSTALL_TREE)
         self.source_size = source.f_frsize * (source.f_blocks - source.f_bfree)
@@ -110,6 +112,10 @@ class LiveImagePayload(ImagePayload):
 
     def install(self):
         """ Install the payload. """
+
+        if self.source_size <= 0:
+            raise PayloadInstallError("Nothing to install")
+
         self.pct_lock = Lock()
         self.pct = 0
         threadMgr.add(AnacondaThread(name=THREAD_LIVE_PROGRESS,
-- 
1.9.3



More information about the anaconda-patches mailing list