From 716f308f361e22b45c5162c2de39977d180853b5 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 15 Dec 2019 15:03:01 -0500 Subject: [PATCH] Turn off the App Sandbox for now. Sparkle 1.x does not support updating from within the App Sandbox, per https://github.com/sparkle-project/Sparkle/issues/363. Move all the sandbox support behind a USE_APP_SANDBOX compiler define, and create a new Release-AppSandbox build configuration for it. --- MacGDBp.xcodeproj/project.pbxproj | 92 +++++++++++++++++++++++++++++-- Source/AppDelegate.m | 6 ++ Source/DebuggerController.m | 2 + Source/FileAccessController.h | 4 ++ Source/FileAccessController.m | 4 ++ Source/PreferenceNames.h | 2 + Source/PreferenceNames.m | 2 + Source/PreferencesController.h | 2 + Source/PreferencesController.m | 18 ++++++ 9 files changed, 127 insertions(+), 5 deletions(-) diff --git a/MacGDBp.xcodeproj/project.pbxproj b/MacGDBp.xcodeproj/project.pbxproj index 287e2bb..f378a3c 100644 --- a/MacGDBp.xcodeproj/project.pbxproj +++ b/MacGDBp.xcodeproj/project.pbxproj @@ -670,24 +670,102 @@ }; name = Release; }; - C01FCF4B08A954540054247B /* Debug */ = { + 1EFE883423A6C5CF004202A7 /* Release-AppSandbox */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; - CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.9; + SDKROOT = macosx; + USE_HEADERMAP = NO; + }; + name = "Release-AppSandbox"; + }; + 1EFE883523A6C5CF004202A7 /* Release-AppSandbox */ = { + isa = XCBuildConfiguration; + buildSettings = { CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_WEAK = YES; CODE_SIGN_ENTITLEMENTS = MacGDBp.entitlements; COMBINE_HIDPI_IMAGES = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(SRCROOT)", + ); + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_PREPROCESSOR_DEFINITIONS = "USE_APP_SANDBOX=$(MACGDBP_APP_SANDBOX)"; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Applications"; + LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks"; + MACGDBP_APP_SANDBOX = 1; + PRODUCT_BUNDLE_IDENTIFIER = org.bluestatic.macgdbp; + PRODUCT_NAME = MacGDBp; + WRAPPER_EXTENSION = app; + }; + name = "Release-AppSandbox"; + }; + 1EFE883623A6C5CF004202A7 /* Release-AppSandbox */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + COMBINE_HIDPI_IMAGES = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + HEADER_SEARCH_PATHS = "$(SRCROOT)/Source"; + INFOPLIST_FILE = "UnitTests-Info.plist"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = "org.bluestatic.MacGDBp-Tests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Release-AppSandbox"; + }; + C01FCF4B08A954540054247B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)", ); GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = "USE_APP_SANDBOX=$(MACGDBP_APP_SANDBOX)"; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Applications"; LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks"; + MACGDBP_APP_SANDBOX = 0; PRODUCT_BUNDLE_IDENTIFIER = org.bluestatic.macgdbp; PRODUCT_NAME = MacGDBp; WRAPPER_EXTENSION = app; @@ -697,20 +775,19 @@ C01FCF4C08A954540054247B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; - CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_WEAK = YES; - CODE_SIGN_ENTITLEMENTS = MacGDBp.entitlements; COMBINE_HIDPI_IMAGES = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)", ); GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_PREPROCESSOR_DEFINITIONS = "USE_APP_SANDBOX=$(MACGDBP_APP_SANDBOX)"; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Applications"; LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks"; + MACGDBP_APP_SANDBOX = 0; PRODUCT_BUNDLE_IDENTIFIER = org.bluestatic.macgdbp; PRODUCT_NAME = MacGDBp; WRAPPER_EXTENSION = app; @@ -721,6 +798,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; @@ -760,6 +838,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; @@ -800,6 +879,7 @@ buildConfigurations = ( 1E8C709F1BDB167F00D333DC /* Debug */, 1E8C70A01BDB167F00D333DC /* Release */, + 1EFE883623A6C5CF004202A7 /* Release-AppSandbox */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; @@ -809,6 +889,7 @@ buildConfigurations = ( C01FCF4B08A954540054247B /* Debug */, C01FCF4C08A954540054247B /* Release */, + 1EFE883523A6C5CF004202A7 /* Release-AppSandbox */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; @@ -818,6 +899,7 @@ buildConfigurations = ( C01FCF4F08A954540054247B /* Debug */, C01FCF5008A954540054247B /* Release */, + 1EFE883423A6C5CF004202A7 /* Release-AppSandbox */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; diff --git a/Source/AppDelegate.m b/Source/AppDelegate.m index 0ce51bb..d7948ac 100644 --- a/Source/AppDelegate.m +++ b/Source/AppDelegate.m @@ -40,7 +40,9 @@ kPrefPort : @9000, kPrefInspectorWindowVisible : @YES, kPrefPathReplacements : [NSMutableArray array], +#if USE_APP_SANDBOX kPrefFileAccessBookmarks : [NSMutableDictionary dictionary], +#endif kPrefBreakOnFirstLine : @YES, kPrefDebuggerAttached : @YES, kPrefSelectedDebuggerSegment : @1, @@ -74,9 +76,11 @@ [[feedURL absoluteString] rangeOfString:@"?unstable"].location != NSNotFound; [defaults setBool:usesUnstable forKey:kPrefUnstableVersionCast]; +#if USE_APP_SANDBOX [FileAccessController maybeShowFileAccessDialog]; [self _activateSecureFileAccess]; +#endif // USE_APP_SANDBOX } - (void)applicationWillTerminate:(NSNotification*)notification @@ -119,6 +123,7 @@ [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://www.bluestatic.org/software/macgdbp/help/"]]; } +#if USE_APP_SANDBOX /** * Activates any secure file access bookmarks stored in preferences. */ @@ -154,5 +159,6 @@ [NSUserDefaults.standardUserDefaults setObject:bookmarks forKey:kPrefFileAccessBookmarks]; } +#endif // USE_APP_SANDBOX @end diff --git a/Source/DebuggerController.m b/Source/DebuggerController.m index 0a2cedb..67875d8 100644 --- a/Source/DebuggerController.m +++ b/Source/DebuggerController.m @@ -410,9 +410,11 @@ - (void)error:(NSError*)error whileHighlightingFile:(NSString*)file { +#if USE_APP_SANDBOX if (error.code == NSFileReadNoPermissionError) { [FileAccessController showFileAccessDialog]; } +#endif // USE_APP_SANDBOX } @end diff --git a/Source/FileAccessController.h b/Source/FileAccessController.h index 744795a..1230f38 100644 --- a/Source/FileAccessController.h +++ b/Source/FileAccessController.h @@ -14,6 +14,8 @@ * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#if USE_APP_SANDBOX + #import @interface FileAccessController : NSWindowController @@ -22,3 +24,5 @@ - (IBAction)openFileAccess:(id)sender; @end + +#endif diff --git a/Source/FileAccessController.m b/Source/FileAccessController.m index 9ec95c6..4e1d078 100644 --- a/Source/FileAccessController.m +++ b/Source/FileAccessController.m @@ -14,6 +14,8 @@ * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#if USE_APP_SANDBOX + #import "FileAccessController.h" #import "AppDelegate.h" @@ -66,3 +68,5 @@ } @end + +#endif // USE_APP_SANDBOX diff --git a/Source/PreferenceNames.h b/Source/PreferenceNames.h index c236181..fa75db1 100644 --- a/Source/PreferenceNames.h +++ b/Source/PreferenceNames.h @@ -25,11 +25,13 @@ extern NSString* const kPrefInspectorWindowVisible; // NSMutableArray of path replacements. extern NSString* const kPrefPathReplacements; +#if USE_APP_SANDBOX // NSMutableDictionary of NSString paths to NSData file access bookmarks. extern NSString* const kPrefFileAccessBookmarks; // NSDate of last showing the FileAccessController on startup. extern NSString* const kPrefFileAccessStartupShowDate; +#endif // USE_APP_SANDBOX // NSNumber bool for whether to stop the debugger on the first line of the // program. diff --git a/Source/PreferenceNames.m b/Source/PreferenceNames.m index e2958b5..d5ded44 100644 --- a/Source/PreferenceNames.m +++ b/Source/PreferenceNames.m @@ -22,9 +22,11 @@ NSString* const kPrefInspectorWindowVisible = @"InspectorWindowVisible"; NSString* const kPrefPathReplacements = @"PathReplacements"; +#if USE_APP_SANDBOX NSString* const kPrefFileAccessBookmarks = @"FileAccessBookmarks"; NSString* const kPrefFileAccessStartupShowDate = @"FileAccessStartupShowDate"; +#endif // USE_APP_SANDBOX NSString* const kPrefBreakOnFirstLine = @"BreakOnFirstLine"; diff --git a/Source/PreferencesController.h b/Source/PreferencesController.h index 34241fe..dcc3873 100644 --- a/Source/PreferencesController.h +++ b/Source/PreferencesController.h @@ -35,7 +35,9 @@ - (IBAction)addFileAccess:(id)sender; +#if USE_APP_SANDBOX + (NSData*)secureBookmarkDataForURL:(NSURL*)url; +#endif // panel switching - (IBAction)showGeneral:(id)sender; diff --git a/Source/PreferencesController.m b/Source/PreferencesController.m index 4a69529..092ed9f 100644 --- a/Source/PreferencesController.m +++ b/Source/PreferencesController.m @@ -37,7 +37,13 @@ - (void)awakeFromNib { _generalSize = self.generalPreferencesView.frame.size; +#if USE_APP_SANDBOX _fileAccessSize = self.fileAccessPreferencesView.frame.size; +#else + NSUInteger i = [self.toolbar.items indexOfObject:self.fileAccessPreferencesItem]; + if (i != NSNotFound) + [self.toolbar removeItemAtIndex:i]; +#endif _pathsSize = self.pathsPreferencesView.frame.size; } @@ -58,6 +64,7 @@ */ - (IBAction)addFileAccess:(id)sender { +#if USE_APP_SANDBOX NSOpenPanel* panel = [NSOpenPanel openPanel]; panel.canChooseDirectories = YES; panel.canChooseFiles = NO; @@ -74,8 +81,12 @@ pair.key = url.absoluteString; pair.value = secureBookmark; [self.fileAccessController addObject:pair]; +#else + NSAssert(NO, @"not reached"); +#endif } +#if USE_APP_SANDBOX + (NSData*)secureBookmarkDataForURL:(NSURL*)url { NSError* error; @@ -88,6 +99,7 @@ } return secureBookmark; } +#endif // USE_APP_SANDBOX #pragma mark Panel Switching @@ -101,7 +113,11 @@ - (IBAction)showFileAccess:(id)sender { +#if USE_APP_SANDBOX [self _switchToView:self.fileAccessPreferencesView resizeTo:_fileAccessSize forToolbarItem:self.fileAccessPreferencesItem]; +#else + NSAssert(NO, @"not reached"); +#endif } /** @@ -121,7 +137,9 @@ { return @[ self.generalPreferencesItem.itemIdentifier, +#if USE_APP_SANDBOX self.fileAccessPreferencesItem.itemIdentifier, +#endif self.pathsPreferencesItem.itemIdentifier, ]; } -- 2.43.5