I am trying to use the Security framework to authorize my program for
task_for_pid() without adding the current user to the procmod group
from the command line.  I am running OSXv10.4.11 on an Intel MacBook.

[code]
#import <Security/Authorization.h>
#import <mach/mach.h>

@implementation auth_obj

-(IBAction)auth_tfp:(id)sender {
    AuthorizationRef myAuthorizationRef;
    OSStatus myStatus;
    myStatus = AuthorizationCreate (NULL, kAuthorizationEmptyEnvironment,
        kAuthorizationFlagDefaults, &myAuthorizationRef);
    NSLog( @"AuthorizationCreate:%d\n", myStatus);
    
    AuthorizationItem myItems[1];
    //system.privilege.taskport found on random website
    myItems[0].name = "system.privilege.taskport";
    myItems[0].valueLength = 0;
    myItems[0].value = NULL;
    myItems[0].flags = 0;    
    
    AuthorizationRights myRights;
    myRights.count = sizeof (myItems) / sizeof (myItems[0]);
    myRights.items = myItems;
    
    AuthorizationFlags myFlags;
    myFlags = kAuthorizationFlagDefaults |
        kAuthorizationFlagInteractionAllowed |
        kAuthorizationFlagExtendRights;
    
    myStatus = AuthorizationCopyRights (myAuthorizationRef, &myRights,
        kAuthorizationEmptyEnvironment, myFlags, NULL);
    NSLog( @"AuthorizationCopyRights:%d\n", myStatus);
    
    mach_port_t    remoteTask = 0;
    int err = task_for_pid( mach_task_self(), 6840, &remoteTask );
    if (err == 5) {
        printf("Could not access task for pid %d. You probably need to add user 
to procmod group\n", 6840);
    } else {
        printf("task_pid_success\n");
    }
    
    //myStatus = AuthorizationFreeItemSet (myItems);
    myStatus = AuthorizationFree (myAuthorizationRef,  
kAuthorizationFlagDestroyRights);
    NSLog( @"AuthorizationCopyRights:%d\n", myStatus);
    
    NSLog ( @" done auth" );
}
@end
[/code]

i am expecting the output to be:
2008-07-17 23:29:06.949 auth_tfp[7439] AuthorizationCreate:0
2008-07-17 23:29:12.580 auth_tfp[7439] AuthorizationCopyRights:0
task_pid_success
2008-07-17 23:29:12.581 auth_tfp[7439] AuthorizationCopyRights:0
2008-07-17 23:29:12.581 auth_tfp[7439]  done auth

but the output is:
2008-07-17 23:29:06.949 auth_tfp[7439] AuthorizationCreate:0
2008-07-17 23:29:12.580 auth_tfp[7439] AuthorizationCopyRights:0
Could not access task for pid 6840. You probably need to add user to procmod 
group
2008-07-17 23:29:12.581 auth_tfp[7439] AuthorizationCopyRights:0
2008-07-17 23:29:12.581 auth_tfp[7439]  done auth

i do not want to add the user to the procmod group.  just gain authorization to 
call task_for_pid once.

is
the security framework the correct method for gaining this access?  if
so, what am i doing wrong?  if not, what method should i use?


      
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to