• 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
Re: Getting the path to an application with a launchDaemon
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting the path to an application with a launchDaemon


  • Subject: Re: Getting the path to an application with a launchDaemon
  • From: Jens Alfke <email@hidden>
  • Date: Fri, 27 Nov 2009 23:06:12 -0800

On Nov 27, 2009, at 12:08 AM, Zephyroth Akash wrote:

> I'm actually creating a daemon which then runs in root context and I can't get the path to an application.
> The command: [[NSWorkspace sharedWorkspace] absolutePathForAppBundleIdentifier:@"com.myCompany.myApp"]; returns NULL but returns the path to my application bundle correctly if used as a user.

I don't believe NSWorkspace works correctly when run as root. While root is a real userid at the Unix level, it's not intended that anyone ever log into the GUI with that userid, so a lot of the higher-level system frameworks don't support it.

Anyway, in keeping with the "Principle Of Least Privilege", it's best not to run as root if there is any way around it. There's too much danger if anything goes wrong, since you can delete or overwrite anything. Worse, it's all too easy for malware to exploit poorly-written software that runs as root, by tricking it into following the wrong instructions or calling the wrong helper tool. (Plenty of Apple's security-fix system patches have addressed issues like these.)

Can you write your program as a background agent that runs as the currently logged-in user? This is a lot easier and safer. (Frankly, I would avoid using Cocoa APIs for any code that runs as root.)

—Jens_______________________________________________

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

References: 
 >Getting the path to an application with a launchDaemon (From: Zephyroth Akash <email@hidden>)

  • Prev by Date: Re: An Array of structs
  • Next by Date: Re: Global Object
  • Previous by thread: Getting the path to an application with a launchDaemon
  • Next by thread: Invoking ImageKit effects panel
  • Index(es):
    • Date
    • Thread