Skip to content

Feature: Re-lock LUKS volumes unlocked by the app on unmount and eject - #206

Merged
MemerGamer merged 2 commits into
mainfrom
feat/luks-relock
Nov 2, 2026
Merged

MemerGamer merged 2 commits into
mainfrom
feat/luks-relock

Conversation

@MemerGamer

Copy link
Copy Markdown
Owner

Resolved / Related Issues

Steps used to test these changes

  1. Ran build/fetch-uno-wayland.sh, then built Files.Platform.Linux with -warnaserror and Files.App (net10.0-desktop, Release, Win32 compat off): 0 errors.
  2. Built Files.Platform.Tests with -warnaserror and ran it: 1477 total, 1466 passed, 0 failed, 11 skipped (Xvfb-dependent, inconclusive in this environment).
  3. New fake-UDisks2 tests cover: lock after unmount, lock after eject, externally unlocked volume not locked, Lock failure does not fail the unmount, failed unmount does not lock.
  4. Not tested against a real LUKS device or real display.

Design

  • UDisks2UnlockTracker (in UDisks2Model.cs) records cleartext devices unlocked through Encrypted.Unlock by the service; already-unlocked volumes are never tracked.
  • After Filesystem.Unmount succeeds, the service calls Encrypted.Lock on the crypto backing device and forgets the entry. Eject goes through the same unmount path.
  • Lock failures are logged (Debug.WriteLine) and do not fail the unmount; no new UI or result types.

🤖 Generated with Claude Code

MemerGamer and others added 2 commits November 2, 2026 16:52
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The cleartext device has no drive of its own, so ejecting it only unmounted
and locked but never ejected or powered off the drive. Cleartext devices now
use their container's drive. Also relock when the volume was already
unmounted (including on eject), and only lock the container the app unlocked.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@MemerGamer

Copy link
Copy Markdown
Owner Author

Review: fixed-and-approve (pushed a fix commit).

Bug found (eject path): the app ejects by the mounted cleartext volume id (DriveHelpers.Linux.cs EjectDeviceAsync -> volumes.EjectAsync(volume.Id)). Real UDisks2 cleartext block devices have Drive "/", so BuildVolumes gave them DriveId null and UnmountDriveAsync returned no drive: EjectAsync unmounted and relocked but never called Drive.Eject/PowerOff, and the CanEject notification was skipped. Fix: a cleartext device now inherits its container's drive (UDisks2Model.cs DrivePathOf), so siblings, eject and power-off work.

Other fixes:

  • Relock also runs when the volume is already unmounted (NotMounted path in UnmountAsync, and unmounted siblings during eject/power-off), otherwise the device stays open and power-off fails.
  • Tracker now maps cleartext -> container; relock only proceeds if the current crypto backing matches, so a reused dm device name unlocked elsewhere is not locked. Thread safety was fine (lock on the set).

CRLF is intact on all changed files. Added tests for eject order (Lock before Drive.Eject), unmounted eject, NotMounted relock, drive inheritance, tracker, reused name. Platform tests: 1471 passed, 11 skipped (no Xvfb), 0 failed, -warnaserror clean; Files.App net10.0-desktop Release (FilesWin32Compat=false) builds with 0 errors.

🤖 Generated with Claude Code

@MemerGamer
MemerGamer merged commit e744653 into main Nov 2, 2026
2 checks passed
@MemerGamer
MemerGamer deleted the feat/luks-relock branch November 2, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant