From 20f835329a35651c720b73a8d217e3b48ebd2fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 14 Jun 2021 16:26:44 +0200 Subject: [PATCH] macOS: Detect sandboxed state for command line apps The documentation says that if we "pass a URL to the main executable of a bundle, the bundle as a whole is generally recognized.". By passing the executable instead of the bundle we include command line applications that don't have a app bundle folder (but have an embedded Info.plist). Pick-to: 6.2 6.1 5.15 Change-Id: I3a2f145c1ec6e16607e9c04baf08678d5dea0b81 Reviewed-by: Alexandru Croitor --- src/corelib/kernel/qcore_mac.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qcore_mac.mm b/src/corelib/kernel/qcore_mac.mm index 6bf61b11558..6a8db38cc3f 100644 --- a/src/corelib/kernel/qcore_mac.mm +++ b/src/corelib/kernel/qcore_mac.mm @@ -401,8 +401,8 @@ bool qt_apple_isSandboxed() { static bool isSandboxed = []() { QCFType staticCode = nullptr; - NSURL *bundleUrl = [[NSBundle mainBundle] bundleURL]; - if (SecStaticCodeCreateWithPath((__bridge CFURLRef)bundleUrl, + NSURL *executableUrl = NSBundle.mainBundle.executableURL; + if (SecStaticCodeCreateWithPath((__bridge CFURLRef)executableUrl, kSecCSDefaultFlags, &staticCode) != errSecSuccess) return false;