Flash via udisks2 on Linux instead of requiring root#14
Flash via udisks2 on Linux instead of requiring root#14justanotherariel wants to merge 5 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #14 +/- ##
==========================================
+ Coverage 89.52% 89.76% +0.24%
==========================================
Files 28 28
Lines 10887 11055 +168
Branches 82 82
==========================================
+ Hits 9747 9924 +177
+ Misses 1140 1131 -9
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 |
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 lint