fix(core): block the wizard if app has been translocated on macOS. Fix #844

This commit is contained in:
Federico Terzi 2021-11-05 21:11:14 +01:00
parent fcc0a4ee50
commit 93ce220b62
2 changed files with 15 additions and 1 deletions

View File

@ -72,7 +72,7 @@ fn launcher_main(args: CliModuleArgs) -> i32 {
let is_welcome_page_enabled = !preferences.has_completed_wizard(); let is_welcome_page_enabled = !preferences.has_completed_wizard();
let is_move_bundle_page_enabled = false; // TODO let is_move_bundle_page_enabled = crate::cli::util::is_subject_to_app_translocation_on_macos();
let is_legacy_version_page_enabled = util::is_legacy_version_running(&paths.runtime); let is_legacy_version_page_enabled = util::is_legacy_version_running(&paths.runtime);
let runtime_dir_clone = paths.runtime.clone(); let runtime_dir_clone = paths.runtime.clone();

View File

@ -69,3 +69,17 @@ pub fn prevent_running_as_root_on_macos() {
pub fn prevent_running_as_root_on_macos() { pub fn prevent_running_as_root_on_macos() {
// Do nothing on other platforms // Do nothing on other platforms
} }
// This is needed to make sure the app is NOT subject to "App Translocation" on
// macOS, which would make Espanso misbehave on some circumstances.
// For more information, see: https://github.com/federico-terzi/espanso/issues/844
pub fn is_subject_to_app_translocation_on_macos() -> bool {
if !cfg!(target_os = "macos") {
return false;
}
let exec_path = std::env::current_exe().expect("unable to extract executable path");
let exec_path = exec_path.to_string_lossy();
exec_path.contains("/private/")
}