AppInstaller // Introducing readonlyAccessCheckGPR().

- This is a new way to detect whether the app bundle is translocated by GateKeeper.
This commit is contained in:
ShikiSuen 2022-07-06 17:59:34 +08:00
parent c412db063a
commit 562e6f99f1
1 changed files with 9 additions and 2 deletions

View File

@ -144,7 +144,7 @@ class AppDelegate: NSWindowController, NSApplicationDelegate {
if elapsed >= kTranslocationRemovalDeadline {
timer.invalidate()
window?.endSheet(progressSheet, returnCode: .cancel)
} else if appBundleChronoshiftedToARandomizedPath(kTargetPartialPath) == false {
} else if readonlyAccessCheckGPR(kTargetPartialPath) == false {
progressIndicator.doubleValue = 1.0
timer.invalidate()
window?.endSheet(progressSheet, returnCode: .continue)
@ -163,7 +163,7 @@ class AppDelegate: NSWindowController, NSApplicationDelegate {
}
let shouldWaitForTranslocationRemoval =
appBundleChronoshiftedToARandomizedPath(kTargetPartialPath)
readonlyAccessCheckGPR(kTargetPartialPath)
&& (window?.responds(to: #selector(NSWindow.beginSheet(_:completionHandler:))) ?? false)
//
@ -358,4 +358,11 @@ class AppDelegate: NSWindowController, NSApplicationDelegate {
func windowWillClose(_: Notification) {
NSApp.terminate(self)
}
// Determines if an app is translocated by Gatekeeper to a randomized path
// See https://weblog.rogueamoeba.com/2016/06/29/sierra-and-gatekeeper-path-randomization/
// Theoretically, if the path is a randomized path then it cannot be writable to FileManager.
func readonlyAccessCheckGPR(_ bundle: String) -> Bool {
!FileManager.default.isWritableFile(atPath: (bundle as NSString).expandingTildeInPath)
}
}