From de35f4b62454d0c2c8b526e13a38059ffcdf11da Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Fri, 28 Jan 2022 20:13:41 -0300 Subject: [PATCH] fix(core): use `std::env::temp_dir` instead of fixed `/tmp` --- core/tauri-utils/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/tauri-utils/src/lib.rs b/core/tauri-utils/src/lib.rs index 597418b02..8486091fc 100644 --- a/core/tauri-utils/src/lib.rs +++ b/core/tauri-utils/src/lib.rs @@ -65,11 +65,15 @@ impl Default for Env { }; if env.appimage.is_some() || env.appdir.is_some() { // validate that we're actually running on an AppImage - // an AppImage is mounted to `/tmp/.mount_${appPrefix}${hash}` + // an AppImage is mounted to `/$TEMPDIR/.mount_${appPrefix}${hash}` // see https://github.com/AppImage/AppImageKit/blob/1681fd84dbe09c7d9b22e13cdb16ea601aa0ec47/src/runtime.c#L501 // note that it is safe to use `std::env::current_exe` here since we just loaded an AppImage. if !std::env::current_exe() - .map(|p| p.to_string_lossy().into_owned().starts_with("/tmp/.mount_")) + .map(|p| { + p.display() + .to_string() + .starts_with(&format!("{}/.mount_", std::env::temp_dir().display())) + }) .unwrap_or(true) { panic!("`APPDIR` or `APPIMAGE` environment variable found but this application was not detected as an AppImage; this might be a security issue.");