From 5befd4ff707b6e10d020b87db8c6867b3bc25c90 Mon Sep 17 00:00:00 2001 From: georgesnow Date: Tue, 5 Nov 2019 13:38:18 -0500 Subject: [PATCH 01/13] added lock databse on Screen sleep --- MacPass/Base.lproj/GeneralPreferences.xib | 21 +++++++++++++++------ MacPass/MPDocumentWindowController.m | 4 ++++ MacPass/MPGeneralPreferencesController.h | 1 + MacPass/MPGeneralPreferencesController.m | 1 + MacPass/MPLockDaemon.m | 17 +++++++++++++++++ MacPass/MPSettingsHelper.h | 1 + MacPass/MPSettingsHelper.m | 2 ++ 7 files changed, 41 insertions(+), 6 deletions(-) diff --git a/MacPass/Base.lproj/GeneralPreferences.xib b/MacPass/Base.lproj/GeneralPreferences.xib index 3de597b88..45fa643e8 100644 --- a/MacPass/Base.lproj/GeneralPreferences.xib +++ b/MacPass/Base.lproj/GeneralPreferences.xib @@ -14,6 +14,7 @@ + @@ -47,7 +48,7 @@ - + @@ -75,7 +76,7 @@ - + @@ -113,7 +114,7 @@ - + Enabling this compromises security. If enabled, your preferences will contain mappings from database to keyfile. Key locations for databases without a password will not be saved. @@ -146,12 +147,20 @@ - + Disabling this compromises security. If enabled, anything copied to the Clipboard in MacPass will be available on your connected iOS devices. You should clear the clipboard on those devices manually. + @@ -219,7 +228,7 @@ - + @@ -236,7 +245,7 @@ - + diff --git a/MacPass/MPDocumentWindowController.m b/MacPass/MPDocumentWindowController.m index 87f9fd678..8d246dfb4 100644 --- a/MacPass/MPDocumentWindowController.m +++ b/MacPass/MPDocumentWindowController.m @@ -159,6 +159,9 @@ - (void)windowDidLoad { [self.window addTitlebarAccessoryViewController:tbc]; */ } +- (NSResponder *)reconmendedFirstResponder { + return self.toolbarDelegate.searchField; +} - (NSSearchField *)searchField { return self.toolbarDelegate.searchField; @@ -216,6 +219,7 @@ - (void)_didLockDatabase:(NSNotification *)notification { - (void)_didUnlockDatabase:(NSNotification *)notification { [self showEntries]; /* Show password reminders */ + [self reconmendedFirstResponder]; [self _presentPasswordIntervalAlerts]; } diff --git a/MacPass/MPGeneralPreferencesController.h b/MacPass/MPGeneralPreferencesController.h index f216249be..54a8a9828 100644 --- a/MacPass/MPGeneralPreferencesController.h +++ b/MacPass/MPGeneralPreferencesController.h @@ -32,6 +32,7 @@ @property (strong) IBOutlet NSPopUpButton *idleTimeOutPopup; @property (strong) IBOutlet NSButton *lockOnSleepCheckButton; @property (strong) IBOutlet NSButton *lockOnLogoutCheckButton; +@property (weak) IBOutlet NSButton *lockOnScreenSleep; @property (strong) IBOutlet NSButton *reopenLastDatabase; @property (strong) IBOutlet NSButton *enableAutosaveCheckButton; @property (strong) IBOutlet NSButton *rememberKeyFileCheckButton; diff --git a/MacPass/MPGeneralPreferencesController.m b/MacPass/MPGeneralPreferencesController.m index 20428a82d..933f518ca 100644 --- a/MacPass/MPGeneralPreferencesController.m +++ b/MacPass/MPGeneralPreferencesController.m @@ -50,6 +50,7 @@ - (void)viewDidLoad { [self.preventUniversalClipboardSupportCheckButton bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyPreventUniversalClipboard] options:nil]; [self.lockOnSleepCheckButton bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyLockOnSleep] options:nil]; [self.lockOnLogoutCheckButton bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingskeyLockOnLogout] options:nil]; + [self.lockOnScreenSleep bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingskeyLockOnScreenSleep] options:nil]; [self.idleTimeOutPopup bind:NSSelectedTagBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyIdleLockTimeOut] options:nil]; [self.reopenLastDatabase bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyReopenLastDatabaseOnLaunch] options:nil]; [self.enableAutosaveCheckButton bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyEnableAutosave] options:nil]; diff --git a/MacPass/MPLockDaemon.m b/MacPass/MPLockDaemon.m index 5180f37d4..bf657a0bb 100644 --- a/MacPass/MPLockDaemon.m +++ b/MacPass/MPLockDaemon.m @@ -28,6 +28,7 @@ @interface MPLockDaemon () @property (nonatomic,assign) BOOL lockOnSleep; @property (nonatomic,assign) BOOL lockOnLogout; +@property (nonatomic,assign) BOOL lockOnScreenSleep; @property (nonatomic,assign) NSUInteger idleLockTime; @property (nonatomic,strong) id localEventHandler; @property (nonatomic,strong) NSTimer *idleCheckTimer; @@ -59,6 +60,7 @@ - (instancetype)_init { [self bind:NSStringFromSelector(@selector(lockOnSleep)) toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyLockOnSleep] options:nil]; [self bind:NSStringFromSelector(@selector(idleLockTime)) toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyIdleLockTimeOut] options:nil]; [self bind:NSStringFromSelector(@selector(lockOnLogout)) toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingskeyLockOnLogout] options:nil]; + [self bind:NSStringFromSelector(@selector(lockOnScreenSleep)) toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingskeyLockOnScreenSleep] options:nil]; } return self; } @@ -95,6 +97,18 @@ - (void)setLockOnSleep:(BOOL)lockOnSleep { } } +- (void)setLockOnScreenSleep:(BOOL)lockOnScreenSleep { + if(_lockOnScreenSleep != lockOnScreenSleep) { + _lockOnScreenSleep = lockOnScreenSleep; + if(_lockOnScreenSleep) { + [NSWorkspace.sharedWorkspace.notificationCenter addObserver:self selector:@selector(_willScreenSleepNotification:) name:NSWorkspaceScreensDidSleepNotification object:nil]; + } + else { + [NSWorkspace.sharedWorkspace.notificationCenter removeObserver:self name:NSWorkspaceWillSleepNotification object:nil]; + } + } +} + - (void)setIdleLockTime:(NSUInteger)idleLockTime { if(_idleLockTime != idleLockTime) { _idleLockTime = idleLockTime; @@ -113,6 +127,9 @@ - (void)_willLogOutNotification:(NSNotification *)notification { - (void)_willSleepNotification:(NSNotification *)notification { [((MPAppDelegate *)NSApp.delegate) lockAllDocuments]; } +- (void)_willScreenSleepNotification:(NSNotification *)notification { + [((MPAppDelegate *)NSApp.delegate) lockAllDocuments]; +} - (void)_checkIdleTime:(NSTimer *)timer { if(timer != self.idleCheckTimer) { diff --git a/MacPass/MPSettingsHelper.h b/MacPass/MPSettingsHelper.h index 9c366a877..786b8b17b 100644 --- a/MacPass/MPSettingsHelper.h +++ b/MacPass/MPSettingsHelper.h @@ -42,6 +42,7 @@ APPKIT_EXTERN NSString *const kMPSettingsKeyBrowserBundleId; APPKIT_EXTERN NSString *const kMPSettingsKeyLockOnSleep; APPKIT_EXTERN NSString *const kMPSettingskeyLockOnLogout; APPKIT_EXTERN NSString *const kMPSettingsKeyIdleLockTimeOut; +APPKIT_EXTERN NSString *const kMPSettingskeyLockOnScreenSleep; /* Autosaving states */ APPKIT_EXTERN NSString *const kMPSettingsKeyShowInspector; diff --git a/MacPass/MPSettingsHelper.m b/MacPass/MPSettingsHelper.m index 63dea553e..c08a48767 100644 --- a/MacPass/MPSettingsHelper.m +++ b/MacPass/MPSettingsHelper.m @@ -37,6 +37,7 @@ NSString *const kMPSettingsKeyEnableAutosave = @"EnableAutosave"; NSString *const kMPSettingsKeyLockOnSleep = @"LockOnSleep"; NSString *const kMPSettingskeyLockOnLogout = @"LockOnLogout"; +NSString *const kMPSettingskeyLockOnScreenSleep = @"LockOnScreenSleep"; NSString *const kMPSettingsKeyIdleLockTimeOut = @"IdleLockTimeOut"; NSString *const kMPSettingsKeyShowInspector = @"ShowInspector"; NSString *const kMPSettingsKeyEntryTableSortDescriptors = @"EntryTableSortDescriptors"; @@ -132,6 +133,7 @@ + (NSDictionary *)_standardDefaults { kMPSettingsKeyFileChangeStrategy: @(MPFileChangeStrategyAsk), // Ask what to do on a file change! kMPSettingsKeyLockOnSleep: @YES, kMPSettingskeyLockOnLogout: @NO, + kMPSettingskeyLockOnScreenSleep: @NO, kMPSettingsKeyIdleLockTimeOut: @0, // 5 minutes kMPSettingsKeyLegacyHideNotes: @NO, kMPSettingsKeyLegacyHidePassword: @YES, From 85af79f13e94ea533028a777469c70e4e38dab3d Mon Sep 17 00:00:00 2001 From: georgesnow Date: Tue, 5 Nov 2019 15:36:09 -0500 Subject: [PATCH 02/13] remove unneeded change --- MacPass/MPDocumentWindowController.m | 4 ---- 1 file changed, 4 deletions(-) diff --git a/MacPass/MPDocumentWindowController.m b/MacPass/MPDocumentWindowController.m index 8d246dfb4..87f9fd678 100644 --- a/MacPass/MPDocumentWindowController.m +++ b/MacPass/MPDocumentWindowController.m @@ -159,9 +159,6 @@ - (void)windowDidLoad { [self.window addTitlebarAccessoryViewController:tbc]; */ } -- (NSResponder *)reconmendedFirstResponder { - return self.toolbarDelegate.searchField; -} - (NSSearchField *)searchField { return self.toolbarDelegate.searchField; @@ -219,7 +216,6 @@ - (void)_didLockDatabase:(NSNotification *)notification { - (void)_didUnlockDatabase:(NSNotification *)notification { [self showEntries]; /* Show password reminders */ - [self reconmendedFirstResponder]; [self _presentPasswordIntervalAlerts]; } From d019b53507857a1e09b7ce509973fea8480ab611 Mon Sep 17 00:00:00 2001 From: georgesnow Date: Wed, 6 Nov 2019 09:26:19 -0500 Subject: [PATCH 03/13] fix unregister screen sleep method --- MacPass/MPLockDaemon.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MacPass/MPLockDaemon.m b/MacPass/MPLockDaemon.m index bf657a0bb..8851198cc 100644 --- a/MacPass/MPLockDaemon.m +++ b/MacPass/MPLockDaemon.m @@ -104,7 +104,7 @@ - (void)setLockOnScreenSleep:(BOOL)lockOnScreenSleep { [NSWorkspace.sharedWorkspace.notificationCenter addObserver:self selector:@selector(_willScreenSleepNotification:) name:NSWorkspaceScreensDidSleepNotification object:nil]; } else { - [NSWorkspace.sharedWorkspace.notificationCenter removeObserver:self name:NSWorkspaceWillSleepNotification object:nil]; + [NSWorkspace.sharedWorkspace.notificationCenter removeObserver:self name:NSWorkspaceScreensDidSleepNotification object:nil]; } } } From 13c820aac2e4238adb2a0c78cd124a0543d7c369 Mon Sep 17 00:00:00 2001 From: georgesnow Date: Mon, 16 Dec 2019 15:38:27 -0500 Subject: [PATCH 04/13] fixed constraints and checkbox label --- MacPass/Base.lproj/GeneralPreferences.xib | 45 ++++++++++++----------- MacPass/MPGeneralPreferencesController.h | 2 +- MacPass/MPGeneralPreferencesController.m | 2 +- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/MacPass/Base.lproj/GeneralPreferences.xib b/MacPass/Base.lproj/GeneralPreferences.xib index 45fa643e8..4ce5887df 100644 --- a/MacPass/Base.lproj/GeneralPreferences.xib +++ b/MacPass/Base.lproj/GeneralPreferences.xib @@ -25,16 +25,16 @@ - + - + - + - + @@ -45,7 +45,7 @@ - + @@ -63,7 +63,7 @@ - + @@ -90,14 +90,14 @@ - + @@ -114,7 +114,7 @@ - + Enabling this compromises security. If enabled, your preferences will contain mappings from database to keyfile. Key locations for databases without a password will not be saved. @@ -131,31 +131,30 @@ - + - + Disabling this compromises security. If enabled, anything copied to the Clipboard in MacPass will be available on your connected iOS devices. You should clear the clipboard on those devices manually. - - + @@ -88,7 +88,7 @@ - + @@ -134,21 +134,25 @@ - + - + + + + + @@ -184,7 +188,7 @@ - + @@ -199,7 +203,7 @@ - + @@ -218,18 +222,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + - + diff --git a/MacPass/MPIntegrationPreferencesController.h b/MacPass/MPIntegrationPreferencesController.h index 2deb2b5ad..a2ffd2eb0 100644 --- a/MacPass/MPIntegrationPreferencesController.h +++ b/MacPass/MPIntegrationPreferencesController.h @@ -44,6 +44,9 @@ /* Preview */ @property (strong) IBOutlet NSButton *enableQuicklookCheckBox; +/* Interface */ +@property (weak) IBOutlet NSButton *launchOnLoginCheckBox; + - (IBAction)runAutotypeDoctor:(id)sender; @end diff --git a/MacPass/MPIntegrationPreferencesController.m b/MacPass/MPIntegrationPreferencesController.m index c4ccdfbc1..82b6bc255 100644 --- a/MacPass/MPIntegrationPreferencesController.m +++ b/MacPass/MPIntegrationPreferencesController.m @@ -29,6 +29,8 @@ #import "DDHotKey+MacPassAdditions.h" #import "DDHotKeyTextField.h" +#import + @interface MPIntegrationPreferencesController () @property (nonatomic, strong) DDHotKey *hotKey; @@ -68,7 +70,10 @@ - (void)awakeFromNib { [self.matchTagsCheckBox bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyAutotypeMatchTags] options:nil]; [self.sendCommandForControlCheckBox bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeySendCommandForControlKey] options:nil]; - + + self.launchOnLoginCheckBox.state = [NSUserDefaults.standardUserDefaults boolForKey:@"LoginEnabled"]; + [self.launchOnLoginCheckBox bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyLaunchOnLogin] options:nil]; + [self _showKeyCodeMissingKeyWarning:NO]; [self _updateAccessabilityWarning]; } @@ -121,4 +126,14 @@ - (void)_updateAccessabilityWarning { - (void)runAutotypeDoctor:(id)sender { [MPAutotypeDoctor.defaultDoctor runChecksAndPresentResults]; } +- (IBAction)loginButtonCheckBox:(id)sender { + if (!SMLoginItemSetEnabled((__bridge CFStringRef)@"com.hicknhacksoftware.MacPassHelper", [sender state])) { + NSLog(@"Login Item Was Not Successful"); + } + +// [NSUserDefaults.standardUserDefaults setBool:[sender state] forKey:@"LoginEnabled"]; + [[NSUserDefaults standardUserDefaults] setBool:[sender state] forKey:kMPSettingsKeyLaunchOnLogin]; +} + + @end diff --git a/MacPass/MPSettingsHelper.h b/MacPass/MPSettingsHelper.h index 786b8b17b..15ccbb336 100644 --- a/MacPass/MPSettingsHelper.h +++ b/MacPass/MPSettingsHelper.h @@ -71,6 +71,9 @@ APPKIT_EXTERN NSString *const kMPSettingsKeyAutotypeMatchHost; // APPKIT_EXTERN NSString *const kMPSettingsKeyAutotypeMatchTags; // Autotype lookup includes tags for entries APPKIT_EXTERN NSString *const kMPSettingsKeyAutotpyeHideMissingPermissionsWarning; +/* Interface */ +APPKIT_EXTERN NSString *const kMPSettingsKeyLaunchOnLogin; + /* Search */ APPKIT_EXTERN NSString *const kMPSettingsKeyEntrySearchFilterContext; diff --git a/MacPass/MPSettingsHelper.m b/MacPass/MPSettingsHelper.m index 7ec3d674c..53187e568 100644 --- a/MacPass/MPSettingsHelper.m +++ b/MacPass/MPSettingsHelper.m @@ -62,6 +62,8 @@ NSString *const kMPSettingsKeyAutotypeMatchTags = @"AutotypeMatchTags"; NSString *const kMPSettingsKeyAutotpyeHideMissingPermissionsWarning = @"AutotpyeHideMissingPermissionsWarning"; +NSString *const kMPSettingsKeyLaunchOnLogin =@"LaunchOnLogin"; + NSString *const kMPSettingsKeyEntrySearchFilterContext = @"EntrySearchFilterContext"; NSString *const kMPSettingsKeyEnableQuicklookPreview = @"EnableQuicklookPreview"; @@ -164,7 +166,8 @@ + (NSDictionary *)_standardDefaults { kMPSettingsKeyLoadIncompatiblePlugins: @NO, kMPSettingsKeyQuitOnLastWindowClose: @NO, kMPSettingsKeyEnableAutosave: @YES, - kMPSettingsKeyHideAfterCopyToClipboard: @NO + kMPSettingsKeyHideAfterCopyToClipboard: @NO, + kMPSettingsKeyLaunchOnLogin: @NO }; }); return standardDefaults; diff --git a/MacPassHelper/AppDelegate.h b/MacPassHelper/AppDelegate.h new file mode 100644 index 000000000..178a5e333 --- /dev/null +++ b/MacPassHelper/AppDelegate.h @@ -0,0 +1,15 @@ +// +// AppDelegate.h +// MacPassHelper +// +// Created by georgesnow on 1/22/20. +// Copyright © 2020 HicknHack Software GmbH. All rights reserved. +// + +#import + +@interface AppDelegate : NSObject + + +@end + diff --git a/MacPassHelper/AppDelegate.m b/MacPassHelper/AppDelegate.m new file mode 100644 index 000000000..ffb9b2577 --- /dev/null +++ b/MacPassHelper/AppDelegate.m @@ -0,0 +1,33 @@ +// +// AppDelegate.m +// MacPassHelper +// +// Created by georgesnow on 1/22/20. +// Copyright © 2020 HicknHack Software GmbH. All rights reserved. +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@property (weak) IBOutlet NSWindow *window; +@end + +@implementation AppDelegate + +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { + // Insert code here to initialize your application + NSArray *pathComponents = [[[NSBundle mainBundle] bundlePath] pathComponents]; + pathComponents = [pathComponents subarrayWithRange:NSMakeRange(0, [pathComponents count] - 4)]; + NSString *path = [NSString pathWithComponents:pathComponents]; + [[NSWorkspace sharedWorkspace] launchApplication:path]; + [NSApp terminate:nil]; +} + + +- (void)applicationWillTerminate:(NSNotification *)aNotification { + // Insert code here to tear down your application +} + + +@end diff --git a/MacPassHelper/Assets.xcassets/AppIcon.appiconset/Contents.json b/MacPassHelper/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..2db2b1c7c --- /dev/null +++ b/MacPassHelper/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,58 @@ +{ + "images" : [ + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/MacPassHelper/Assets.xcassets/Contents.json b/MacPassHelper/Assets.xcassets/Contents.json new file mode 100644 index 000000000..da4a164c9 --- /dev/null +++ b/MacPassHelper/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/MacPassHelper/Base.lproj/MainMenu.xib b/MacPassHelper/Base.lproj/MainMenu.xib new file mode 100644 index 000000000..cb2338f52 --- /dev/null +++ b/MacPassHelper/Base.lproj/MainMenu.xib @@ -0,0 +1,692 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MacPassHelper/Info.plist b/MacPassHelper/Info.plist new file mode 100644 index 000000000..b55597471 --- /dev/null +++ b/MacPassHelper/Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSBackgroundOnly + + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + Copyright © 2020 HicknHack Software GmbH. All rights reserved. + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/MacPassHelper/MacPassHelper.entitlements b/MacPassHelper/MacPassHelper.entitlements new file mode 100644 index 000000000..f2ef3ae02 --- /dev/null +++ b/MacPassHelper/MacPassHelper.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + + + diff --git a/MacPassHelper/main.m b/MacPassHelper/main.m new file mode 100644 index 000000000..06df9eeae --- /dev/null +++ b/MacPassHelper/main.m @@ -0,0 +1,13 @@ +// +// main.m +// MacPassHelper +// +// Created by georgesnow on 1/22/20. +// Copyright © 2020 HicknHack Software GmbH. All rights reserved. +// + +#import + +int main(int argc, const char * argv[]) { + return NSApplicationMain(argc, argv); +} diff --git a/MacPassHelperTests/Info.plist b/MacPassHelperTests/Info.plist new file mode 100644 index 000000000..6c40a6cd0 --- /dev/null +++ b/MacPassHelperTests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/MacPassHelperTests/MacPassHelperTests.m b/MacPassHelperTests/MacPassHelperTests.m new file mode 100644 index 000000000..38b9cf173 --- /dev/null +++ b/MacPassHelperTests/MacPassHelperTests.m @@ -0,0 +1,37 @@ +// +// MacPassHelperTests.m +// MacPassHelperTests +// +// Created by georgesnow on 1/22/20. +// Copyright © 2020 HicknHack Software GmbH. All rights reserved. +// + +#import + +@interface MacPassHelperTests : XCTestCase + +@end + +@implementation MacPassHelperTests + +- (void)setUp { + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. +} + +- (void)testExample { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end diff --git a/MacPassHelperUITests/Info.plist b/MacPassHelperUITests/Info.plist new file mode 100644 index 000000000..6c40a6cd0 --- /dev/null +++ b/MacPassHelperUITests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/MacPassHelperUITests/MacPassHelperUITests.m b/MacPassHelperUITests/MacPassHelperUITests.m new file mode 100644 index 000000000..de047f0d0 --- /dev/null +++ b/MacPassHelperUITests/MacPassHelperUITests.m @@ -0,0 +1,38 @@ +// +// MacPassHelperUITests.m +// MacPassHelperUITests +// +// Created by georgesnow on 1/22/20. +// Copyright © 2020 HicknHack Software GmbH. All rights reserved. +// + +#import + +@interface MacPassHelperUITests : XCTestCase + +@end + +@implementation MacPassHelperUITests + +- (void)setUp { + // Put setup code here. This method is called before the invocation of each test method in the class. + + // In UI tests it is usually best to stop immediately when a failure occurs. + self.continueAfterFailure = NO; + + // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. + [[[XCUIApplication alloc] init] launch]; + + // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. +} + +- (void)testExample { + // Use recording to get started writing UI tests. + // Use XCTAssert and related functions to verify your tests produce the correct results. +} + +@end From d6914d0e75975325175e811b2e716178770ab029 Mon Sep 17 00:00:00 2001 From: georgesnow Date: Wed, 22 Jan 2020 15:18:06 -0500 Subject: [PATCH 09/13] remove unneeded clipboard fix and remove window for mprhelper --- MacPass/MPPasteBoardController.m | 4 ++-- MacPassHelper/Base.lproj/MainMenu.xib | 24 +++++------------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/MacPass/MPPasteBoardController.m b/MacPass/MPPasteBoardController.m index 39540b3d9..a51ef7d0d 100644 --- a/MacPass/MPPasteBoardController.m +++ b/MacPass/MPPasteBoardController.m @@ -111,7 +111,7 @@ - (void)copyObjectsWithoutTimeout:(NSArray> *)objects { } else { [NSPasteboard.generalPasteboard clearContents]; - [NSPasteboard.generalPasteboard setString:@"" forType:NSPasteboardTypeString]; +// [NSPasteboard.generalPasteboard setString:@"" forType:NSPasteboardTypeString]; } [NSPasteboard.generalPasteboard writeObjects:objects]; self.isEmpty = NO; @@ -165,7 +165,7 @@ - (void)_clearPasteboardContents { /* Only clear stuff we might have put there */ if(!self.isEmpty) { [NSPasteboard.generalPasteboard clearContents]; - [NSPasteboard.generalPasteboard setString:@"" forType:NSPasteboardTypeString]; +// [NSPasteboard.generalPasteboard setString:@"" forType:NSPasteboardTypeString]; [NSNotificationCenter.defaultCenter postNotificationName:MPPasteBoardControllerDidClearClipboard object:self]; } self.isEmpty = YES; diff --git a/MacPassHelper/Base.lproj/MainMenu.xib b/MacPassHelper/Base.lproj/MainMenu.xib index cb2338f52..9571a80f8 100644 --- a/MacPassHelper/Base.lproj/MainMenu.xib +++ b/MacPassHelper/Base.lproj/MainMenu.xib @@ -1,7 +1,7 @@ - - + + - + @@ -10,12 +10,8 @@ - - - - - - + + @@ -678,15 +674,5 @@ - - - - - - - - - - From b09284790830416c1018dba317dd61d67524f305 Mon Sep 17 00:00:00 2001 From: georgesnow Date: Wed, 22 Jan 2020 16:02:43 -0500 Subject: [PATCH 10/13] fixed check box and updated comment on keyvalue --- MacPass/MPIntegrationPreferencesController.m | 5 +---- MacPass/MPSettingsHelper.m | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/MacPass/MPIntegrationPreferencesController.m b/MacPass/MPIntegrationPreferencesController.m index 82b6bc255..3ef302b3a 100644 --- a/MacPass/MPIntegrationPreferencesController.m +++ b/MacPass/MPIntegrationPreferencesController.m @@ -71,7 +71,6 @@ - (void)awakeFromNib { [self.sendCommandForControlCheckBox bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeySendCommandForControlKey] options:nil]; - self.launchOnLoginCheckBox.state = [NSUserDefaults.standardUserDefaults boolForKey:@"LoginEnabled"]; [self.launchOnLoginCheckBox bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyLaunchOnLogin] options:nil]; [self _showKeyCodeMissingKeyWarning:NO]; @@ -130,9 +129,7 @@ - (IBAction)loginButtonCheckBox:(id)sender { if (!SMLoginItemSetEnabled((__bridge CFStringRef)@"com.hicknhacksoftware.MacPassHelper", [sender state])) { NSLog(@"Login Item Was Not Successful"); } - -// [NSUserDefaults.standardUserDefaults setBool:[sender state] forKey:@"LoginEnabled"]; - [[NSUserDefaults standardUserDefaults] setBool:[sender state] forKey:kMPSettingsKeyLaunchOnLogin]; + [NSUserDefaults.standardUserDefaults setBool:[sender state] forKey:kMPSettingsKeyLaunchOnLogin]; } diff --git a/MacPass/MPSettingsHelper.m b/MacPass/MPSettingsHelper.m index 53187e568..8cd517579 100644 --- a/MacPass/MPSettingsHelper.m +++ b/MacPass/MPSettingsHelper.m @@ -167,7 +167,7 @@ + (NSDictionary *)_standardDefaults { kMPSettingsKeyQuitOnLastWindowClose: @NO, kMPSettingsKeyEnableAutosave: @YES, kMPSettingsKeyHideAfterCopyToClipboard: @NO, - kMPSettingsKeyLaunchOnLogin: @NO + kMPSettingsKeyLaunchOnLogin: @NO //By default off when turned on it registers the mprhelper.app with launchservices }; }); return standardDefaults; From d6c3290f6960ab9fbb63818e06af5bd324ee7422 Mon Sep 17 00:00:00 2001 From: georgesnow Date: Thu, 23 Jan 2020 21:35:36 -0500 Subject: [PATCH 11/13] updated helper deployment sdk to match main MP bundle --- MacPass.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index db5b1f224..dc68f8a33 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -3048,7 +3048,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; INFOPLIST_FILE = MacPassHelper/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.15; + MACOSX_DEPLOYMENT_TARGET = 10.10; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.hicknhacksoftware.MacPassHelper; @@ -3083,7 +3083,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; INFOPLIST_FILE = MacPassHelper/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.15; + MACOSX_DEPLOYMENT_TARGET = 10.10; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.hicknhacksoftware.MacPassHelper; From 5a744028e0d3c6beed34fed996f95fb7977aea6c Mon Sep 17 00:00:00 2001 From: georgesnow Date: Thu, 23 Jan 2020 21:42:06 -0500 Subject: [PATCH 12/13] remove stale comments --- MacPass/MPPasteBoardController.m | 2 -- MacPass/MPSettingsHelper.m | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/MacPass/MPPasteBoardController.m b/MacPass/MPPasteBoardController.m index a51ef7d0d..f3588d49d 100644 --- a/MacPass/MPPasteBoardController.m +++ b/MacPass/MPPasteBoardController.m @@ -111,7 +111,6 @@ - (void)copyObjectsWithoutTimeout:(NSArray> *)objects { } else { [NSPasteboard.generalPasteboard clearContents]; -// [NSPasteboard.generalPasteboard setString:@"" forType:NSPasteboardTypeString]; } [NSPasteboard.generalPasteboard writeObjects:objects]; self.isEmpty = NO; @@ -165,7 +164,6 @@ - (void)_clearPasteboardContents { /* Only clear stuff we might have put there */ if(!self.isEmpty) { [NSPasteboard.generalPasteboard clearContents]; -// [NSPasteboard.generalPasteboard setString:@"" forType:NSPasteboardTypeString]; [NSNotificationCenter.defaultCenter postNotificationName:MPPasteBoardControllerDidClearClipboard object:self]; } self.isEmpty = YES; diff --git a/MacPass/MPSettingsHelper.m b/MacPass/MPSettingsHelper.m index 8cd517579..6b3dc6525 100644 --- a/MacPass/MPSettingsHelper.m +++ b/MacPass/MPSettingsHelper.m @@ -62,7 +62,7 @@ NSString *const kMPSettingsKeyAutotypeMatchTags = @"AutotypeMatchTags"; NSString *const kMPSettingsKeyAutotpyeHideMissingPermissionsWarning = @"AutotpyeHideMissingPermissionsWarning"; -NSString *const kMPSettingsKeyLaunchOnLogin =@"LaunchOnLogin"; +NSString *const kMPSettingsKeyLaunchOnLogin = @"LaunchOnLogin"; NSString *const kMPSettingsKeyEntrySearchFilterContext = @"EntrySearchFilterContext"; @@ -167,7 +167,7 @@ + (NSDictionary *)_standardDefaults { kMPSettingsKeyQuitOnLastWindowClose: @NO, kMPSettingsKeyEnableAutosave: @YES, kMPSettingsKeyHideAfterCopyToClipboard: @NO, - kMPSettingsKeyLaunchOnLogin: @NO //By default off when turned on it registers the mprhelper.app with launchservices + kMPSettingsKeyLaunchOnLogin: @NO }; }); return standardDefaults; From 6c89dee9aab46e086bb4b3cd151138a95f015920 Mon Sep 17 00:00:00 2001 From: georgesnow Date: Fri, 24 Jan 2020 13:46:44 -0500 Subject: [PATCH 13/13] improved: helper no longer relaunches MacPassed when enabled - had to unsandbox helper app, checkbox no reflects plist settings --- MacPass.xcodeproj/project.pbxproj | 7 +++- MacPass/Base.lproj/IntegrationPreferences.xib | 4 +- MacPass/MPIntegrationPreferencesController.m | 38 +++++++++++++++++-- MacPassHelper/AppDelegate.m | 12 +++++- MacPassHelper/MacPassHelper.entitlements | 7 +--- 5 files changed, 54 insertions(+), 14 deletions(-) diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index dc68f8a33..287742b17 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -1882,6 +1882,11 @@ 7E834B6823D8961F00F3999E = { CreatedOnToolsVersion = 10.3; ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 0; + }; + }; }; }; }; @@ -3034,7 +3039,6 @@ CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_ENTITLEMENTS = MacPassHelper/MacPassHelper.entitlements; CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; @@ -3072,7 +3076,6 @@ CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_ENTITLEMENTS = MacPassHelper/MacPassHelper.entitlements; CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; diff --git a/MacPass/Base.lproj/IntegrationPreferences.xib b/MacPass/Base.lproj/IntegrationPreferences.xib index f943eb8bc..ef846ca9c 100644 --- a/MacPass/Base.lproj/IntegrationPreferences.xib +++ b/MacPass/Base.lproj/IntegrationPreferences.xib @@ -14,6 +14,8 @@ + + @@ -230,7 +232,7 @@