From 2062f54078159e866f3ba6ce8318c4bb19a5827d Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Wed, 28 Aug 2024 10:28:01 +0300 Subject: [PATCH] WIP - teardown before locking We should have done this anyway, and now we need it to get rid of the tmp mountpoint. --- pkg/storaged/crypto/actions.jsx | 31 +++++++++++++++++++++++++++--- test/verify/check-storage-anaconda | 10 ++-------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/pkg/storaged/crypto/actions.jsx b/pkg/storaged/crypto/actions.jsx index ad7a8ec19ef..31c1727ed33 100644 --- a/pkg/storaged/crypto/actions.jsx +++ b/pkg/storaged/crypto/actions.jsx @@ -21,8 +21,8 @@ import cockpit from "cockpit"; import client from "../client"; import { get_existing_passphrase, unlock_with_type } from "./keyslots.jsx"; -import { set_crypto_auto_option } from "../utils.js"; -import { dialog_open, PassInput } from "../dialog.jsx"; +import { set_crypto_auto_option, get_active_usage, teardown_active_usage, block_name } from "../utils.js"; +import { dialog_open, PassInput, init_teardown_usage, TeardownMessage, BlockingMessage } from "../dialog.jsx"; const _ = cockpit.gettext; @@ -63,7 +63,32 @@ export function lock(block) { if (!crypto) return; - return crypto.Lock({}).then(() => set_crypto_auto_option(block, false)); + const name = block_name(block); + const usage = get_active_usage(client, block.path, _("lock")); + + if (usage.Blocking) { + dialog_open({ + Title: cockpit.format(_("$0 is in use"), name), + Body: BlockingMessage(usage) + }); + return; + } + + dialog_open({ + Title: cockpit.format(_("Lock $0?"), name), + Teardown: TeardownMessage(usage), + Action: { + Title: _("Lock"), + action: async function () { + await teardown_active_usage(client, usage); + await crypto.Lock({}); + await set_crypto_auto_option(block, false); + } + }, + Inits: [ + init_teardown_usage(client, usage) + ] + }); } export function std_lock_action(backing_block, content_block) { diff --git a/test/verify/check-storage-anaconda b/test/verify/check-storage-anaconda index 79331969985..48b38f90b5c 100755 --- a/test/verify/check-storage-anaconda +++ b/test/verify/check-storage-anaconda @@ -283,11 +283,6 @@ class TestStorageAnaconda(storagelib.StorageCase): self.dialog_apply() self.dialog_wait_close() - # Mount so that we can create subvolumes - b.wait_text(self.card_row_col("Storage", 1, 3), "btrfs filesystem (encrypted)") - self.click_dropdown(self.card_row("Storage", location="/mnt/butter"), "Mount") - self.dialog({}) - # Create two subvolumes self.click_dropdown(self.card_row("Storage", location="/mnt/butter"), "Create subvolume") self.dialog_wait_open() @@ -306,11 +301,10 @@ class TestStorageAnaconda(storagelib.StorageCase): self.dialog_apply() self.dialog_wait_close() - # Unmount and lock, mount point exporting should still work + # Lock, mount point exporting should still work - self.click_dropdown(self.card_row("Storage", location="/mnt/butter"), "Unmount") - self.dialog({}) self.click_dropdown(self.card_row("Storage", name=disk), "Lock") + self.confirm() b.wait_text(self.card_row_col("Storage", 1, 3), "Locked data (encrypted)") self.expectExportedDevice(disk,