Skip to content

Commit

Permalink
SEBMAC-587 Now detecting and denying to run when custom Cocoa Text Sy…
Browse files Browse the repository at this point in the history
…stem key bindings are set.
  • Loading branch information
danschlet committed May 15, 2024
1 parent 5c4aa4a commit 3b547fa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions Classes/Global/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ static NSString __unused *BTouchBarRestartAgent = @"BTTRelaunch";
static NSString __unused *WebKitNetworkingProcessBundleID = @"com.apple.WebKit.Networking";
static NSString __unused *UniversalControlBundleID = @"com.apple.universalcontrol";
static NSString __unused *KeyboardViewerBundleID = @"com.apple.inputmethod.AssistiveControl";
static NSString __unused *KeyBindingsPath = @"/KeyBindings/DefaultKeyBinding.dict";
static NSString __unused *cachedTouchBarGlobalSettingsKey = @"cachedTouchBarGlobalSettingsKey";
static NSString __unused *cachedTouchBarFnDictionarySettingsKey = @"cachedTouchBarFnDictionarySettingsKey";
static NSString __unused *systemPreferencesBundleID = @"com.apple.systempreferences";
Expand Down
24 changes: 24 additions & 0 deletions Classes/SEBController.m
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,30 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification
DDLogDebug(@"%s", __FUNCTION__);
NSApp.presentationOptions |= (NSApplicationPresentationDisableForceQuit | NSApplicationPresentationHideDock);

NSArray <NSString *> *libraryDirs = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
NSLocalDomainMask | NSUserDomainMask,
YES);
NSFileManager *fileManager= [NSFileManager defaultManager];

for (NSString *libraryDir in libraryDirs) {
BOOL isDir;
NSString *keyBindingsFilePath = [libraryDir stringByAppendingPathComponent:KeyBindingsPath];
if ([fileManager fileExistsAtPath:keyBindingsFilePath isDirectory:&isDir]) {
DDLogError(@"Cocoa Text System key bindings file detected: at path %@", keyBindingsFilePath);
NSAlert *modalAlert = [self newAlert];
[modalAlert setMessageText:NSLocalizedString(@"Custom Key Binding Detected", @"")];
[modalAlert setInformativeText:[NSString stringWithFormat:NSLocalizedString(@"SEB doesn't allow to use custom key bindings. Please delete or rename the file at the path %@ and restart SEB", @""), keyBindingsFilePath]];
[modalAlert addButtonWithTitle:NSLocalizedString(@"Quit", @"")];
[modalAlert setAlertStyle:NSAlertStyleCritical];
void (^keyBindingDetectedHandler)(NSModalResponse) = ^void (NSModalResponse answer) {
[self removeAlertWindow:modalAlert.window];
[self quitSEBOrSession];
};
[self runModalAlert:modalAlert conditionallyForWindow:self.browserController.mainBrowserWindow completionHandler:(void (^)(NSModalResponse answer))keyBindingDetectedHandler];
return;
}
}

// Check if the font download alert was triggered from a web page
// and SEB didn't had Accessibility permissions
// and therefore was terminated to prevent a modal lock
Expand Down

0 comments on commit 3b547fa

Please sign in to comment.