Open application with lowered privileges

2

I have a mac installer which runs as root with pre and post install bash scripts.

At the end of the post install script I launch the application which inherits and opens as root. Is there a way I can lower the permissions back down to the user that ran the installer and then open the app?

Or a more hackish way I can set the app to open in some scheduler from the script, which then gets opened by the scheduler which would have the users permissions

GP89

Posted 2012-09-24T16:32:35.480

Reputation: 121

No need to ask a new question, just edit this one. I'll remove my comments so as not to confuse people. – Zoredache – 2012-09-24T16:58:54.323

Can you open the application using open, e.g. open -a /Applications/MyApp.app? If you're not installing an .app, you could check out output of env, it probably contains the actual user name. Just su -u $username /path/to/app or something like that. – Daniel Beck – 2012-09-24T17:33:19.103

I'm currently opening the app with open "$APP_DIR". I guess a su -u "$username" "$APP_DIR"? – GP89 – 2012-09-24T17:53:20.193

Answers

0

If you're logged in as root you can use su:

/bin/su -c "open -a App.app" username

Brad Wright

Posted 2012-09-24T16:32:35.480

Reputation: 189