Launch Services regression: Cannot open files & URLs remotely

Originator:reppepreppep
Number:rdar://7208629 Date Originated:09-Sep-2009 10:21 AM
Status: Resolved:
Product:Mac OS X Product Version:10.6 (10a432)
Classification:Serious Bug Reproducible:Always
 
09-Sep-2009 10:21 AM Chris Pepper:
In 10.6, I cannot use the 'open' command to open files or URLs remotely (with the screensaver locked) -- only when sitting in front of the Mac.

pepper@prowler:~$ open http://www.apple.com/
LSOpenURLsWithRole() failed with error -600 for the URL http://www.apple.com/.
pepper@prowler:~$ open -a Safari 'http://www.benbellabooks.com/bookstore/cart.php?m=product_detail&p=594'
LSOpenURLsWithRole() failed for the application /Applications/Safari.app with error -600 for the URL http://www.benbellabooks.com/bookstore/cart.php?m=product_detail&p=594.
pepper@prowler:~$ open -a Safari LSOpenURLsWithRole() failed for the application /Applications/Safari.app with error -600.
pepper@prowler:~$ open /Applications/Safari.app/
LSOpenURLsWithRole() failed with error -600 for the file /Applications/Safari.app.
pepper@prowler:~$ open Documents
LSOpenURLsWithRole() failed with error -600 for the file /Users/pepper/Documents.
pepper@prowler:~$ open -a iPhoto
pepper@prowler:~$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.6
BuildVersion:	10A432

I have had this issue for a while with 10.6 betas, but it worked in Leopard. Note that opening iPhoto still works.


'reppep.prowler.10A432.2009-09-06.spx' was successfully uploaded

29-Sep-2009 12:04 PM Chris Pepper:
I have verified the same issue affects my work system as well, and that even 'ssh localhost' prevents most 'open' commands from working.

pepper@teriyaki:~$ open Desktop/ # succeeds
pepper@teriyaki:~$ ssh localhost
Last login: Tue Sep 29 11:54:14 2009 from teriyaki.mskcc.org
pepper@teriyaki:~$ open Desktop/
LSOpenURLsWithRole() failed with error -600 for the file /Users/pepper/Desktop.
pepper@teriyaki:~$ open -a iPhoto # succeeds
pepper@teriyaki:~$

Comments

procNotFound

Error -600 is a Process Manager error, procNotFound: no eligible process with specified descriptor. The Process Manager only knows about applications with a connection to the window manager. When you're in an ssh session, you do not have a connection to the window manager. The gory details are in TN2083, "Daemons and Agents".

Looking there, this appears to be a regression from Mac OS X 10.5:

Process Manager and Launch Services

Historically, neither Process Manager nor Launch Services were daemon safe. This represents a significant gotcha for daemon writers who, quite reasonably, expect that process services should be available to a daemon. However, if you look at the these APIs in their historical context, you can understand why this restriction existed.

Consider the Process Manager routine GetNextProcess. Numerous programs, from both Apple and third parties, use this routine to display a list of running applications. It wouldn't make sense for this list to show applications running in other GUI login sessions. Thus, this routine uses the bootstrap namespace as an implicit parameter to determine the login session, and hence the list of running applications to return.

Launch Services, which is layered on top of the Process Manager, had similar issues.

Thus, both Process Manager and Launch Services have, historically, been located in the ApplicationServices framework, and were not available to daemons.

Apple recognizes that this restriction is quite inconvenient and is working to improve things. Mac OS X 10.5 represents the first step on that path. Specifically, the underlying implementation of Process Manager has moved from the window server to the CoreServices daemon (coreservicesd). With this change, it is now possible to create daemon-safe system services that deal with Process Manager processes.

The first beneficiary of this change in Launch Services. In Mac OS X 10.5 Launch Services has been moved down to the Core Services layer (it is now a subframework of the CoreServices framework). Thus, it is now daemon-safe.

This raises the question of what happens when you use Launch Services to launch an application from a daemon. Because the daemon is running in the global bootstrap namespace, Launch Services can't use the bootstrap namespace to derive the login session. Rather, Launch Services uses the EUID of the calling process. The behavior is as follows:

  • If the EUID of the calling process is zero, the application is launched in the context of the currently active GUI login session. If there is no currently active GUI login session (no one is logged in, or a logged in user has fast user switched to the login window), the behavior is unspecified (r. 5321293) .
  • If the EUID of the calling process is not zero and it matches that of a user logged in via the GUI, the application is launched in the context of that user's GUI login session.
  • If the EUID of the calling process is not zero but it does not match that of a user logged in via the GUI, the behavior is unspecified (r. 5321281) .

Unfortunately, while the underlying implementation of Process Manager is now at the CoreServices layer, Process Manager itself remains in the ApplicationServices framework. Thus, it's still not possible to use Process Manager from a daemon.

By jeremyw.sherman at Sept. 30, 2009, 2:31 p.m. (reply...)

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!