Re: Security-scoped bookmark and screensaver

2024-01-03 Thread Gabriel Zachmann via Cocoa-dev

>>
>> For that user, the directory for which my screensaver creates the bookmark 
>> is on an external HD.
>
> Is that use running 10.10? Googling reveals a bug resolving SSBs on external 
> drives that was fixed in 10.11.6.

He is running 10.14

Best regards, Gabriel




smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Security-scoped bookmark and screensaver

2024-01-03 Thread Steve Mills via Cocoa-dev
> On Jan 3, 2024, at 06:20, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> From one of the users of my screensaver, I get the issue report that 
> resolving the SSB does not work.
> He is running macOS 10.14.6 on a Mac Mini.
> I have compiled my screensaver using the current version of Xcode, under 
> macOS 14, but for the target macOS 10.13.
> 
> When my screensaver tries to resolve the bookmark, I get the infamous 
>  Code=259 "The File couldn't be opened because it isn't in the correct 
> format."
> 
> This happens, when my screensaver is launched by the ScreenSaverEngine.
> When my screensaver is running in System Preferences, in the thumbnail 
> window, everything is fine, and resolving the bookmark works, of course.
> Also, there are other users of my screensaver (including me), where it runs 
> just fine.
> 
> For that user, the directory for which my screensaver creates the bookmark is 
> on an external HD.

Is that use running 10.10? Googling reveals a bug resolving SSBs on external 
drives that was fixed in 10.11.6.

It’s been a while since I’ve dealt with SSBs, but do you even need them for 
external devices? You also didn’t say if you tried to duplicate the user 
problem by using your own external drive. If you can, then you need to find the 
work-around.

Steve via iPad

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Security-scoped bookmark and screensaver

2024-01-03 Thread Gabriel Zachmann via Cocoa-dev
From one of the users of my screensaver, I get the issue report that resolving 
the SSB does not work.
He is running macOS 10.14.6 on a Mac Mini.
I have compiled my screensaver using the current version of Xcode, under macOS 
14, but for the target macOS 10.13.

When my screensaver tries to resolve the bookmark, I get the infamous
  Code%9 "The File couldn't be opened because it isn't in the correct format."

This happens, when my screensaver is launched by the ScreenSaverEngine.
When my screensaver is running in System Preferences, in the thumbnail window, 
everything is fine, and resolving the bookmark works, of course.
Also, there are other users of my screensaver (including me), where it runs 
just fine.

For that user, the directory for which my screensaver creates the bookmark is 
on an external HD.

Below is the source code showing how I create/resolve bookmarks.

Any ideas what I could try (or the user) will be highly appreciated.

Best regards, Gabriel


Create bookmark:

NSData * dir_bookmark = [dir bookmarkDataWithOptions: 
NSURLBookmarkCreationWithSecurityScope
   includingResourceValuesForKeys: nil
relativeToURL: nil
error: &systemError];

[no problems occur here]


Resolve bookmark:

NSURL * dir_location = [NSURL URLByResolvingBookmarkData: bookmark
   options: 
NSURLBookmarkResolutionWithSecurityScope
 relativeToURL: nil
   bookmarkDataIsStale: & isStale
 error: & error];

[at this point, dir_location == nil, and I get the error code 259.
I can still extract the path using this code:

NSDictionary * dict = [NSURL resourceValuesForKeys: [NSArray 
arrayWithObjects: NSURLPathKey, nil]
  fromBookmarkData: bookmark ];
.. = [NSString stringWithFormat: @"Orig path: %@", [dict 
objectForKey: NSURLPathKey];




smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com