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
  • Loading branch information
bcl committed Sep 29, 2014
1 parent e34747d commit 55134c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions pyanaconda/packaging/yumpayload.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,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
Original file line number Diff line number Diff line change
Expand Up @@ -2091,7 +2091,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 @@ -2359,6 +2360,8 @@ def _destroy_device(self, device):
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:
Expand All @@ -2375,6 +2378,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.removeEmptyExtendedPartitions()
Expand Down Expand Up @@ -2842,8 +2846,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)

def _do_autopart(self):
"""Helper function for on_create_clicked.
Expand Down

0 comments on commit 55134c1

Please sign in to comment.