Skip to content

Commit

Permalink
Protect protected devices in custom spoke (#1052883)
Browse files Browse the repository at this point in the history
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 55134c1)

Related: rhbz#1196721
  • Loading branch information
bcl committed Jun 2, 2015
1 parent cca497c commit 1b7cf70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions pyanaconda/packaging/__init__.py
Expand Up @@ -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")
Expand Down
8 changes: 5 additions & 3 deletions pyanaconda/ui/gui/spokes/custom.py
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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()
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 1b7cf70

Please sign in to comment.