From 17feda5cb3a61e956800d9030ee4fa7e480613c1 Mon Sep 17 00:00:00 2001 From: hinto-janaiyo Date: Thu, 22 Dec 2022 11:03:38 -0500 Subject: [PATCH] macos: warn user if gupax is in [/private] directory macOS moves "dangerous" applications into a read-only [/private] filesystem. This messes up with the updater and default P2Pool and XMRig paths. If [/private] is detected, show a panic screen upon Gupax startup telling the user to move it to [/Applications]. This _seems_ to make macOS relax a little (after an arbitrary amount of time...) --- Cargo.lock | 119 ++++++++++-------- Cargo.toml | 4 +- src/main.rs | 8 ++ src/update.rs | 5 + utils/package.sh | 7 +- .../Gupax.app/Contents/MacOS/{Gupax => gupax} | 0 .../Contents/MacOS}/p2pool/p2pool | 0 .../Contents/MacOS}/xmrig/xmrig | 0 8 files changed, 85 insertions(+), 58 deletions(-) rename utils/skel/macos/Gupax.app/Contents/MacOS/{Gupax => gupax} (100%) rename utils/skel/macos/{ => Gupax.app/Contents/MacOS}/p2pool/p2pool (100%) rename utils/skel/macos/{ => Gupax.app/Contents/MacOS}/xmrig/xmrig (100%) diff --git a/Cargo.lock b/Cargo.lock index 5650957..34c816f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,49 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "Gupax" -version = "1.0.0" -dependencies = [ - "anyhow", - "arti-client", - "arti-hyper", - "bytes", - "dirs", - "eframe", - "egui", - "egui_extras", - "env_logger 0.9.3", - "figment", - "flate2", - "hyper", - "hyper-tls", - "image", - "is_elevated", - "log", - "num-format", - "num_cpus", - "portable-pty", - "rand 0.8.5", - "regex", - "rfd", - "serde", - "serde_json", - "static_vcruntime", - "sudo", - "sysinfo", - "tar", - "tls-api", - "tls-api-native-tls", - "tokio", - "toml", - "tor-rtcompat", - "walkdir", - "winres", - "zeroize", - "zip", -] - [[package]] name = "ab_glyph" version = "0.2.18" @@ -330,7 +287,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", "winapi", ] @@ -1839,6 +1796,49 @@ dependencies = [ "system-deps", ] +[[package]] +name = "gupax" +version = "1.0.0" +dependencies = [ + "anyhow", + "arti-client", + "arti-hyper", + "bytes", + "dirs", + "eframe", + "egui", + "egui_extras", + "env_logger 0.9.3", + "figment", + "flate2", + "hyper", + "hyper-tls", + "image", + "is_elevated", + "log", + "num-format", + "num_cpus", + "portable-pty", + "rand 0.8.5", + "regex", + "rfd", + "serde", + "serde_json", + "static_vcruntime", + "sudo", + "sysinfo", + "tar", + "tls-api", + "tls-api-native-tls", + "tokio", + "toml", + "tor-rtcompat", + "walkdir", + "winres", + "zeroize", + "zip", +] + [[package]] name = "half" version = "2.1.0" @@ -1881,6 +1881,15 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + [[package]] name = "hex" version = "0.4.3" @@ -2178,9 +2187,9 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "libc" -version = "0.2.138" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "libloading" @@ -2587,11 +2596,11 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi", + "hermit-abi 0.2.6", "libc", ] @@ -2668,9 +2677,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.44" +version = "0.10.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29d971fd5722fec23977260f6e81aa67d2f22cadbdc2aa049f1022d9a3be1566" +checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" dependencies = [ "bitflags", "cfg-if", @@ -2709,9 +2718,9 @@ dependencies = [ [[package]] name = "openssl-sys" -version = "0.9.79" +version = "0.9.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5454462c0eced1e97f2ec09036abc8da362e66802f66fd20f86854d9d8cbcbc4" +checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" dependencies = [ "autocfg", "cc", @@ -3003,9 +3012,9 @@ dependencies = [ [[package]] name = "proc-macro-hack" -version = "0.5.19" +version = "0.5.20+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" +checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" diff --git a/Cargo.toml b/Cargo.toml index 5fed009..b963cb0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "Gupax" +name = "gupax" version = "1.0.0" authors = ["hinto-janaiyo "] description = "GUI for P2Pool+XMRig" @@ -77,5 +77,7 @@ static_vcruntime = "2.0" # For macOS build (cargo-bundle) [package.metadata.bundle] +name = "Gupax" identifier = "com.github.hinto-janaiyo.gupax" icon = ["images/icons/icon@2x.png"] +category = "public.app-category.utilities" diff --git a/src/main.rs b/src/main.rs index 48b00a9..479542d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -416,6 +416,14 @@ impl App { app.error_state.set(format!("Gupax was launched as: [{:?}]\nPlease launch Gupax with regular user permissions.", id), ErrorFerris::Panic, ErrorButtons::Quit); } + // macOS re-locates "dangerous" applications into some read-only "/private" directory. + // It _seems_ to be fixed by moving [Gupax.app] into "/Applications". + // So, detect if we are in in "/private" and warn the user. + #[cfg(target_os = "macos")] + if app.exe.starts_with("/private") { + app.error_state.set(format!("macOS thinks Gupax is a virus!\n(macOS has relocated Gupax for security reasons)\n\nThe directory: [{}]\nSince this is a private read-only directory, it causes issues with updates and correctly locating P2Pool/XMRig. Please move Gupax into the [Applications] directory, this lets macOS relax a little.\n", app.exe), ErrorFerris::Panic, ErrorButtons::Quit); + } + app } } diff --git a/src/update.rs b/src/update.rs index 58a36b7..356e638 100644 --- a/src/update.rs +++ b/src/update.rs @@ -119,6 +119,11 @@ const XMRIG_BINARY: &str = "xmrig.exe"; #[cfg(target_family = "unix")] const XMRIG_BINARY: &str = "xmrig"; +#[cfg(target_os = "windows")] +const ACCEPTABLE_GUPAX: [&str; 3] = ["GUPAX.exe", "Gupax.exe", "gupax.exe"]; +#[cfg(target_family = "unix")] +const ACCEPTABLE_GUPAX: [&str; 3] = ["GUPAX", "Gupax", "gupax"]; + #[cfg(target_os = "windows")] const ACCEPTABLE_XMRIG: [&str; 4] = ["XMRIG.exe", "XMRig.exe", "Xmrig.exe", "xmrig.exe"]; #[cfg(target_family = "unix")] diff --git a/utils/package.sh b/utils/package.sh index e88640b..080eaf0 100755 --- a/utils/package.sh +++ b/utils/package.sh @@ -40,12 +40,15 @@ cd skel; check "CD into skel" # and that the naming schemes are correct title "Linux folder check" [[ -f linux/gupax ]]; check "linux/gupax" +[[ -f linux/Gupax.AppImage ]]; check "linux/Gupax.AppImage" +OUTPUT=$(cat linux/Gupax.AppImage) +[[ $OUTPUT = "./gupax" ]]; check "linux/Gupax.AppImage = ./gupax" [[ -f linux/p2pool/p2pool ]]; check "linux/p2pool/p2pool" [[ -f linux/xmrig/xmrig ]]; check "linux/xmrig/xmrig" title "macOS folder check" [[ -d macos/Gupax.app ]]; check "macos/Gupax.app" -[[ -f macos/p2pool/p2pool ]]; check "macos/p2pool/p2pool" -[[ -f macos/xmrig/xmrig ]]; check "macos/xmrig/xmrig" +[[ -f macos/Gupax.app/Contents/MacOS/p2pool/p2pool ]]; check "macos/p2pool/p2pool" +[[ -f macos/Gupax.app/Contents/MacOS/xmrig/xmrig ]]; check "macos/xmrig/xmrig" title "Windows folder check" [[ -f windows/Gupax.exe ]]; check "windows/Gupax.exe" [[ -f windows/P2Pool/p2pool.exe ]]; check "windows/P2Pool/p2pool.exe" diff --git a/utils/skel/macos/Gupax.app/Contents/MacOS/Gupax b/utils/skel/macos/Gupax.app/Contents/MacOS/gupax similarity index 100% rename from utils/skel/macos/Gupax.app/Contents/MacOS/Gupax rename to utils/skel/macos/Gupax.app/Contents/MacOS/gupax diff --git a/utils/skel/macos/p2pool/p2pool b/utils/skel/macos/Gupax.app/Contents/MacOS/p2pool/p2pool similarity index 100% rename from utils/skel/macos/p2pool/p2pool rename to utils/skel/macos/Gupax.app/Contents/MacOS/p2pool/p2pool diff --git a/utils/skel/macos/xmrig/xmrig b/utils/skel/macos/Gupax.app/Contents/MacOS/xmrig/xmrig similarity index 100% rename from utils/skel/macos/xmrig/xmrig rename to utils/skel/macos/Gupax.app/Contents/MacOS/xmrig/xmrig