In article
<7001248a-c287-43c9-a160-088658f9b54c@[EMAIL PROTECTED]
>,
p2 <pradip.patel@[EMAIL PROTECTED]
> wrote:
> On Jun 24, 4:23 pm, Gregory Weston <u...@[EMAIL PROTECTED]
> wrote:
> > In article
> > <a324b77a-303c-4c44-8f7c-41bb459a0...@[EMAIL PROTECTED]
>,
> >
> >
> >
> >
> >
> > p2 <pradip.pa...@[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- 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


|