summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXInit.c
diff options
context:
space:
mode:
authormarc_culler <marc.culler@gmail.com>2020-11-01 15:47:50 (GMT)
committermarc_culler <marc.culler@gmail.com>2020-11-01 15:47:50 (GMT)
commitdf042e0afd8158c643945ca8c92dc0718c65c3d0 (patch)
tree84d405ddac00d11c40c616785e780c2911c1e1c1 /macosx/tkMacOSXInit.c
parent54fe8b9255f92311fa990d4c2d09e2fc98ee7bd0 (diff)
downloadtk-df042e0afd8158c643945ca8c92dc0718c65c3d0.zip
tk-df042e0afd8158c643945ca8c92dc0718c65c3d0.tar.gz
tk-df042e0afd8158c643945ca8c92dc0718c65c3d0.tar.bz2
Be straightforward - check if the app is signed and use the result to choose the notification API
Diffstat (limited to 'macosx/tkMacOSXInit.c')
-rw-r--r--macosx/tkMacOSXInit.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index 11ebea1..1298af5 100644
--- a/macosx/tkMacOSXInit.c
+++ b/macosx/tkMacOSXInit.c
@@ -17,6 +17,7 @@
#include <dlfcn.h>
#include <objc/objc-auto.h>
#include <sys/stat.h>
+#import <Security/SecStaticCode.h>
static char tkLibPath[PATH_MAX + 1] = "";
@@ -41,6 +42,7 @@ static int TkMacOSXGetAppPathCmd(ClientData cd, Tcl_Interp *ip,
@synthesize macOSVersion = _macOSVersion;
@synthesize isDrawing = _isDrawing;
@synthesize needsToDraw = _needsToDraw;
+@synthesize isSigned = _isSigned;
@end
/*
@@ -93,10 +95,14 @@ static int TkMacOSXGetAppPathCmd(ClientData cd, Tcl_Interp *ip,
-(void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
(void)aNotification;
+ CFURLRef mainBundleURL;
+ OSStatus errorCode;
+ SecStaticCodeRef *staticCode = nil;
/*
* Initialize notifications.
*/
+
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_postedNotification:) name:nil object:nil];
@@ -107,6 +113,7 @@ static int TkMacOSXGetAppPathCmd(ClientData cd, Tcl_Interp *ip,
/*
* Construct the menu bar.
*/
+
_defaultMainMenu = nil;
[self _setupMenus];
@@ -119,8 +126,25 @@ static int TkMacOSXGetAppPathCmd(ClientData cd, Tcl_Interp *ip,
/*
* Initialize the graphics context.
*/
+
TkMacOSXUseAntialiasedText(_eventInterp, -1);
TkMacOSXInitCGDrawing(_eventInterp, TRUE, 0);
+
+ /*
+ * Check if the app has been signed.
+ */
+
+ mainBundleURL = CFBundleCopyBundleURL(CFBundleGetMainBundle());
+ errorCode = SecStaticCodeCreateWithPath(mainBundleURL, kSecCSDefaultFlags,
+ &staticCode);
+ CFRelease(mainBundleURL);
+ if (staticCode != nil && errorCode == noErr) {
+ errorCode = SecStaticCodeCheckValidity(staticCode, kSecCSBasicValidateOnly, nil);
+ if (errorCode == noErr) {
+ [NSApp setIsSigned:YES];
+ }
+ CFRelease(staticCode);
+ }
}
-(void)applicationDidFinishLaunching:(NSNotification *)notification