Debugging on Snow Leopard: getting task_for_pid() to work
Thursday, August 12, 2010 at 08:30PM Acquiring debug privileges on Snow Leopard is a bit of a pain. You have to follow the following steps:
- Create a code signing certificate in your login keychain.
- Find your .plist file in XCode and add a new entry "SecTaskAccess" and set it to "allowed". Make sure the Info.plist file generated in your bundle actually has this value in it.
- Make XCode sign the executable during the build process, or sign it yourself manually using the codesign command line utility.
- Call the following method before making calls to task_for_pid()
int { OSStatus status; AuthorizationItem taskport_item[] = {{"system.privilege.taskport"}}; AuthorizationRights rights = {1, taskport_item}, *out_rights = NULL; AuthorizationRef author; AuthorizationFlags authorizationFlags = kAuthorizationFlagExtendRights | kAuthorizationFlagPreAuthorize | kAuthorizationFlagInteractionAllowed | (1 << 5); status = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, authorizationFlags, &author); if { return 0; } status = AuthorizationCopyRights(author, &rights, kAuthorizationEmptyEnvironment, authorizationFlags, &out_rights); if { return 1; } return 0; } |

