FAQFAQ   SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log in/Register/PasswordLog in/Register/Password

CFPreferencesAppSynchronize failed

 
   Mac (Home) -> Programmer Help RSS
Related Topics:
How to type in ASCII? - Stupid question #2 of the week. I'm trying to avoid writing a printer driver for a barcode label printer. It responds to commands, and I want to embed a command in a page that tells the printer to cut the paper. It's o STX, of course..

applications and windows - Hello. I'm primarily a system unix one. Currently I have to implement the following logic: On Mac OS X enumerate all running only those that are windows. Find which of them is where is defined as..

[ANN] Vice - Graphical Program Priority Adjustment Tool fo.. - Vice is an that allows the user to adjust the priority of programs running on Mac OS X. Normal users can lower the priority of their own programs, while can adjust the priority of any..

NSCursorAttributeName and NSTextView - Well, I've been playing around a little bit with getting URLs in my to actually become clickable links. So far, so good. I set the for my strings that get inserted into the text view: for the link..

adding graphics to my console app - I need to add to my UI, C code). This just means being able to open a window and display data in graphical format. I have a couple of options: 1. Dredge up ancient QuickDraw code I..
Next:  Programmer Help: Happy Hacking Keyboard lite2 for the Mac - problem with in..  
Author Message
p2

External


Since: May 19, 2007
Posts: 45



(Msg. 1) Posted: Tue Jun 24, 2008 3:13 am
Post subject: CFPreferencesAppSynchronize failed
Archived from groups: comp>sys>mac>programmer>help (more info?)

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
Back to top
Login to vote
p2

External


Since: May 19, 2007
Posts: 45



(Msg. 2) Posted: Tue Jun 24, 2008 4:54 am
Post subject: Re: CFPreferencesAppSynchronize failed [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Jun 24, 4:23 pm, Gregory Weston <u....RemoveThis@splook.com> wrote:
> In article
> <a324b77a-303c-4c44-8f7c-41bb459a0....RemoveThis@u12g2000prd.googlegroups.com>,
>
>
>
>
>
>  p2 <pradip.pa....RemoveThis@einfochips.com> 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 documented 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 documented.
>
> 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 portion 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- Hide quoted text -
>
> - Show quoted text -

Hi
Thanks for look in.

I have checked again in Tiger non-admin account, it is working..
the required thing is to give write permission to it..i have given 666
permission to that plist file

p2
Back to top
Login to vote
Gregory Weston

External


Since: Jun 06, 2005
Posts: 481



(Msg. 3) Posted: Tue Jun 24, 2008 7:23 am
Post subject: Re: CFPreferencesAppSynchronize failed [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article
<a324b77a-303c-4c44-8f7c-41bb459a0bd9.TakeThisOut@u12g2000prd.googlegroups.com>,
p2 <pradip.patel.TakeThisOut@einfochips.com> 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 documented 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 documented.

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 portion 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
Back to top
Login to vote
p2

External


Since: May 19, 2007
Posts: 45



(Msg. 4) Posted: Wed Jun 25, 2008 10:46 pm
Post subject: Re: CFPreferencesAppSynchronize failed [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Jun 24, 4:23 pm, Gregory Weston <u... RemoveThis @splook.com> wrote:
> In article
> <a324b77a-303c-4c44-8f7c-41bb459a0... RemoveThis @u12g2000prd.googlegroups.com>,
>
>
>
>
>
>  p2 <pradip.pa... RemoveThis @einfochips.com> 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 documented 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 documented.
>
> 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 portion 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- Hide quoted text -
>
> - Show quoted text -

Hi

I cann't get..it's like to save for individual user.

But I want to save from admin as well as from nonadmin..
Can you please tell me which is the common access path for all users
to save and update preferences ?

please look because it work for 10.4 and not for 10.5

p2
Back to top
Login to vote
p2

External


Since: May 19, 2007
Posts: 45



(Msg. 5) Posted: Wed Jun 25, 2008 11:06 pm
Post subject: Re: CFPreferencesAppSynchronize failed [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Jun 24, 4:23 pm, Gregory Weston <u....DeleteThis@splook.com> wrote:
> In article
> <a324b77a-303c-4c44-8f7c-41bb459a0....DeleteThis@u12g2000prd.googlegroups.com>,
>
>
>
>
>
>  p2 <pradip.pa....DeleteThis@einfochips.com> 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 documented 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 documented.
>
> 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 portion 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- Hide quoted text -
>
> - Show quoted text -

also one more question ,
Can I change the /Library/Preferences permission ? is it feasible ?
how?

p2
Back to top
Login to vote
Gregory Weston

External


Since: Jun 06, 2005
Posts: 481



(Msg. 6) Posted: Thu Jun 26, 2008 9:19 am
Post subject: Re: CFPreferencesAppSynchronize failed [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article
<7001248a-c287-43c9-a160-088658f9b54c DeleteThis @y22g2000prd.googlegroups.com>,
p2 <pradip.patel DeleteThis @einfochips.com> wrote:

> On Jun 24, 4:23 pm, Gregory Weston <u... DeleteThis @splook.com> wrote:
> > In article
> > <a324b77a-303c-4c44-8f7c-41bb459a0... DeleteThis @u12g2000prd.googlegroups.com>,
> >
> >
> >
> >
> >
> >  p2 <pradip.pa... DeleteThis @einfochips.com> 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 documented 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 documented.
> >
> > 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 portion 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- Hide quoted text -
> >
> > - Show quoted text -
>
> also one more question ,
> Can I change the /Library/Preferences permission ? is it feasible ?
> how?

The short answer is: Don't.

The long answer is: It depends when/where you want to change it. If you
want to do it on your machine just once up front, chmod is your friend,
albeit a scruffy, disreputable one that your parents don't like you
hanging out with. If you need your program to be able to do it at
arbitrary times after installation (because the permissions will be
reset on that directory if the user runs a Repair Permissions process or
installs an OS update) you need to see option (c) above. At which point
the real answer would just be to use that technique to write your pref
without compromising the security and stability of the system.

--
"Harry?" Ron's voice was a mere whisper. "Do you smell something ... burning?"
- Harry Potter and the Odor of the Phoenix
Back to top
Login to vote
Gregory Weston

External


Since: Jun 06, 2005
Posts: 481



(Msg. 7) Posted: Thu Jun 26, 2008 9:33 am
Post subject: Re: CFPreferencesAppSynchronize failed [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article
<9e734c7c-9d01-4e15-8d7e-d204cdee1bd7.DeleteThis@a32g2000prf.googlegroups.com>,
p2 <pradip.patel.DeleteThis@einfochips.com> wrote:

> > 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 portion 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.
>
> Hi
>
> I cann't get..it's like to save for individual user.
>
> But I want to save from admin as well as from nonadmin..
> Can you please tell me which is the common access path for all users
> to save and update preferences ?
>
> please look because it work for 10.4 and not for 10.5

I still say it's working for 10.4 because you're not running in the
environment you think you are.

I also still say (a) is the best course unless your program really
*needs* that preference value to be universal. Frankly, I can only think
of a couple of situations where that's the case, and almost all of those
can be handled at installation time.

The only location that it guaranteed to be world-writable on a Mac OS X
system is /Users/Shared. The biggest problem is that the closest we have
to guidelines for writing there is "don't." This can kind of be inferred
by the lack of a domain constant referencing it, and there are very
strong feelings in some quarters about software blindly writing to that
directory.

If (a) isn't viable for you, the correct option is (c). But it's also
the most difficult. Look at the documentation and sample code for the
Authorization API.

--
"Harry?" Ron's voice was a mere whisper. "Do you smell something ... burning?"
- Harry Potter and the Odor of the Phoenix
Back to top
Login to vote
Display posts from previous:   
       Mac (Home) -> Programmer Help All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum
Categories:
 Windows Forums
 Game Forums
 Linux Forums
  Mac Forums
 PDA Forums
 Mobile Forums
  Top  |  Store  |  RSS Feeds RSS  |  Data Feeds  |  Advertise  |  Submit  |  Bookmark  |  Newsletter  |  Contact