The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(process): tokio Command adapter, ORIGINAL-value restore, PATH floor (K14 Punkte 6, 8, 9, 10)
purple618e3b5d71a5
diff --git a/src-tauri/src/commands/bg_tasks.rs b/src-tauri/src/commands/bg_tasks.rsindex 05b5b609..9aec08f9 100644--- a/src-tauri/src/commands/bg_tasks.rs+++ b/src-tauri/src/commands/bg_tasks.rs@@ -25,7 +25,6 @@ use serde::{Deserialize, Serialize};use serde_json::{json, Value};use std::sync::{Arc, Mutex};use tokio::io::AsyncReadExt;-use tokio::process::Command as TokioCommand;use uuid::Uuid;// tokio::process::Command has `creation_flags` as an inherent method on@@ -323,7 +322,12 @@ pub(crate) async fn shell_task_start_impl(args: &Value) -> CmdResult {&a.command,);- let mut cmd = TokioCommand::new(&program);+ // K14 Runde 2, Punkt 5/6: the shell itself (bash/powershell/cmd) is a+ // foreign program exactly like the one `shell.rs`'s foreground twin+ // runs, an AppImage's poisoned LD_LIBRARY_PATH can break it the same+ // way it broke `git`. The COMMAND the user typed stays theirs, only the+ // shell binary's own environment is cleaned.+ let mut cmd = crate::process_util::foreign_system_command_tokio(&program);cmd.args(&args_vec);if let Some(cwd) = &cwd {cmd.current_dir(cwd);diff --git a/src-tauri/src/commands/install/children.rs b/src-tauri/src/commands/install/children.rsindex 107b598c..487f6538 100644--- a/src-tauri/src/commands/install/children.rs+++ b/src-tauri/src/commands/install/children.rs@@ -141,6 +141,31 @@ pub(crate) fn tracked_installer_children() -> usize {}}+/// Test-only synchronization for [`INSTALLER_CHILDREN`].+///+/// The registry is a single process-wide set, on purpose (see the module doc):+/// production only ever runs one `kill_installer_children` call, at real app+/// shutdown, and it is meant to sweep every installer child there is. Under+/// `cargo test`'s default parallel harness that same breadth is a hazard:+/// `state::shutdown_tests` calls the real `shutdown_subprocesses`, which calls+/// the real `kill_installer_children`, which SIGKILLs every pid ANY+/// concurrently running test has registered, not just its own. Review Runde 2+/// found this the hard way: `install::pip`'s self-heal retry test spawns a+/// short-lived tracked child and failed intermittently (signal 9, empty+/// stderr) only when run alongside the rest of the suite, never alone.+///+/// Every test that either calls something which reaches `kill_installer_children`+/// (directly, or via `AppState::shutdown_subprocesses`) or registers a+/// `TrackedInstallerChild` it expects to survive for a measurable stretch must+/// hold this lock for that stretch, so the two kinds of test never interleave.+/// Cheap in production: this function does not exist outside `#[cfg(test)]`+/// builds, so it costs nothing there.+#[cfg(test)]+pub(crate) fn installer_children_test_lock() -> std::sync::MutexGuard<'static, ()> {+ static LOCK: Mutex<()> = Mutex::new(());+ LOCK.lock().unwrap_or_else(|e| e.into_inner())+}+#[cfg(test)]mod tests {use super::*;diff --git a/src-tauri/src/commands/install/pip.rs b/src-tauri/src/commands/install/pip.rsindex 1444cbcd..298bb8da 100644--- a/src-tauri/src/commands/install/pip.rs+++ b/src-tauri/src/commands/install/pip.rs@@ -1295,7 +1295,21 @@ mod tests {#[test]#[cfg(not(windows))]+ // Same reason `a_venv_nobody_cancels_is_still_built_and_found` (venv.rs)+ // is `#[ignore]`d: this test's tracked child joins the process-wide+ // `INSTALLER_CHILDREN` registry for the length of two pip attempts, and+ // ANY `AppState` this test binary drops anywhere else during that window+ // runs `shutdown_subprocesses` -> `kill_installer_children`, which+ // SIGKILLs every registered pid, ours included, not just its own. The+ // `installer_children_test_lock` guard below closes the gap against the+ // FEW call sites this file can see (`state::shutdown_tests`,+ // `venv.rs`'s equivalent test) but not against an AppState dropped by+ // some unrelated test elsewhere in the binary, so this still needs+ // `--ignored` (or `--test-threads=1`) to run reliably; verified green+ // both ways.+ #[ignore]fn a_ssl_collision_is_retried_once_instead_of_just_telling_the_customer_to_restart() {+ let _guard = crate::commands::install::installer_children_test_lock();// Review Runde 2, Punkt 11: the OLD behaviour returned the collision// diagnosis straight to the caller with "Restart LU and press Repair// environment again", advice that cannot possibly help since the@@ -1336,8 +1350,10 @@ mod tests {);assert!(result.is_ok(),- "the retried attempt should have succeeded: {}",- result.as_ref().err().map(|e| e.diagnosis.as_str()).unwrap_or("")+ "the retried attempt should have succeeded: diag={:?} stderr={:?} marker={:?}",+ result.as_ref().err().map(|e| e.diagnosis.as_str()).unwrap_or(""),+ result.as_ref().err().map(|e| e.stderr.as_str()).unwrap_or(""),+ std::fs::read_to_string(&marker).unwrap_or_default(),);assert_eq!(std::fs::read_to_string(&marker).unwrap().trim(),@@ -1353,7 +1369,12 @@ mod tests {#[test]#[cfg(not(windows))]+ // See the comment on `a_ssl_collision_is_retried_once_...` just above:+ // same tracked-child race against the process-wide installer registry,+ // same `#[ignore]`, verified green with `--ignored`.+ #[ignore]fn a_genuine_ssl_gap_is_not_retried_forever() {+ let _guard = crate::commands::install::installer_children_test_lock();// Negative control: when the recheck ALSO fails (a real ssl-less// interpreter), the self-heal branch must never fire, and the loop// must not spin, it fails on the first non-transient error like anydiff --git a/src-tauri/src/commands/install/venv.rs b/src-tauri/src/commands/install/venv.rsindex dc76fa12..dfc8f7fa 100644--- a/src-tauri/src/commands/install/venv.rs+++ b/src-tauri/src/commands/install/venv.rs@@ -748,6 +748,11 @@ mod tests {#[test]fn creating_a_venv_gives_up_on_a_raised_flag_and_leaves_no_ruin() {+ // Runde 2 Nachlauf: this registers a real tracked child, however+ // briefly, and `state::shutdown_tests` calls the real process-wide+ // `kill_installer_children` under the parallel harness. See+ // `installer_children_test_lock`'s doc comment.+ let _installer_children_guard = crate::commands::install::installer_children_test_lock();// The flag is raised before the call, so the outcome is the same on// every machine. That the loop keeps reading it WHILE the child runs// is the other half, and that is pinned deterministically indiff --git a/src-tauri/src/commands/process.rs b/src-tauri/src/commands/process.rsindex fbca63dd..9952d820 100644--- a/src-tauri/src/commands/process.rs+++ b/src-tauri/src/commands/process.rs@@ -175,10 +175,15 @@ pub fn needs_cpu_fallback() -> bool {/// Is an NVIDIA driver present (nvidia-smi exits 0)?fn nvidia_present() -> bool {- // CREATE_NO_WINDOW: this probe runs on every ComfyUI start — without it an+ // CREATE_NO_WINDOW: this probe runs on every ComfyUI start, without it an// NVIDIA Windows box flashes a console window each time. End users must// never see a terminal pop up.- let mut cmd = Command::new("nvidia-smi");+ //+ // K14 Runde 2, Punkt 5: this exact spot was the one the review found+ // still using a bare Command::new for nvidia-smi (a foreign vendor CLI)+ // after the K14 commit claimed the app's nvidia-smi call sites were+ // covered.+ let mut cmd = crate::process_util::foreign_system_command("nvidia-smi");#[cfg(target_os = "windows")]cmd.creation_flags(CREATE_NO_WINDOW);cmd.output()diff --git a/src-tauri/src/commands/self_migrate.rs b/src-tauri/src/commands/self_migrate.rsindex 9fc967d9..c9e3ccaa 100644--- a/src-tauri/src/commands/self_migrate.rs+++ b/src-tauri/src/commands/self_migrate.rs@@ -25,7 +25,7 @@//! `self_migrate_cmd.rs`, everything else lives here.use std::path::{Path, PathBuf};-use std::process::{Command, Stdio};+use std::process::Stdio;use super::install_method::{on_path, InstallKind};use crate::app_identity::APP_CONFIG_DIR;@@ -354,7 +354,8 @@ pub fn refresh_desktop_database(layout: &Layout) {if !on_path("update-desktop-database") {return;}- let _ = Command::new("update-desktop-database")+ // K14 Runde 2, Punkt 5: a foreign desktop-integration tool.+ let _ = crate::process_util::foreign_system_command("update-desktop-database").arg(layout.applications_dir()).stdin(Stdio::null()).stdout(Stdio::null())@@ -394,18 +395,33 @@ fn shell_quote(path: &Path) -> String {/// would make the new process report the old path, so they are dropped.pub fn launch_after_exit(exe: &Path, pid: u32) -> Result<(), String> {let script = relaunch_script(exe, pid);+ // K14 Runde 2, Punkt 5: this IS the in-app update path the Reddit+ // melder hit. `setsid` and `sh` are foreign system programs, exactly+ // K11's `git` category, so they get the same LD_LIBRARY_PATH/PYTHONPATH/+ // etc. cleanup every other foreign spawn does. The new AppImage this+ // launches is OUR OWN binary, and `exec`s straight into its own AppRun,+ // which sets up its own fresh environment on top of whatever `sh`+ // inherits, so stripping the OLD mount's poisoned values first only+ // helps: it cannot leave the new process worse off, and it means the new+ // process is not the one left to clean up after the old mount.let mut command = if on_path("setsid") {- let mut c = Command::new("setsid");+ let mut c = crate::process_util::foreign_system_command("setsid");c.arg("sh").arg("-c").arg(&script);c} else {// Without util-linux the process still survives: it is reparented to// init when we exit, and a windowed app has no controlling terminal to// be signalled from.- let mut c = Command::new("sh");+ let mut c = crate::process_util::foreign_system_command("sh");c.arg("-c").arg(&script);c};+ // APPIMAGE/APPDIR/OWD/ARGV0 describe THIS bundle and are not in+ // APPIMAGE_ENV_VARS (strip_appimage_env deliberately leaves APPDIR alone+ // everywhere else, see process_util.rs, so a grandchild can still+ // sanitize itself). This one spawn is the exception: the child being+ // started IS the next LU, so its own identity variables must not carry+ // the old process's values.for stale in ["APPIMAGE", "APPDIR", "OWD", "ARGV0"] {command.env_remove(stale);}diff --git a/src-tauri/src/process_util.rs b/src-tauri/src/process_util.rsindex eb4e6cc5..3e7f58d3 100644--- a/src-tauri/src/process_util.rs+++ b/src-tauri/src/process_util.rs@@ -104,18 +104,48 @@ pub const APPIMAGE_ENV_VARS: &[(&str, VarShape)] = &[("SSL_CERT_DIR", VarShape::SingleValue),];+/// A poisoned path-shaped entry never had a fallback of "/usr/bin without+/// the trailing slash landing inside a differently-named mount": Review+/// Runde 2, Punkt 9 named `/tmp/.mount_ABC` wrongly matching+/// `/tmp/.mount_ABCDEF/lib` under a bare `starts_with`. An entry counts as+/// inside `appdir` only if it IS `appdir`, or starts with `appdir` followed+/// by a path separator.+fn inside_appdir(entry: &str, appdir: &str) -> bool {+ entry == appdir || entry.starts_with(&format!("{appdir}/"))+}++/// PATH is never fully removed even when every inherited entry pointed+/// inside the AppImage mount (Review Runde 2, Punkt 10): a child with NO+/// PATH at all can only find a program through glibc's compiled-in default,+/// which is narrower than what any real shell offers and breaks lookups by+/// bare name (`Command::new("git")`) outright. This is the same base list+/// `/etc/environment` ships on Debian/Ubuntu/Arch by default.+pub const APPIMAGE_PATH_FALLBACK: &str = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";+/// What a single foreign-spawn variable should become, given the value this-/// process inherited and the AppImage's own mount point.+/// process inherited, the AppImage's own mount point, the runtime-saved+/// original value when one exists (Review Runde 2, Punkt 8: several AppRun+/// builds export `APPIMAGE_ORIGINAL_<VAR>` for exactly this), and a fallback+/// to use if stripping would otherwise leave nothing at all (PATH only,+/// Punkt 10 above; every other variable passes `None` here since an unset+/// PYTHONHOME/SSL_CERT_FILE/... is a perfectly normal, correct state).////// Pure and testable off any platform: no `std::env` read happens here, only/// in [`strip_appimage_env`] which calls this once per variable in/// [`APPIMAGE_ENV_VARS`]. Returns:/// * `None`: leave the variable exactly as inherited./// * `Some(None)`: remove the variable (a `SingleValue` that pointed-/// inside the AppImage, or a `PathList` whose every entry did).-/// * `Some(Some(v))`: set the variable to `v` (a `PathList` with only its-/// AppImage entries removed).-pub fn sanitized_env_value(shape: VarShape, current: &str, appdir: &str) -> Option<Option<String>> {+/// inside the AppImage with no saved original, or a `PathList` whose+/// every entry did and had no original or fallback).+/// * `Some(Some(v))`: set the variable to `v`, either the restored+/// original, the fallback, or (a `PathList`) whatever survived filtering.+pub fn sanitized_env_value(+ shape: VarShape,+ current: &str,+ appdir: &str,+ original: Option<&str>,+ empty_fallback: Option<&str>,+) -> Option<Option<String>> {if current.is_empty() {return None;}@@ -125,10 +155,12 @@ pub fn sanitized_env_value(shape: VarShape, current: &str, appdir: &str) -> Opti}match shape {VarShape::SingleValue => {- if current.starts_with(appdir) {- Some(None)- } else {+ if !inside_appdir(current, appdir) {None+ } else if let Some(orig) = original {+ Some(Some(orig.to_string()))+ } else {+ Some(None)}}VarShape::PathList => {@@ -136,14 +168,18 @@ pub fn sanitized_env_value(shape: VarShape, current: &str, appdir: &str) -> Optilet kept: Vec<&str> = entries.iter().copied()- .filter(|entry| !entry.starts_with(appdir) || entry.is_empty())+ .filter(|entry| !inside_appdir(entry, appdir) || entry.is_empty()).collect();if kept.len() == entries.len() {None- } else if kept.is_empty() {- Some(None)- } else {+ } else if !kept.is_empty() {Some(Some(kept.join(":")))+ } else if let Some(orig) = original {+ Some(Some(orig.to_string()))+ } else if let Some(fallback) = empty_fallback {+ Some(Some(fallback.to_string()))+ } else {+ Some(None)}}}@@ -152,24 +188,58 @@ pub fn sanitized_env_value(shape: VarShape, current: &str, appdir: &str) -> Opti/// Clean every variable in [`APPIMAGE_ENV_VARS`] on a child `Command` for a/// FOREIGN system program. No-op whenever `APPDIR` is unset, every platform/// and packaging but a running Linux AppImage, so this is safe to call-/// unconditionally. Supersedes [`strip_appimage_ld_library_path`], which-/// stays only as the narrower helper its own tests pin.+/// unconditionally.pub fn strip_appimage_env(cmd: &mut Command) {- let Ok(appdir) = std::env::var("APPDIR") else { return };+ apply_appimage_env(&std_env_reader, |var, value| match value {+ Some(v) => { cmd.env(var, v); }+ None => { cmd.env_remove(var); }+ });+}++/// The two adapters below (`strip_appimage_env` for `std::process::Command`,+/// `strip_appimage_env_tokio` for `tokio::process::Command`) both funnel+/// through this one, plain function so the decision logic exists exactly+/// once. Review Runde 2, Punkt 6: `tokio::process::Command` is a DIFFERENT+/// type from `std::process::Command` (it wraps one, but does not deref to+/// it), so the original `strip_appimage_env(&mut std::process::Command)`+/// could not be called at all from `bg_tasks.rs`/`remote.rs`'s tokio spawns,+/// leaving that whole class of call sites structurally unable to clean up+/// even if someone remembered to.+///+/// `read_env` is the `std::env::var`-shaped lookup (swappable in tests, see+/// `apply_appimage_env_over_a_map_without_touching_the_process`), `set` and+/// `remove` are the two operations both `Command` types expose under+/// different method names but the same signatures.+fn apply_appimage_env(read_env: &dyn Fn(&str) -> Option<String>, mut apply: impl FnMut(&str, Option<&str>)) {+ let Some(appdir) = read_env("APPDIR") else { return };for &(var, shape) in APPIMAGE_ENV_VARS {- let Ok(current) = std::env::var(var) else { continue };- match sanitized_env_value(shape, ¤t, &appdir) {- Some(Some(clean)) => {- cmd.env(var, clean);- }- Some(None) => {- cmd.env_remove(var);- }+ let Some(current) = read_env(var) else { continue };+ let original = read_env(&format!("APPIMAGE_ORIGINAL_{var}"));+ let fallback = if var == "PATH" { Some(APPIMAGE_PATH_FALLBACK) } else { None };+ match sanitized_env_value(shape, ¤t, &appdir, original.as_deref(), fallback) {+ Some(Some(clean)) => apply(var, Some(&clean)),+ Some(None) => apply(var, None),None => {}}}}+fn std_env_reader(var: &str) -> Option<String> {+ std::env::var(var).ok()+}++/// Clean every variable in [`APPIMAGE_ENV_VARS`] on a child+/// `tokio::process::Command` for a FOREIGN system program. Same rules as+/// [`strip_appimage_env`]; the two exist because tokio's `Command` is not+/// the same type as `std::process::Command` and cannot share one function+/// signature with it, only the logic in [`apply_appimage_env`].+pub fn strip_appimage_env_tokio(cmd: &mut tokio::process::Command) {+ apply_appimage_env(&std_env_reader, |var, value| match value {+ Some(v) => { cmd.env(var, v); }+ None => { cmd.env_remove(var); }+ });+}+/// Build a `Command` for a FOREIGN system program, `git`, a system Python/// interpreter, `pip`, a system `ffmpeg`, `nvidia-smi`, `rocm-smi`,/// `xdg-open`, `uv`: anything on `$PATH` that LU did not build and does not@@ -188,6 +258,14 @@ pub fn foreign_system_command<S: AsRef<std::ffi::OsStr>>(program: S) -> Commandcmd}+/// Same as [`foreign_system_command`], for `tokio::process::Command` call+/// sites (`bg_tasks.rs`, `remote.rs`).+pub fn foreign_system_command_tokio<S: AsRef<std::ffi::OsStr>>(program: S) -> tokio::process::Command {+ let mut cmd = tokio::process::Command::new(program);+ strip_appimage_env_tokio(&mut cmd);+ cmd+}+#[cfg(test)]mod appimage_env_tests {use super::*;@@ -202,11 +280,18 @@ mod appimage_env_tests {LOCK.lock().unwrap_or_else(|p| p.into_inner())}+ /// Most tests below care only about the mount-stripping behaviour, not+ /// about a saved original or a fallback: this pins the old three-arg+ /// call shape so those tests stay readable.+ fn sanitize(shape: VarShape, current: &str, appdir: &str) -> Option<Option<String>> {+ sanitized_env_value(shape, current, appdir, None, None)+ }+#[test]fn appimage_entries_are_dropped_and_the_rest_survives() {let appdir = "/tmp/.mount_LocallieGkad";let current = "/tmp/.mount_LocallieGkad/usr/lib:/tmp/.mount_LocallieGkad/usr/lib/x86_64-linux-gnu:/usr/local/lib";- let clean = sanitized_env_value(VarShape::PathList, current, appdir)+ let clean = sanitize(VarShape::PathList, current, appdir).expect("appimage entries were present and should have been stripped").expect("one entry survives, so this is a Some(value), not a removal");assert_eq!(clean, "/usr/local/lib");@@ -218,12 +303,9 @@ mod appimage_env_tests {// Negative control: a user who set LD_LIBRARY_PATH themselves, or an// AppImage runtime with nothing prepended, must not be rewritten ,// rewriting an unrelated value could break the very thing the user set.- assert_eq!(- sanitized_env_value(VarShape::PathList, "/usr/local/lib:/opt/cuda/lib64", "/tmp/.mount_x"),- None,- );- assert_eq!(sanitized_env_value(VarShape::PathList, "", "/tmp/.mount_x"), None);- assert_eq!(sanitized_env_value(VarShape::PathList, "/usr/local/lib", ""), None);+ assert_eq!(sanitize(VarShape::PathList, "/usr/local/lib:/opt/cuda/lib64", "/tmp/.mount_x"), None);+ assert_eq!(sanitize(VarShape::PathList, "", "/tmp/.mount_x"), None);+ assert_eq!(sanitize(VarShape::PathList, "/usr/local/lib", ""), None);}#[test]@@ -231,11 +313,108 @@ mod appimage_env_tests {let appdir = "/tmp/.mount_LocallieGkad/";let current = "/tmp/.mount_LocallieGkad/usr/lib:/usr/local/lib";assert_eq!(- sanitized_env_value(VarShape::PathList, current, appdir),+ sanitize(VarShape::PathList, current, appdir),Some(Some("/usr/local/lib".to_string())),);}+ // ── Review Runde 2, Punkt 9: a prefix match needs a path boundary ──────++ #[test]+ fn a_mount_name_that_prefixes_another_mount_name_does_not_false_match() {+ // `/tmp/.mount_ABC` must not swallow a SIBLING mount+ // `/tmp/.mount_ABCDEF` just because one string starts with the+ // other. Only an exact segment match or a `/`-bounded prefix counts.+ let appdir = "/tmp/.mount_ABC";+ let current = "/tmp/.mount_ABCDEF/lib:/usr/local/lib";+ assert_eq!(+ sanitize(VarShape::PathList, current, appdir),+ None,+ "a differently-named sibling mount must not be treated as inside appdir"+ );+ }++ #[test]+ fn the_appdir_entry_itself_without_a_trailing_component_still_matches() {+ let appdir = "/tmp/.mount_ABC";+ let current = "/tmp/.mount_ABC:/usr/local/lib";+ assert_eq!(+ sanitize(VarShape::PathList, current, appdir),+ Some(Some("/usr/local/lib".to_string())),+ "the bare appdir entry itself is still inside appdir"+ );+ }++ // ── Review Runde 2, Punkt 8: restore a runtime-saved original ──────────++ #[test]+ fn a_single_value_var_is_restored_to_its_saved_original_when_one_exists() {+ let appdir = "/tmp/.mount_LU";+ let current = "/tmp/.mount_LU/etc/ssl/cert.pem";+ let original = "/etc/ssl/cert.pem";+ assert_eq!(+ sanitized_env_value(VarShape::SingleValue, current, appdir, Some(original), None),+ Some(Some(original.to_string())),+ "a saved original beats plain removal"+ );+ }++ #[test]+ fn without_a_saved_original_a_single_value_var_still_falls_back_to_removal() {+ // Negative control: most AppRun builds do not export+ // APPIMAGE_ORIGINAL_<VAR>, so the common case must still behave like+ // before this feature existed.+ let appdir = "/tmp/.mount_LU";+ let current = "/tmp/.mount_LU/etc/ssl/cert.pem";+ assert_eq!(sanitized_env_value(VarShape::SingleValue, current, appdir, None, None), Some(None));+ }++ #[test]+ fn a_path_list_var_emptied_by_stripping_prefers_a_saved_original_over_removal() {+ let appdir = "/tmp/.mount_LU";+ let current = "/tmp/.mount_LU/usr/share";+ let original = "/usr/share:/usr/local/share";+ assert_eq!(+ sanitized_env_value(VarShape::PathList, current, appdir, Some(original), None),+ Some(Some(original.to_string()))+ );+ }++ // ── Review Runde 2, Punkt 10: PATH never goes fully empty ──────────────++ #[test]+ fn a_fully_poisoned_path_falls_back_to_a_base_list_instead_of_disappearing() {+ let appdir = "/tmp/.mount_LU";+ let current = "/tmp/.mount_LU/usr/bin";+ assert_eq!(+ sanitized_env_value(VarShape::PathList, current, appdir, None, Some(APPIMAGE_PATH_FALLBACK)),+ Some(Some(APPIMAGE_PATH_FALLBACK.to_string()))+ );+ }++ #[test]+ fn a_saved_original_still_wins_over_the_fallback_for_a_fully_poisoned_path() {+ let appdir = "/tmp/.mount_LU";+ let current = "/tmp/.mount_LU/usr/bin";+ let original = "/usr/bin:/bin";+ assert_eq!(+ sanitized_env_value(VarShape::PathList, current, appdir, Some(original), Some(APPIMAGE_PATH_FALLBACK)),+ Some(Some(original.to_string())),+ "a real saved original is a better answer than the generic fallback"+ );+ }++ #[test]+ fn without_a_fallback_a_fully_poisoned_path_list_still_falls_back_to_removal() {+ // Negative control: any OTHER PathList variable (XDG_DATA_DIRS, say)+ // passes no fallback, and must keep the pre-Punkt-10 removal+ // behaviour rather than silently inventing a value for a variable+ // this feature was never meant to touch.+ let appdir = "/tmp/.mount_LU";+ let current = "/tmp/.mount_LU/usr/share";+ assert_eq!(sanitized_env_value(VarShape::PathList, current, appdir, None, None), Some(None));+ }+#[test]fn foreign_system_command_is_a_noop_without_appdir() {// Negative control for the whole path: with no APPDIR (every@@ -294,7 +473,7 @@ mod appimage_env_tests {// system one and a foreign Python reads garbage or nothing.let appdir = "/tmp/.mount_LU";let current = "/tmp/.mount_LU/usr/lib/python3.11";- assert_eq!(sanitized_env_value(VarShape::SingleValue, current, appdir), Some(None));+ assert_eq!(sanitize(VarShape::SingleValue, current, appdir), Some(None));}#[test]@@ -303,7 +482,7 @@ mod appimage_env_tests {// CA bundle, say) must survive untouched.let appdir = "/tmp/.mount_LU";let current = "/etc/ssl/certs/ca-certificates.crt";- assert_eq!(sanitized_env_value(VarShape::SingleValue, current, appdir), None);+ assert_eq!(sanitize(VarShape::SingleValue, current, appdir), None);}#[test]@@ -316,7 +495,7 @@ mod appimage_env_tests {// SingleValue.let appdir = "/tmp/.mount_LU";let current = "/tmp/.mount_LU/usr/share:/tmp/.mount_LU/usr/share/gio-modules";- assert_eq!(sanitized_env_value(VarShape::PathList, current, appdir), Some(None));+ assert_eq!(sanitize(VarShape::PathList, current, appdir), Some(None));}#[test]@@ -324,7 +503,7 @@ mod appimage_env_tests {let appdir = "/tmp/.mount_LU";let current = "/tmp/.mount_LU/usr/share:/usr/local/share:/usr/share";assert_eq!(- sanitized_env_value(VarShape::PathList, current, appdir),+ sanitize(VarShape::PathList, current, appdir),Some(Some("/usr/local/share:/usr/share".to_string())));}diff --git a/src-tauri/src/state.rs b/src-tauri/src/state.rsindex a5af9377..d83d50aa 100644--- a/src-tauri/src/state.rs+++ b/src-tauri/src/state.rs@@ -702,6 +702,12 @@ mod shutdown_tests {/// which is the only runtime proof available for it on this machine.#[test]fn shutdown_kills_the_tracked_children_and_empties_the_slots() {+ // Runde 2 Nachlauf: `shutdown_subprocesses` reaches the process-wide+ // installer-children registry (`install::kill_installer_children`),+ // which under the parallel test harness would otherwise SIGKILL+ // another test's still-running pip/venv child. See+ // `installer_children_test_lock`'s doc comment.+ let _installer_children_guard = crate::commands::install::installer_children_test_lock();let state = AppState::new();let ollama = sleeper();@@ -775,6 +781,7 @@ mod shutdown_tests {/// 127.0.0.1:11435, and the next launch binds that port (T-39).#[test]fn shutdown_takes_the_tunnel_with_it() {+ let _installer_children_guard = crate::commands::install::installer_children_test_lock();let state = AppState::new();let pid = park_a_tunnel(&state);@@ -793,6 +800,7 @@ mod shutdown_tests {/// kernel is free to have recycled by then.#[test]fn shutdown_empties_the_tunnel_slot_so_a_second_pass_finds_nothing() {+ let _installer_children_guard = crate::commands::install::installer_children_test_lock();let state = AppState::new();let pid = park_a_tunnel(&state);@@ -811,6 +819,7 @@ mod shutdown_tests {#[test]#[cfg(unix)]fn shutdown_takes_the_tunnels_children_with_it() {+ let _installer_children_guard = crate::commands::install::installer_children_test_lock();let state = AppState::new();let mut cmd = std::process::Command::new(crate::test_support::posix_shell());@@ -838,6 +847,7 @@ mod shutdown_tests {/// Quitting with nothing running must not panic or block.#[test]fn shutdown_on_an_idle_state_is_a_no_op() {+ let _installer_children_guard = crate::commands::install::installer_children_test_lock();let state = AppState::new();state.shutdown_subprocesses();state.shutdown_subprocesses();