• 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: Subclassing NSUserDefaultsController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subclassing NSUserDefaultsController


  • Subject: Re: Subclassing NSUserDefaultsController
  • From: Thomas Bauer <email@hidden>
  • Date: Sun, 27 Sep 2009 12:23:34 +1300

Hi!

Thanks for your response.
Sorry, I did not point out clearly enough that in my case the code would run with root privileges.
Thanks for the pointer to EUID. I was not aware of that... and that might be a solution.


Independently - it still puzzles me that it does not seem to be possible to override the class of the userdefaultscontroller.

Regards
Thomas

On 21/09/2009, at 3:44 AM, James Bucanek wrote:

Thomas Bauer <mailto:email@hidden> wrote (Sunday, September 20, 2009 2:39 AM +1200):

In some cases my application needs to modify and get the user defaults from a
different user than the one it is launched under. Since this affects not only
things done programmatically, but also parts of the user interface that use
bindings, I was thinking an elegant solution would be to make the
SharedDefaults controller be a subclass and override the designated init
method to either be initialized by sharedDefaults or a NSDefaults object
created with initWithUser. Unfortunately this does not seem to work on a basic
level.

At that basic level, this should never work. Your user (UID) should never, under normal circumstances, have access to any non-public files belonging to another user, especially not their ~/Library folder. So even if you could coerce NSUserDefaults or CFPerferences to access the file, the basic security model of Mac OS X / BSD would prevent them from reading or changing it.


The straightforward solution is to create a SetUID helper or daemon process that you can launch and will run as that other user. It could be an SUID->root process that dynamically changes its EUID to the user you need to affect, or be a pre-configured SUID->user (probably the easiest solution) that always runs as that particular user. Your process could launch the helper then communicate what changes you need to make via inter-process messaging.

--
James Bucanek


_______________________________________________

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: 
 >Re: Subclassing NSUserDefaultsController (From: James Bucanek <email@hidden>)

  • Prev by Date: Pain-Free Core Data derived properties (pre-alpha)
  • Next by Date: Re: OR compositing operation?
  • Previous by thread: Re: Subclassing NSUserDefaultsController
  • Next by thread: Thank you
  • Index(es):
    • Date
    • Thread