Re: Security framework refuses to work at all
Re: Security framework refuses to work at all
- Subject: Re: Security framework refuses to work at all
- From: email@hidden
- Date: Fri, 25 Oct 2002 09:31:51 +0200
On vendredi, octobre 25, 2002, at 07:03 AM, Jan Van Boghout wrote:
On jeudi, octobre 24, 2002, at 10:10 PM, Jan Van Boghout wrote:
Hi,
I am trying to get authentication working in my app, but it simply
won't work. I have another app which uses it too, and there it works
fine.
What do you mean by it's not working?
It's on vacation?
Is the Authentication dialog not appearing?
Indeed, no dialog ever shows up and I have no clue why it won't
This is the typical code I'm using for authentication (taken from an
article on Stepwise IIRC) and which has been working in multiple apps:
- (void) initPrivilege
{
AuthorizationRights rights;
AuthorizationFlags flags;
OSStatus err;
_authorizationRef_=NULL;
// We just want the user's current authorization environment,
// so we aren't asking for any additional rights yet.
rights.count=0;
rights.items = NULL;
flags = kAuthorizationFlagDefaults;
err = AuthorizationCreate(&rights, kAuthorizationEmptyEnvironment,
flags, &_authorizationRef_);
}
AuthorizationRights rights;
AuthorizationFlags flags;
OSStatus err;
char * commandPath[4] = {
"/bin/mv",
"/bin/mkdir",
"/bin/chmod",
"/usr/sbin/chown"
};
AuthorizationItem item[4];
int i;
for(i=0;i<4;i++)
{
item[i].name = kAuthorizationRightExecute;
item[i].value = commandPath[i];
item[i].valueLength = strlen(commandPath[i]);
item[i].flags = 0;
}
rights.count=4;
rights.items = item;
flags = kAuthorizationFlagInteractionAllowed|
kAuthorizationFlagExtendRights;
// Here, since we've specified kAuthorizationFlagExtendRights
and
// have also specified kAuthorizationFlagInteractionAllowed, if
the
// user isn't currently authorized to execute tools as root
// (kAuthorizationRightExecute),they will be asked for their
password.
// The err return value will indicate authorization success or
failure.
err = AuthorizationCopyRights(_authorizationRef_,&rights,
kAuthorizationEmptyEnvironment,
flags, NULL);
if (errAuthorizationSuccess==err)
{
isAuthorized_=YES;
....
_______________________________________________
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.