Skip to content

Commit

Permalink
storage: Always set config on cleartext block during mounting
Browse files Browse the repository at this point in the history
UDisks2 allows any block object to be used to update configuration
items for any other block, and the mounting dialog was abusing that
when mounting an encrypted filesystem: It would use the backing block
to update the fstab entries of the cleartext block. This works
perfectly fine, except that UDisks2 only guarantees proper
notification ordering for the block used to make the method call.

Thus, when calling UpdateConfiguration on the backing block, the
"Configuration" property of the cleartext block would not necessarily
be up-to-date yet when mount_at accesses it.
  • Loading branch information
mvollmer authored and jelly committed Mar 26, 2024
1 parent c3f99ce commit ec4538c
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions pkg/storaged/filesystem/mounting-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,18 @@ export function mounting_dialog(client, block, mode, forced_options, subvol) {
return Promise.resolve();
}

function maybe_unlock() {
async function maybe_unlock() {
const crypto = client.blocks_crypto[block.path];
if (mode == "mount" && crypto) {
return (unlock_with_type(client, block, passphrase, passphrase_type)
.catch(error => {
dlg.set_values({ needs_explicit_passphrase: true });
return Promise.reject(error);
}));
try {
await unlock_with_type(client, block, passphrase, passphrase_type);
return await client.wait_for(() => client.blocks_cleartext[block.path]);
} catch (error) {
dlg.set_values({ needs_explicit_passphrase: true });
throw error;
}
} else
return Promise.resolve();
return block;
}

function maybe_lock() {
Expand All @@ -275,14 +277,14 @@ export function mounting_dialog(client, block, mode, forced_options, subvol) {
return (reload_systemd()
.then(() => teardown_active_usage(client, usage))
.then(maybe_unlock)
.then(() => {
.then(content_block => {
if (!old_config && new_config)
return (block.AddConfigurationItem(new_config, {})
return (content_block.AddConfigurationItem(new_config, {})
.then(maybe_mount));
else if (old_config && !new_config)
return block.RemoveConfigurationItem(old_config, {});
return content_block.RemoveConfigurationItem(old_config, {});
else if (old_config && new_config)
return (block.UpdateConfigurationItem(old_config, new_config, {})
return (content_block.UpdateConfigurationItem(old_config, new_config, {})
.then(maybe_mount));
else if (new_config && !is_mounted(client, block))
return maybe_mount();
Expand Down

0 comments on commit ec4538c

Please sign in to comment.