Creating a security-scoped bookmark attempts read-write access

Originator:mike.abdullah
Number:rdar://11929296 Date Originated:21-Jul-2012 02:07 PM
Status:Open Resolved:
Product:Mac OS X Product Version:10.7.3+
Classification:Serious Bug Reproducible:Always
 
Steps to Reproduce:
Try to generate a security-scoped bookmark for which you only have read-only access. e.g. something in the Pictures folder. Our code:

NSData *bookmark = [bookmarkedURL bookmarkDataWithOptions:KSURLBookmarkCreationWithSecurityScope |  KSURLBookmarkCreationSecurityScopeAllowOnlyReadAccess
                                     includingResourceValuesForKeys:nil
                                                      relativeToURL:docURL
                                                              error:&error];
                

Expected Results:
I get back a bookmark which can be later used to restore read-only access to the file

Actual Results:
Bookmark creation fails and a sandbox violation occurs. Internally, the bookmark system tries to open the file for read-write access. Backtrace:

Thread 0:
0   libsystem_kernel.dylib        	0x93bab76e __open + 10
1   CoreFoundation                	0x94b8f812 -[NSURL bookmarkDataWithOptions:includingResourceValuesForKeys:relativeToURL:error:] + 114


24-Jul-2012 10:55 AM Mike Abdullah:
Lots of detail can also be found at https://devforums.apple.com/message/702927

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!