Skip to content

Commit

Permalink
Merge branch 'walles/translocation'
Browse files Browse the repository at this point in the history
  • Loading branch information
walles committed May 7, 2018
2 parents 840843e + 9758694 commit d9de2f4
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions osx/bubblemon/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,40 @@ private func launchActivityMonitor() {
}
}

func isTranslocated() -> Bool {
let appPath = URL(string: Bundle.main.bundlePath)!.resolvingSymlinksInPath().path

// Example translocated path:
// /private/var/folders/04/34ltylqn5yd9scvlrwjgmy580000gn/T/AppTranslocation/6E0A03F4-21EC-4559-87DF-77CB0DD7DB20/d/Bubblemon.app

// Does our path say "AppTranslocation"?
return appPath.range(of:"AppTranslocation") != nil
}

func showTranslocationWarning() {
let alert = NSAlert()
alert.messageText = "Move to Applications before running"
alert.informativeText =
"Please move Bubblemon into your Applications folder before running.\n\n" +
"" +
"Otherwise, because of App Translocation / Gatekeeper Path Randomization, " +
"Bubblemon will run in a random path every time, and after your computer " +
"reboots the Dock won't be able to find it any more."
alert.alertStyle = NSAlertStyle.warning
alert.addButton(withTitle: "OK")

alert.runModal()
}

func main() -> Int32 {
if (isTranslocated()) {
// See: http://lapcatsoftware.com/articles/app-translocation.html
// Or search the Internet for "Gatekeeper Path Randomization"
showTranslocationWarning()

return EXIT_FAILURE
}

let appPath = URL(string: Bundle.main.bundlePath)!.resolvingSymlinksInPath().path
let defaults = UserDefaults.standard

Expand Down

0 comments on commit d9de2f4

Please sign in to comment.