• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problem with NSWorkspace.shared and uid 0
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with NSWorkspace.shared and uid 0


  • Subject: Problem with NSWorkspace.shared and uid 0
  • From: sqwarqDev <email@hidden>
  • Date: Wed, 13 Dec 2017 10:14:11 +0700

When using the absolutePathForApplication(withBundleIdentifier:) api, I find
that if the path is on an external mount, the api will return nil / none if the
uid is 0, when it will return an actual path when the uid is a valid user login
id (eg, 501, 502 etc).

To reproduce, mount a .dmg containing some app that isn’t on the boot drive,
and insert its bundeID for the value of inputPath in the code below:


import Foundation
import AppKit

let inputPath = “com.some.bundleID"
let pathToApp: String? =
NSWorkspace.shared.absolutePathForApplication(withBundleIdentifier: inputPath)
let result = pathToApp ?? "nil"
print(result)


In Xcode, if I edit the scheme to debug/run as myself, I’ll get a valid result,
but if I edit it to run as root, I’ll get back this error msg:

schedule invalidation <DYTransport 0x10128bcc0, error: lost transport
connection (31)>

I have also tried querying LaunchServices directly with

let altPath = LSCopyApplicationURLsForBundleIdentifier(inputPath as CFString,
&error)

which again returns successfully as me, but as root gives the error:

Error Domain=NSOSStatusErrorDomain Code=-10814 "kLSApplicationNotFoundErr: E.g.
no application claims the file”))

It’s been suggested to me that the problem may be that the LS database isn’t
updated for transient mounts for the root user. That makes sense of the error
messages, but two questions:

1. Should this be considered a bug, or expected behaviour?
2. Any suggestions for a workaround?


TIA



Best


Phil
@sqwarq




_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Problem with NSWorkspace.shared and uid 0
      • From: Jean-Daniel <email@hidden>
    • Re: Problem with NSWorkspace.shared and uid 0
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: Creating NSTableView programmatically
  • Next by Date: Re: Background fetch is never called
  • Previous by thread: Re: Background fetch is never called
  • Next by thread: Re: Problem with NSWorkspace.shared and uid 0
  • Index(es):
    • Date
    • Thread