MacOS – Run a Cocoa application on Lion as another user

bashmacos

I'm trying to run an application as the user 'steve' with the window displayed on my desktop ( brendan ).

This is what I have been doing so far.

sudo -u steve open -a /Path/To/MyApplication.app

No matter which application I try, it always runs with my privileges and not steve's, which is not what I want. The process is owned by me, even though I executed open under 'sudo -u steve' .

How can I simply execute a command from the console that will open any application with different user's privileges ( steve being the owning user of the process )?

Also, GUI tools such as RunAs and Peek-A-Boo ( I think that's what it was called, very similar ) are not an option. This command must be launched from a bash/zsh/python/whatever script.

Thanks!

Best Answer

The easiest way I'm aware of is to use the full path to the executable. For example:

$ sudo -u steve "/Path/To/MyApplication.app/Contents/MacOS/MyApplication"

That definitely works (I've just tested it with several applications under Lion).