Re: Preventing the writing of the NSUserDefaults
Re: Preventing the writing of the NSUserDefaults
- Subject: Re: Preventing the writing of the NSUserDefaults
- From: Gerben Wierda <email@hidden>
- Date: Sun, 24 Mar 2002 19:09:43 +0100
On Sunday, March 24, 2002, at 04:33 , Eric Peyton wrote:
What do you want to do instead? Write them someplace else?
NSUserDefaults is just a convenience, you can create your own defaults
in whatever manner you choose (use a Dictionary to store them and write
them out use NSDictionaries writeToFile: method, etc.), however, I
don't believe you will be able to easily extend or change
NSUserDefaults without dropping down to the CFPreferences level ...
No. the problem is that the app under certain circumstances is launched
by AuthorizationExecuteWithPrivileges(), in other words, it runs with a
different effective uid (root) than the real uid. The NSUserDefaults
file is then written with owner root and mode 600, but in the user's
~/Library/Preferences. This is bad, if the app also is run non-setuid
sometimes.
I either need to make sure I control completely the writing of
~/Library/Preferences/appid.plist, or when the app finishes, but after
it has written the defaults database, I need to change ownership of that
file.
The alternative is to make sure the app runs with real uid root as well
(setuid(geteuid())), but that means it will not use the user's settings
for how it looks (blue, graphite, etc).
So, I do not need to do preferences, but I need to know what part of
Cocoa triggers preferences storage and how.
I know some part of Cocoa send 'synchronize' message to the user
defaults once in a while. Who? When? Can I set a delegate for a
NSUserDefaults object and catch that method? Or is there a notification
I can catch in my Application delegate? Or can I subclass NSUserDefaults
and then somehow replace the NSUserDefaults sharedInstance?
G
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.