Updater v0.8.3: Polkit detection enhance#532
Conversation
…d Cargo.lock to latest stable
avifenesh
left a comment
There was a problem hiding this comment.
This is an auto review done by revuto.
One finding on the new test's env-var handling. The dependency bumps (Cargo.toml/Cargo.lock are consistent), the has_graphical_session → has_interactive_graphical_session rename (no stragglers), and the relaxed polkit gate (has_user_session_bus_for_polkit) all look correct.
| let original_dbus_session_bus_address = std::env::var_os("DBUS_SESSION_BUS_ADDRESS"); | ||
| let original_xdg_runtime_dir = std::env::var_os("XDG_RUNTIME_DIR"); | ||
|
|
||
| std::env::remove_var("DISPLAY"); |
There was a problem hiding this comment.
This is an auto review done by revuto.
This test mutates process-wide env vars (DISPLAY, WAYLAND_DISPLAY, DBUS_SESSION_BUS_ADDRESS, XDG_RUNTIME_DIR) and restores them with manual save/restore code at the tail (lines 2809-2828). If the assert!(has_user_session_bus_for_polkit()) on line 2807 panics, the restore block never runs, leaking the removed DISPLAY/WAYLAND_DISPLAY and the faked DBUS_SESSION_BUS_ADDRESS/XDG_RUNTIME_DIR into other env-dependent tests in the crate (e.g. the feature_picker tests that read DISPLAY/WAYLAND_DISPLAY, and has_interactive_graphical_session callers). env_lock() only serializes access — it does not roll back leaked state — so a single failure here can cascade into misleading failures elsewhere.
Use a Drop-based RAII guard so restoration happens on every exit path including panic. The crate already has this exact pattern in codex_cli.rs (EnvRestoreGuard::capture(&[...])); reusing/lifting that (e.g. into test_util) would keep restoration panic-safe and drop the ~20 lines of manual restore here.
|
Thanks, the runtime change looks good and the updater tests pass locally. One thing to fix before merge: the new test mutates process-wide env vars and restores them manually after the assertion. If the assertion panics, the restore block will not run and the modified env can leak into later tests. Please use a |
This pull request updates dependencies and refines how the application detects graphical and user session environments, especially for polkit (policy kit) support. The main focus is on improving session detection logic, clarifying function responsibilities, and adding targeted tests.
Dependency updates:
Cargo.toml, includingchrono,clap,notify-rust,reqwest,serde_json,semver, andtokiofor bug fixes and compatibility.Session detection improvements:
has_graphical_sessiontohas_interactive_graphical_sessionto clarify its purpose, and updated all call sites to use the new name.has_user_session_bus_for_polkit, which checks for a user session bus environment and is now used in polkit agent detection.Testing:
has_user_session_bus_for_polkitreturns true when the appropriate environment variables are set, even without a display.