Flash via udisks2 on Linux instead of requiring root - #14
Flash via udisks2 on Linux instead of requiring root#14justanotherariel wants to merge 13 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #14 +/- ##
==========================================
- Coverage 89.28% 89.08% -0.20%
==========================================
Files 31 31
Lines 10711 10833 +122
Branches 98 100 +2
==========================================
+ Hits 9563 9651 +88
- Misses 1148 1182 +34
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR changes Linux drive flashing to go through the udisks2 D-Bus API (via zbus) instead of requiring the entire Tauri app to run as root. Resolving, unmounting, and opening the target device now happen through udisks2, so a single polkit prompt authorizes the operation. This also fixes a WebKitGTK rendering bug where running the whole app as root broke the asset-protocol sandbox and left the UI unstyled.
Changes:
- Replace root-based
OpenOptionsdevice access on Linux with udisks2 D-Bus proxies (Manager.ResolveDevice,Block.OpenDevice,Filesystem.Unmount), opening the fd withO_SYNCand dropping the page cache before verify. - Add a
DiskServiceUnavailableerror variant plus amap_udisks_errorhelper that classifies D-Bus faults into unavailable/permission/busy/not-found errors, and surface these inflash_image. - Merge write and verify into a single blocking task reusing one device handle, and update dependencies (
zbus,libc) and tests accordingly.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/hai-core/src/disk_writer.rs | Core rewrite of the Linux flashing path to use udisks2/zbus; adds proxies, error mapping, partition-name helper, and updated tests |
| crates/hai-core/src/error.rs | Adds DiskServiceUnavailable variant and its display test |
| crates/hai-desktop/src/commands.rs | Maps VerificationFailed/DiskServiceUnavailable to user-facing messages in flash_image |
| crates/hai-core/Cargo.toml | Adds Linux-only zbus/libc dependencies |
| Cargo.toml | Declares workspace zbus (v5, tokio) and libc versions |
| Cargo.lock | Records resolved dependency graph changes |
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
|
MacOS CI job seems to be flaky. Rerunning it fixed it. Added some tests. |
Until now it was stable. So not sure if your changes introduced these flakiness but I will hold this PR back until we have the artefacts and co so we are sure everything is working as expected |
There was a problem hiding this comment.
🟡 Changes recommended
Unmount errors are discarded and partitions above 16 remain mounted, causing incorrect cancellation behavior or failed exclusive access.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (1)
crates/hai-core/src/disk_writer.rs:750
- Correct “ot” to “to.”
// O_SYNC: so each write reaches the card before returning ot keep the
- Files reviewed: 6/7 changed files
- Comments generated: 4
- Review effort level: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
Device eligibility can be classified incorrectly, and verification disconnects are reported as write failures.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 6/7 changed files
- Comments generated: 4
- Review effort level: Balanced
Description
Flashes drives on Linux through the udisks2 D-Bus API instead of requiring the whole app to run as root. The device is resolved, unmounted, and opened via udisks2, so a single polkit prompt grants access for everything. Adds a
DiskServiceUnavailableerror for when udisks2 isn't installed/running.Beyond the cleaner UX, this fixes UI rendering glitches when flashing: writing previously needed the whole Tauri app to run as root, and WebKitGTK's web/network process can't initialize its bubblewrap sandbox as uid 0, so subresources served over Tauri's asset protocol (CSS/JS/images) failed to load and the UI rendered unstyled/broken.
Type of Change
Related Issues
Testing
Screenshots
Checklist
cargo fmtandnpm run lintOnly merge after reviewing the whole stack