Skip to content

Commit

Permalink
WIP - teardown before locking
Browse files Browse the repository at this point in the history
We should have done this anyway, and now we need it to get rid of the
tmp mountpoint.
  • Loading branch information
mvollmer committed Aug 28, 2024
1 parent 8b2e738 commit 37ba9ce
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
31 changes: 28 additions & 3 deletions pkg/storaged/crypto/actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 2 additions & 8 deletions test/verify/check-storage-anaconda
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions test/verify/check-storage-luks
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ class TestStorageLuks(storagelib.StorageCase):

# Lock it
b.click(self.card_button("Unformatted data", "Lock"))
self.confirm()
b.wait_visible(self.card("Locked data"))

# Make it readonly
Expand Down

0 comments on commit 37ba9ce

Please sign in to comment.