• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: task_for_pid return dsChkErr
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: task_for_pid return dsChkErr


  • Subject: Re: task_for_pid return dsChkErr
  • From: abandon <email@hidden>
  • Date: Thu, 5 Jun 2008 16:26:08 +0800

Oh, when I run this with sudo, it works well. And I found this comment in /private/etc/authorization:
Used by task_for_pid(...). Task_for_pid is called by programs requesting full control over another program for things like debugging or performance analysis. This authorization only applies if the requesting and target programs are run by the same user; it will never authorize access to the program of another user.


But why task_for_pid() still failed though same user? How does gdb can work without sudo? I just want to implement a tool to collect some information of my application.

On 2008-6-5, at 下午3:30, Jean-Daniel Dupas wrote:



I don't think this functions returns an OSStatus, isn't it ?

Using GetMacOSStatusErrorString() will not returns anything usefull, but mach_error_string() will.

Since Mac OS 10.4 Tiger Intel, this function need special rights to be used (for obvious security reasons).

See man taskgated, this is a good starting point to find information about those restrictions.


Le 5 juin 08 à 08:41, abandon a écrit :

Hi, all,

Is task_for_pid still supported on Leopard 10.5.3(9D34)? I found when I call this function it will always return dsChkErr( code 5). Following my simple test program, use gcc test.c -o test -framework carbon to compile and ./test pid to run.

#include <sys/sysctl.h>
#include <mach-o/dyld.h>
#include <mach/mach_traps.h>
#include <mach/mach_init.h>
#include <mach/message.h>
#include <mach/vm_map.h>
#include <mach/vm_region.h>
#include <mach/mach_port.h>
#include <mach-o/fat.h>
#include <mach-o/nlist.h>
#include <Carbon/Carbon.h>

int main(int argc, char* argv[])
{
mach_port_name_t task;
int pid = atoi(argv[1]);
int error = task_for_pid((mach_port_name_t)task_self_trap(), pid, (mach_port_name_t *) &task);
if (error)
{
printf("task_for_pid return error %d : %s\n", error, GetMacOSStatusErrorString(error));
} else {
printf("Get the process %d's task port : %x\n", pid, task);
}
return 0;
}


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: task_for_pid return dsChkErr
      • From: email@hidden
References: 
 >task_for_pid return dsChkErr (From: abandon <email@hidden>)
 >Re: task_for_pid return dsChkErr (From: Jean-Daniel Dupas <email@hidden>)

  • Prev by Date: Re: Compiling msdosfs...
  • Next by Date: Re: task_for_pid return dsChkErr
  • Previous by thread: Re: task_for_pid return dsChkErr
  • Next by thread: Re: task_for_pid return dsChkErr
  • Index(es):
    • Date
    • Thread