Revert "For file/line breakpoints, create secure bookmarks for maintaining access."
authorRobert Sesek <rsesek@bluestatic.org>
Sat, 7 Dec 2019 22:46:03 +0000 (17:46 -0500)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 15 Dec 2019 17:08:04 +0000 (12:08 -0500)
However the changes to the .entitlements file are kept.

This reverts commit 1603d8d995220f0b81dcd98915f3d6c8ffe25895.

 Conflicts:
Source/BreakpointManager.m

Source/BSLineNumberRulerView.mm
Source/Breakpoint.h
Source/Breakpoint.m
Source/BreakpointController.m
Source/BreakpointManager.m

index e912b0201a4711a9b659bed13e867975997f82c8..7b1d253d1e2b4a06420cfcedd7356f60b6e53fff 100644 (file)
@@ -141,15 +141,11 @@ const CGFloat kRulerRightPadding = 2.5;
 {
   [self computeLineIndex];
 
-  if (lineIndex_.empty()) {
-    [self setRuleThickness:kDefaultWidth];
-  } else {
-    // Determine the width of the ruler based on the line count.
-    NSUInteger lastElement = lineIndex_.back() + 1;
-    NSAttributedString* lastElementString = [self attributedStringForLineNumber:lastElement];
-    NSSize boundingSize = [lastElementString size];
-    [self setRuleThickness:std::max(kDefaultWidth, boundingSize.width)];
-  }
+  // Determine the width of the ruler based on the line count.
+  NSUInteger lastElement = lineIndex_.back() + 1;
+  NSAttributedString* lastElementString = [self attributedStringForLineNumber:lastElement];
+  NSSize boundingSize = [lastElementString size];
+  [self setRuleThickness:std::max(kDefaultWidth, boundingSize.width)];
 
   [self setNeedsDisplay:YES];
 }
@@ -213,9 +209,6 @@ const CGFloat kRulerRightPadding = 2.5;
     index = NSMaxRange([text lineRangeForRange:NSMakeRange(index, 0)]);
   }
 
-  if (lineIndex_.empty())
-    return;
-
   NSUInteger lineEnd, contentEnd;
   [text getLineStart:NULL
                  end:&lineEnd
index 4a534978f35a5ff2843a2eecec2ca96a29393785..fe2e217190767e5f697d52322d66313fdb089721 100644 (file)
@@ -35,7 +35,6 @@ extern NSString* const kBreakpointTypeFunctionEntry;
 // kBreakpointTypeFile:
 @property (readonly) NSString* file;
 @property (readonly) unsigned long line;
-@property (copy) NSData* secureBookmark;
 
 // kBreakpointTypeFunctionEntry:
 @property (readonly) NSString* functionName;
@@ -51,16 +50,4 @@ extern NSString* const kBreakpointTypeFunctionEntry;
 // Creates a dictionary representation for use in NSUserDefaults.
 - (NSDictionary*)dictionary;
 
-// For kBreakpointTypeFile: ////////////////////////////////////////////////////
-
-// Creates a new secure bookmark for maintaining access to the file in the App
-// Sandbox across relaunches.
-- (BOOL)createSecureBookmark;
-
-// Call to enable read-only access to the file.
-- (BOOL)startSecureFileAccess;
-
-// Call when done accessing the file.
-- (BOOL)stopSecureFileAccess;
-
 @end
index f3cc6753756c90b6093429255ec4c1a79bc69550..744cf5d457482d7482c2c9a0d6f13518ef5b6e4f 100644 (file)
@@ -26,8 +26,6 @@ NSString* const kBreakpointTypeFunctionEntry = @"call";
   unsigned long _debuggerId;
 
   NSString* _file;
-  NSData* _secureBookmark;
-  NSURL* _secureFileAccess;
 
   NSString* _functionName;
 }
@@ -57,7 +55,6 @@ NSString* const kBreakpointTypeFunctionEntry = @"call";
       _type = kBreakpointTypeFile;
       _file = [[dict valueForKey:@"file"] copy];
       _line = [[dict valueForKey:@"line"] intValue];
-      _secureBookmark = [[dict valueForKey:@"secureBookmark"] copy];
     } else if ([type isEqualToString:kBreakpointTypeFunctionEntry]) {
       _type = kBreakpointTypeFunctionEntry;
       _functionName = [[dict valueForKey:@"function"] copy];
@@ -69,11 +66,6 @@ NSString* const kBreakpointTypeFunctionEntry = @"call";
   return self;
 }
 
-- (void)dealloc {
-  if (_secureFileAccess)
-    [self stopSecureFileAccess];
-}
-
 /**
  * Returns the string to display in the breakpoints list.
  */
@@ -132,14 +124,11 @@ NSString* const kBreakpointTypeFunctionEntry = @"call";
 - (NSDictionary*)dictionary
 {
   if (self.type == kBreakpointTypeFile) {
-    NSMutableDictionary* dict = [NSMutableDictionary dictionaryWithDictionary:@{
+    return @{
       @"type" : self.type,
       @"file" : self.file,
-      @"line" : @(self.line),
-    }];
-    if (self.secureBookmark)
-      [dict setObject:self.secureBookmark forKey:@"secureBookmark"];
-    return dict;
+      @"line" : @(self.line)
+    };
   } else if (self.type == kBreakpointTypeFunctionEntry) {
     return @{
       @"type"     : self.type,
@@ -149,66 +138,6 @@ NSString* const kBreakpointTypeFunctionEntry = @"call";
   return nil;
 }
 
-- (BOOL)createSecureBookmark
-{
-  NSURL* fileURL = [NSURL fileURLWithPath:self.file];
-  return [self _createSecureBookmarkWithURL:fileURL];
-}
-
-- (BOOL)_createSecureBookmarkWithURL:(NSURL*)url
-{
-  NSError* error;
-  NSData* secureBookmark = [url bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope | NSURLBookmarkCreationSecurityScopeAllowOnlyReadAccess
-                         includingResourceValuesForKeys:nil
-                                          relativeToURL:nil
-                                                  error:&error];
-  if (secureBookmark) {
-    self.secureBookmark = secureBookmark;
-    return YES;
-  } else {
-    NSLog(@"Failed to create secure bookmark: %@", error);
-    return NO;
-  }
-}
-
-- (BOOL)startSecureFileAccess
-{
-  assert(self.type == kBreakpointTypeFile);
-  if (_secureFileAccess)
-    return YES;
-  if (!_secureBookmark)
-    return NO;
-
-  BOOL isStale;
-  NSError* error;
-  _secureFileAccess = [NSURL URLByResolvingBookmarkData:_secureBookmark
-                                                options:NSURLBookmarkResolutionWithSecurityScope
-                                          relativeToURL:nil
-                                    bookmarkDataIsStale:&isStale
-                                                  error:&error];
-  if (error) {
-    NSLog(@"Failed to access file via secure bookmark: %@", error);
-    return NO;
-  }
-  if (isStale)
-    [self _createSecureBookmarkWithURL:_secureFileAccess];
-
-  return [_secureFileAccess startAccessingSecurityScopedResource];
-}
-
-- (BOOL)stopSecureFileAccess
-{
-  assert(self.type == kBreakpointTypeFile);
-  if (!_secureFileAccess)
-    return YES;
-  if (!_secureBookmark)
-    return NO;
-
-  [_secureFileAccess stopAccessingSecurityScopedResource];
-  _secureFileAccess = nil;
-  return YES;
-}
-
 - (NSString*)description
 {
   return [NSString stringWithFormat:@"Breakpoint %@", [[self dictionary] description]];
index 9e539c87e751078f2cb2ffd5dbf08fb46f62ddd7..516f3a97e93d179d252c08a1f4e4e84cdc01469f 100644 (file)
@@ -21,7 +21,6 @@
 
 @implementation BreakpointController {
   BreakpointManager* _manager;
-  Breakpoint* _selection;
 
   BSSourceView* _sourceView;
 
  */
 - (void)tableViewSelectionDidChange:(NSNotification*)notif
 {
-  if (_selection.type == kBreakpointTypeFile) {
-    [_selection stopSecureFileAccess];
-    _selection = nil;
-  }
-
   NSArray* selection = [_arrayController selectedObjects];
   if ([selection count] < 1) {
-    [_sourceView setString:@"" asFile:nil];
-    [_sourceView setMarkers:[NSSet set]];
     return;
   }
 
-  _selection = [selection objectAtIndex:0];
-  if (_selection.type != kBreakpointTypeFile) {
+  Breakpoint* bp = [selection objectAtIndex:0];
+  if (bp.type != kBreakpointTypeFile) {
     return;
   }
 
-  [_selection startSecureFileAccess];
-
-  [_sourceView setFile:[_selection file]];
-  [_sourceView scrollToLine:[_selection line]];
-  [_sourceView setMarkers:[_manager breakpointsForFile:_selection.file]];
+  [_sourceView setFile:[bp file]];
+  [_sourceView scrollToLine:[bp line]];
+  [_sourceView setMarkers:[_manager breakpointsForFile:bp.file]];
 }
 
 @end
index 2c133f6e75142faf1204b27bff6c6f3f5db4456b..75e6786e2388931b95ee7cd85de9016e7c421c8a 100644 (file)
  */
 - (void)addBreakpoint:(Breakpoint*)bp;
 {
-  if ([_breakpoints containsObject:bp])
-    return;
-
-  if (bp.type == kBreakpointTypeFile && !bp.secureBookmark) {
-    // There is no secure bookmark for this file, so first see if any other
-    // bookmarks exist for the same file. If not, try and create a bookmark.
-    if (!bp.secureBookmark) {
-      [bp createSecureBookmark];
-      /*
-      for (Breakpoint* other in _breakpoints) {
-        if ([other.file isEqualToString:bp.file] && other.secureBookmark) {
-          bp.secureBookmark = other.secureBookmark;
-          break;
-        }
-      }
-
-      if (!bp.secureBookmark) {
-        [bp createSecureBookmark];
-      }
-       */
-    }
-  }
+  if (![_breakpoints containsObject:bp])
+  {
+    [self willChangeValueForKey:@"breakpoints"];
+    [_breakpoints addObject:bp];
+    [self didChangeValueForKey:@"breakpoints"];
 
-  [self willChangeValueForKey:@"breakpoints"];
-  [_breakpoints addObject:bp];
-  [self didChangeValueForKey:@"breakpoints"];
+    [_connection addBreakpoint:bp];
 
-  [_connection addBreakpoint:bp];
+    [_savedBreakpoints addObject:[bp dictionary]];
+    [[NSUserDefaults standardUserDefaults] setObject:_savedBreakpoints forKey:kPrefBreakpoints];
 
-  [_savedBreakpoints addObject:[bp dictionary]];
-  [[NSUserDefaults standardUserDefaults] setObject:_savedBreakpoints forKey:kPrefBreakpoints];
-  [self updateDisplaysForFile:[bp file]];
+    [self updateDisplaysForFile:[bp file]];
+  }
 }
 
 - (Breakpoint*)removeBreakpoint:(Breakpoint*)bp