diff --git a/blivetgui/blivet_utils.py b/blivetgui/blivet_utils.py index 6c9fbd2e..54302cdb 100644 --- a/blivetgui/blivet_utils.py +++ b/blivetgui/blivet_utils.py @@ -1493,7 +1493,18 @@ def create_disk_label(self, blivet_device, label_type): return ProxyDataContainer(success=True, actions=actions, message=None, exception=None, traceback=None) - def luks_decrypt(self, blivet_device, passphrase): + def unlock_device(self, blivet_device, passphrase): + """ Unlock/open this LUKS/dm-crypt encrypted device + """ + + if blivet_device.format.type == "luks": + return self._luks_unlock(blivet_device, passphrase) + elif blivet_device.format.type == "stratis": + return self._stratis_unlock(blivet_device, passphrase) + else: + return False + + def _luks_unlock(self, blivet_device, passphrase): """ Decrypt selected luks device :param blivet_device: device to decrypt @@ -1524,6 +1535,30 @@ def luks_decrypt(self, blivet_device, passphrase): self.storage.devicetree.populate() return True + def _stratis_unlock(self, blivet_device, passphrase): + """ Unlock Stratis pool on this device + + :param blivet_device: stratis blockdev with a locked pool + :type blivet_device: StorageDevice + :param passphrase: passphrase + :type passphrase: str + + """ + + log_msg = "Opening Stratis device '%s':\n" % blivet_device + log_utils_call(log=self.log, message=log_msg, + user_input={"device": blivet_device}) + + blivet_device.format.passphrase = passphrase + + try: + blivet_device.format.unlock_pool() + except blivet.errors.StratisError: + return False + else: + self.storage.devicetree.populate() + return True + def blivet_cancel_actions(self, actions): """ Cancel scheduled actions """ diff --git a/blivetgui/blivetgui.py b/blivetgui/blivetgui.py index 515a19eb..6a2c2e90 100644 --- a/blivetgui/blivetgui.py +++ b/blivetgui/blivetgui.py @@ -714,7 +714,7 @@ def decrypt_device(self, _widget=None): response = self.run_dialog(dialog) if response: - ret = self.client.remote_call("luks_decrypt", self.list_partitions.selected_partition[0], response) + ret = self.client.remote_call("unlock_device", self.list_partitions.selected_partition[0], response) if not ret: msg = _("Unlocking failed. Are you sure provided password is correct?") diff --git a/blivetgui/list_partitions.py b/blivetgui/list_partitions.py index 49d73fda..11db8fb0 100644 --- a/blivetgui/list_partitions.py +++ b/blivetgui/list_partitions.py @@ -326,7 +326,8 @@ def activate_action_buttons(self, selected_device): if device.format: if device.format.type == "luks" and not device.format.status and device.format.exists: self.blivet_gui.activate_device_actions(["decrypt"]) - + elif device.format.type == "stratis" and device.format.locked_pool and not device.children: + self.blivet_gui.activate_device_actions(["decrypt"]) elif device.format.mountable and device.format.system_mountpoint: self.blivet_gui.activate_device_actions(["unmount"])