I have a launch daemon that runs in the login context of a Mac OSX 10.6 machine. I want to launch an agent for each user from that agent, and have the agent run in the user's login context. However, I need to control the precise arguments to the agent application very carefully, which is why I cannot use a launchd agent, like I have for the daemon.
How can I create a process that runs in the context of the logged in user? I've trued seteuid
and setuid
calls, but these don't change the execution context of the agent application.
I'm aware that this is not the recommended Apple way of doing things, but I don't really have a choice in the matter - the design of the daemon application is pretty inflexible (it has to run across many different systems). Is there a workaround that allows me to run an application in the GUI context of a logged in user, from a daemon which is running in the login context?
I'm using C++, Carbon & Cocoa.