Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > Mac Programmer Help > Re: CFPreferenc...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 7 Topic 3782 of 3835
Post > Topic >>

Re: CFPreferencesAppSynchronize failed

by Gregory Weston <uce@[EMAIL PROTECTED] > Jun 24, 2008 at 07:23 AM

In article 
<a324b77a-303c-4c44-8f7c-41bb459a0bd9@[EMAIL PROTECTED]
>,
 p2 <pradip.patel@[EMAIL PROTECTED]
> wrote:

> Hi
> 
> I wrote following code. Also, I have created com.p1.myapp.plist from
> admin user at /Library/Preferences and has 666 permission.
> 
> SInt kColor = 5;
> const CFStringRef kAppName = CFSTR("com.p1.myapp");
> const CFStringRef kPrefColor = CFSTR("color");
> CFNumberRef value = CFNumberCreate(NULL, kCFNumberSInt8Type, &kColor);
> 
> CFPreferencesSetValue( kPrefColor, value, kAppName,
> kCFPreferencesAnyUser, kCFPreferencesCurrentHost);
> 
> CFPreferencesAppSynchronize(kAppName); // this will fail ,return
> false  in Non- admin
> 
> above code is working in Tiger Non-Admin but failed in Leopard Non-
> Admin
> 
> Is there any change ?
> My target is to change preferences for Any user(/Library/Preferences/)
> from non-admin account , How can i achieve this ?
> 
> p2

I think you're wrong about it working for a non-admin user in Tiger, 
since:
a) It's do***ented that you can't save such changes: "Note that you can 
only save preferences for łAny User˛ if you have Admin privileges."
b) I've been using that routine since (at least) 10.2 and it has behaved 
as do***ented.

So I'd say either it's not saving or your 10.4 user *is* an admin 
despite what you think.

Your options are:
a) Only save this change when running as an admin user; if the synch 
fails, fall back to user-local storage.
b) Write someplace else, essentially recreating a ****tion of the 
CFPreferences API.
c) Use some form of privilege escalation like a single-purpose setuid 
tool running as root to save this setting.

I advocate course (a) unless it's critical that this value be identical 
for all users. (b) and (c) both have shortcomings that are beyond the 
scope of this message - the increased complexity in comparison to (a) is 
probably the least of your worries.

-- 
"Harry?" Ron's voice was a mere whisper. "Do you smell something ...
burning?"
   - Harry Potter and the Odor of the Phoenix
 




 7 Posts in Topic:
CFPreferencesAppSynchronize failed
p2 <pradip.patel@[EMAI  2008-06-24 03:13:06 
Re: CFPreferencesAppSynchronize failed
Gregory Weston <uce@[E  2008-06-24 07:23:10 
Re: CFPreferencesAppSynchronize failed
p2 <pradip.patel@[EMAI  2008-06-24 04:54:32 
Re: CFPreferencesAppSynchronize failed
p2 <pradip.patel@[EMAI  2008-06-25 22:46:12 
Re: CFPreferencesAppSynchronize failed
Gregory Weston <uce@[E  2008-06-26 09:33:21 
Re: CFPreferencesAppSynchronize failed
p2 <pradip.patel@[EMAI  2008-06-25 23:06:02 
Re: CFPreferencesAppSynchronize failed
Gregory Weston <uce@[E  2008-06-26 09:19:22 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Aug 29 13:54:18 CDT 2008.