[rhel7/master] Protect protected devices in custom spoke (#1052883)

Brian C. Lane bcl at redhat.com
Sat Sep 27 00:33:28 UTC 2014


A protected partition may be shown in custom, but it should not be
possible to remove it. This makes sure that the remove button is set to
the mountpoint's state when the page header is clicked.

Make sure the 'delete all' on other partitions of the disk don't delete
the protected partition by checking in _destroy_device, also exit early
if there was a failure, it doesn't seem like a good idea to continue
with the rest of the method if there was an error.

Also make sure the protected device cannot be resized by making the
_sizeEntry insensitive.

Resolves: rhbz#1052883
---
 pyanaconda/packaging/yumpayload.py | 3 +++
 pyanaconda/ui/gui/spokes/custom.py | 8 +++++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py
index 1516cbb..8efbc50 100644
--- a/pyanaconda/packaging/yumpayload.py
+++ b/pyanaconda/packaging/yumpayload.py
@@ -826,6 +826,9 @@ reposdir=%s
                     if not method.method:
                         method.method = "cdrom"
                     self._setUpMedia(self.install_device)
+
+                    # Make sure Blivet doesn't unmount it
+                    self.install_device.protected = True
                     url = "file://" + INSTALL_TREE
                 elif method.method == "cdrom":
                     raise PayloadSetupError("no usable optical media found")
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index e0566ef..60a1cff 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -2091,7 +2091,8 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
         # new devices that are not btrfs subvolumes.
         # Do this after the device type combo is set since
         # on_device_type_changed doesn't account for device existence.
-        fancy_set_sensitive(self._sizeEntry, device.resizable or (not device.exists and device.format.type != "btrfs"))
+        fancy_set_sensitive(self._sizeEntry, (device.resizable and not device.protected) \
+                            or (not device.exists and device.format.type != "btrfs"))
 
         if self._sizeEntry.get_sensitive():
             self._sizeEntry.props.has_tooltip = False
@@ -2359,6 +2360,8 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
         with ui_storage_logger():
             is_logical_partition = getattr(device, "isLogical", False)
             try:
+                if device.protected:
+                    raise StorageError("Device %s is protected" % device.name)
                 if device.isDisk:
                     self.__storage.initializeDisk(device)
                 elif device.direct and not device.isleaf:
@@ -2375,6 +2378,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
                 self.set_warning(_("Device removal request failed. Click "
                                    "for details."))
                 self.window.show_all()
+                return
             else:
                 if is_logical_partition:
                     self.__storage.removeEmptyExtendedPartitions()
@@ -2842,8 +2846,6 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
             # instead of device/mountpoint details.
             self._partitionsNotebook.set_current_page(NOTEBOOK_LABEL_PAGE)
             self._removeButton.set_sensitive(False)
-        else:
-            self._removeButton.set_sensitive(True)
 
     def _do_autopart(self):
         """Helper function for on_create_clicked.
-- 
1.9.3



More information about the anaconda-patches mailing list