Re: [Q] SFPreferenceView and authorize as admin?
Re: [Q] SFPreferenceView and authorize as admin?
- Subject: Re: [Q] SFPreferenceView and authorize as admin?
- From: Jean-Daniel Dupas <email@hidden>
- Date: Thu, 21 Aug 2008 19:02:17 +0200
Most of the authorizations question on this list have the same answer.
It's not and will never be possible to increase the rights of a
running process (for obvious security reasons). System Preferences
(your host process) run as the current user, so it cannot access
protected locations.
Have a look at “Performing Privileged Operations With Authorization
Services" to find a way to do what you want.
http://developer.apple.com/documentation/Security/Conceptual/authorization_concepts/01introduction/chapter_1_section_1.html
Le 21 août 08 à 18:35, JongAm Park a écrit :
I don't think it is not possible.. but.. does anyone know how to?
Thank you.
-------- Original Message --------
Subject: [Q] SFPreferenceView and authorize as admin?
Date: Wed, 20 Aug 2008 14:53:34 -0700
From: JongAm Park <email@hidden>
To: cocoa-dev <email@hidden>
Hello, all.
Does any of you know how to authorize a user as an admin user using
the SFPreferenceView?
I'm writing a preference pane for the System Preference.
What this custom preference pane does are :
- Display system wide setting, but until a user clicks the "lock"
icon, a user is not allowed to change it.
When the user clicks the "lock" icon, it asks ID and password.
( This is done by the SFPreferenceView. )
- Display user-specific setting and allows changing them
- When the user choose other preference pane, it saves the system-
wide setting and the user-specific setting.
To save the system-wide setting, I used :
CFPreferenceSetValue( CFSTR("System Name", [systemNameField
stringValue], kAppID, kCFPreferencesAnyUser,
kCFPreferencesAnyHost );
isSuccessful = CFPreferencesSynchronize( kAppID,
kCFPreferencesAnyUser, kCFPreferencesAnyHost );
Currently the SFPreferenceView is initialized like :
[authView setDelegate:self];
[authView setString:appID_UTF8_CString];
[authView updateStatus:self];
[authView setEnabled:YES];
For being sure, I also obtain the authorization from the authView
and tried setting kAuthorizationRuleAuthenticateAsAdmin.
SFAuthorization *authorization = [authView authorization];
AuthorizationRef authRef = [authorization authorizationRef];
AuthorizationRights *authRights = [authView authorizationRights];
CFStringRef keys[2] = { CFSTR(kAuthorizationRightRuel),
CFSTR(kAuthorizationComment)};
CFStringRef values[2] = {
CFSTR(kAuthorizationRuleAuthenticateAsAdmin), CFSTR("Authorize as
Admin") };
CFDictionaryRef dictRef = CFDictionaryCreate( NULL, (void *)keys,
(void *)values, 2, &kCFCopyStringDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
// To modify the authorization of the authView, the authRef is used.
result = AuthorizationRightSet( authRef, authRights->items[0].name,
dictRef, CFSTR("Authorize as an admin"), NULL, NULL );
Although it returns 1 for the isSuccessful, it doesn't create a
plist file in /Library/Preferences directory for the system-wide
setting.
Can anyone help me?
Thank you.
_______________________________________________
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
_______________________________________________
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