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...)
This commit is contained in:
hinto-janaiyo 2022-12-22 11:03:38 -05:00
parent f37fb0c589
commit 17feda5cb3
No known key found for this signature in database
GPG key ID: B1C5A64B80691E45
8 changed files with 85 additions and 58 deletions

119
Cargo.lock generated
View file

@ -2,49 +2,6 @@
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3 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]] [[package]]
name = "ab_glyph" name = "ab_glyph"
version = "0.2.18" version = "0.2.18"
@ -330,7 +287,7 @@ version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [ dependencies = [
"hermit-abi", "hermit-abi 0.1.19",
"libc", "libc",
"winapi", "winapi",
] ]
@ -1839,6 +1796,49 @@ dependencies = [
"system-deps", "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]] [[package]]
name = "half" name = "half"
version = "2.1.0" version = "2.1.0"
@ -1881,6 +1881,15 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "hermit-abi"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "hex" name = "hex"
version = "0.4.3" version = "0.4.3"
@ -2178,9 +2187,9 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.138" version = "0.2.139"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
[[package]] [[package]]
name = "libloading" name = "libloading"
@ -2587,11 +2596,11 @@ dependencies = [
[[package]] [[package]]
name = "num_cpus" name = "num_cpus"
version = "1.14.0" version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b"
dependencies = [ dependencies = [
"hermit-abi", "hermit-abi 0.2.6",
"libc", "libc",
] ]
@ -2668,9 +2677,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]] [[package]]
name = "openssl" name = "openssl"
version = "0.10.44" version = "0.10.45"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29d971fd5722fec23977260f6e81aa67d2f22cadbdc2aa049f1022d9a3be1566" checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cfg-if", "cfg-if",
@ -2709,9 +2718,9 @@ dependencies = [
[[package]] [[package]]
name = "openssl-sys" name = "openssl-sys"
version = "0.9.79" version = "0.9.80"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5454462c0eced1e97f2ec09036abc8da362e66802f66fd20f86854d9d8cbcbc4" checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cc", "cc",
@ -3003,9 +3012,9 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro-hack" name = "proc-macro-hack"
version = "0.5.19" version = "0.5.20+deprecated"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"

View file

@ -1,5 +1,5 @@
[package] [package]
name = "Gupax" name = "gupax"
version = "1.0.0" version = "1.0.0"
authors = ["hinto-janaiyo <hinto.janaiyo@protonmail.com>"] authors = ["hinto-janaiyo <hinto.janaiyo@protonmail.com>"]
description = "GUI for P2Pool+XMRig" description = "GUI for P2Pool+XMRig"
@ -77,5 +77,7 @@ static_vcruntime = "2.0"
# For macOS build (cargo-bundle) # For macOS build (cargo-bundle)
[package.metadata.bundle] [package.metadata.bundle]
name = "Gupax"
identifier = "com.github.hinto-janaiyo.gupax" identifier = "com.github.hinto-janaiyo.gupax"
icon = ["images/icons/icon@2x.png"] icon = ["images/icons/icon@2x.png"]
category = "public.app-category.utilities"

View file

@ -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); 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 app
} }
} }

View file

@ -119,6 +119,11 @@ const XMRIG_BINARY: &str = "xmrig.exe";
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]
const XMRIG_BINARY: &str = "xmrig"; 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")] #[cfg(target_os = "windows")]
const ACCEPTABLE_XMRIG: [&str; 4] = ["XMRIG.exe", "XMRig.exe", "Xmrig.exe", "xmrig.exe"]; const ACCEPTABLE_XMRIG: [&str; 4] = ["XMRIG.exe", "XMRig.exe", "Xmrig.exe", "xmrig.exe"];
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]

View file

@ -40,12 +40,15 @@ cd skel; check "CD into skel"
# and that the naming schemes are correct # and that the naming schemes are correct
title "Linux folder check" title "Linux folder check"
[[ -f linux/gupax ]]; check "linux/gupax" [[ -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/p2pool/p2pool ]]; check "linux/p2pool/p2pool"
[[ -f linux/xmrig/xmrig ]]; check "linux/xmrig/xmrig" [[ -f linux/xmrig/xmrig ]]; check "linux/xmrig/xmrig"
title "macOS folder check" title "macOS folder check"
[[ -d macos/Gupax.app ]]; check "macos/Gupax.app" [[ -d macos/Gupax.app ]]; check "macos/Gupax.app"
[[ -f macos/p2pool/p2pool ]]; check "macos/p2pool/p2pool" [[ -f macos/Gupax.app/Contents/MacOS/p2pool/p2pool ]]; check "macos/p2pool/p2pool"
[[ -f macos/xmrig/xmrig ]]; check "macos/xmrig/xmrig" [[ -f macos/Gupax.app/Contents/MacOS/xmrig/xmrig ]]; check "macos/xmrig/xmrig"
title "Windows folder check" title "Windows folder check"
[[ -f windows/Gupax.exe ]]; check "windows/Gupax.exe" [[ -f windows/Gupax.exe ]]; check "windows/Gupax.exe"
[[ -f windows/P2Pool/p2pool.exe ]]; check "windows/P2Pool/p2pool.exe" [[ -f windows/P2Pool/p2pool.exe ]]; check "windows/P2Pool/p2pool.exe"