AuthorizationExecuteWithPrivileges flag error
AuthorizationExecuteWithPrivileges flag error
- Subject: AuthorizationExecuteWithPrivileges flag error
- From: sheen mac <email@hidden>
- Date: Wed, 30 Jul 2008 06:16:53 -0700 (PDT)
Hi All,
In my project , I added an executable and created AuthorizationRef
successfully.The AuthorizationCopyRights also worked without
error.But when AuthorizationExecuteWithPrivileges , it shows
the invalid flags error.
Kindly help me.
Thanks In Advance,
Sheen
OSStatus status;AuthorizationRef auth;
AuthorizationExternalForm extAuth;
if (geteuid() != 0) {
setuid(0);
}
if (fread(&extAuth, sizeof(extAuth), 1, stdin) != 1)
exit(-1);
if (AuthorizationCreateFromExternalForm(&extAuth, &auth))
exit(-1);
AuthorizationItem right = { RIGHT, 0, NULL, 0 };
AuthorizationRights rights = { 1, &right };
AuthorizationFlags flags = kAuthorizationFlagDefaults | kAuthorizationFlagExtendRights;
if (status = AuthorizationCopyRights(auth, &rights, kAuthorizationEmptyEnvironment, flags, NULL)) {
exit(-1);
}
char* args[3];
OSStatus err = 0;
FILE* iopipe;
args[0] = "-w";
args[1]="net.inet.ip.forwarding=1";
args[2]=NULL;
err = AuthorizationExecuteWithPrivileges(auth,
"/usr/sbin/sysctl",
flags, args, &iopipe);
if(err!=errAuthorizationSuccess)
fprintf(stderr,"failed\n");
_______________________________________________
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