From 1b7cf70106ac4e42dac1c5682ce359bd96ef5e03 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Mon, 1 Jun 2015 16:25:22 -0700 Subject: [PATCH] Protect protected devices in custom spoke (#1052883) 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 (cherry picked from commit 55134c131e8ba9df80337bf5092e78ee3d318f4d) Related: rhbz#1196721 --- pyanaconda/packaging/__init__.py | 3 +++ pyanaconda/ui/gui/spokes/custom.py | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py index 4ed4e977421..07e68bb6574 100644 --- a/pyanaconda/packaging/__init__.py +++ b/pyanaconda/packaging/__init__.py @@ -980,6 +980,9 @@ def _setupInstallDevice(self, storage, checkmount): 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 bc3518fdfa4..1a987646798 100644 --- a/pyanaconda/ui/gui/spokes/custom.py +++ b/pyanaconda/ui/gui/spokes/custom.py @@ -1438,7 +1438,8 @@ def _populate_right_side(self, selector): # 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 @@ -1720,6 +1721,8 @@ def _destroy_device(self, device): self.clear_errors() is_logical_partition = getattr(device, "isLogical", False) try: + if device.protected: + raise StorageError("Device %s is protected" % device.name) if device.isDisk: self._storage_playground.initializeDisk(device) elif device.direct and not device.isleaf: @@ -1736,6 +1739,7 @@ def _destroy_device(self, device): self.set_warning(_("Device removal request failed. Click " "for details.")) self.window.show_all() + return else: if is_logical_partition: self._storage_playground.removeEmptyExtendedPartitions() @@ -2198,8 +2202,6 @@ def on_page_clicked(self, page, mountpointToShow=None): # instead of device/mountpoint details. self._partitionsNotebook.set_current_page(NOTEBOOK_LABEL_PAGE) self._removeButton.set_sensitive(False) - else: - self._removeButton.set_sensitive(True) @ui_storage_logged def _do_autopart(self):