feat(desktop): skip the privileged helper in non-tun proxy modes - #221
Merged
Conversation
Only tun mode needs the privileged data-path (a tun device + OS routing rewrite). Gate the startup helper on the saved proxy mode: a non-tun mode (proxy-only/system/pac) runs the data-path in-process and unprivileged — no pkexec prompt on Linux, no service install/connect (hence no UAC) on Windows — while tun keeps today's helper-backed bring-up. The saved mode is read as a bare `settings.proxyMode` field from app-state.json, defaulting to tun on any failure so a bad read never drops the helper for a tun user. The in-process platform is marked gated and refuses a live switch to tun with a restart-required error before any tun bring-up, so the UI shows an actionable `failed:<reason>`; the reverse (a helper-backed session running a non-tun mode) already works. Serialize the env-mutating tests behind a shared guard so the new gating test doesn't race the existing path-resolution tests over process-global KASUMI_* overrides.
17 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Skip the privileged data-path helper when the saved proxy mode doesn't need it. With
proxyMode=proxy-only/system/pac, the GUI now runs the data-path in-process and unprivileged: no pkexec prompt on Linux, no LocalSystem service install/connect (and thus no first-run UAC) on Windows.tun— the default, and the answer on any unreadable state — keeps today's helper-backed behaviour exactly.Builds on #220 (the helper hands its runtime files and the run-dir inodes to the GUI user), which makes alternating privileged/unprivileged data-path owners over the same paths safe.
Mechanics:
saved_proxy_mode()readssettings.proxyModeout of<datadir>/app-state.jsonas a bare field — deliberately not the fullAppStateschema/migration, so a legacy or foreign document still answers sanely. Any failure (paths, missing file, corrupt JSON, absent key, unknown value) →Tun, i.e. a bad read can never silently drop the helper for a tun user.build_platform: after the untouchedKASUMI_SKIP_ELEVATIONshort-circuit and before the per-OS client split, so one check covers both Linux and Windows arms.start_data_pathwithmode == tunon it fails up-front withfailed: tun mode needs an app restart (the privileged helper is not running)— before theconnectingstate blip and any tun bring-up — so the UI shows an actionable reason instead of a cryptic tun-creation error. The reverse direction needs nothing: a helper-backed session already serves every mode (the mode ridesStartDataPath), so switching away from tun applies on the next start without a restart.boot_initdir creation, test cores, subscriptions and status all ride the in-process platform unchanged (theKASUMI_SKIP_ELEVATIONpath has long proven the shape).Affected layer
frontend/— React Web UIcrates/·src-tauri/— Rust core / backend / Tauri desktopmodule/— Android installable zip (thin launcher over the Rust daemon)scripts/— build / release helpers.github/Verification
Rust (
crates/·src-tauri/):cargo fmt --all --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspace— one failure:net::tests::tcp_ping_fails_on_unreachable_host, the known environment flake (an active VPN tun on the dev machine captures the TEST-NET-1 connect); fails identically onmainNew tests: bare-field mode extraction (all four values; corrupt/absent/wrong-type/unknown → tun) and the gated refusal (tun → restart-required error +
failed:service state; non-tun passes the gate and fails later on the missing core binary, proving mode-selectivity).Checklist
module/bin/<abi>/,geoip/geosite, builtmodule/webroot/,src-tauri/gen/— all gitignored on purpose)frontend/src/generated/was regenerated from Rust, not hand-edited (untouched)i18n/en.tsand every locale file updated (no user-visible strings changed)kasumi-proxy,Kasumi Proxy, camelCase)Notes for reviewers
env_test_guard()mutex (poison-recovering): they flip process-globalKASUMI_*overrides, and the new integration test flaked once under full-workspace parallelism before the guard. Held only across the synchronous set→construct→remove window, dropped before any await.ServiceHandlewatch channel leaves that door open).