Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In OS X, how can I determine if an app launched via the open command was launched with elevated permissions?

I tried as an example sudo open http://www.google.com/, but Activity Monitor doesn't seem to display information showing that the Safari process it is running as root.

share|improve this question
    
What do you want to achieve? There's a reason browsers get sandboxed (special lower permissions), running them as root is not usually something you'd want... –  Daniel Beck Jul 21 '12 at 7:01
    
My posted got edited. I don't need a browser to be opened with root permissions. I need a way to determine if an open command was launched with root permissions in OS X. –  Nathan Moinvaziri Jul 22 '12 at 0:59
    
And why do you need a way to know if an open command was launched with root permissions? What are you really trying to do? It's just that in most cases, asking your actual question will give you better answers. That's what I was trying to point out. –  slhck Jul 22 '12 at 1:19
    
We need to verify that the software is launching open with the proper permissions. –  Nathan Moinvaziri Jul 22 '12 at 1:33
add comment

3 Answers

up vote 3 down vote accepted

(Adding a second answer for the clarified question)

When you you used sudo open http://google.com, the the system ran open as root, but open is really just a client for MacOS LaunchServices, which is still running as the logged-in user.

In fact Activity Monitor is showing you that the Safari instance opened by sudo open http:/google.com is not running as root, as the "User" column is showing your username, not root.

You can, however, just invoke Safari directly on the command line with sudo, by-passing Launch Services:

$ sudo /Applications/Safari.app/Contents/MacOS/Safari http://google.com

Now in Activity Monitor, you can confirm that it's running as root.

share|improve this answer
    
Thank you, this is the answer I was looking for: "The system ran open as root, but open is just a client for Mac OS LaunchServices which is still running as the logged in user." –  Nathan Moinvaziri Jul 22 '12 at 1:00
add comment

I'm assuming you mean "running as root". Note that just because you're running as root, doesn't mean you're running at highest priority; nor does using the sudo command necessarily mean the process is running as root.

But those two caveats aside, try this from a Terminal command prompt:

$ ps aux | grep ^root

To filter the process list for those running as root. Or even (depending on your version of Mac OS):

$ ps -u root
share|improve this answer
    
I think the problem might be that when I launch sudo -u root open http://www.google.com/, the browser is not opened under the root user and I'm not sure why not. –  Nathan Moinvaziri Jul 20 '12 at 20:51
    
@NathanMoinvaziri You might just want to ask for your real problem instead of your attempted solution. Why not actually ask how to … do whatever it is that you want? Why do you need a browser to be opened with root permissions? This will most likely get you better answers and will actually solve your real problem. –  slhck Jul 20 '12 at 22:07
    
I never posted an attempted solution so I'm not sure what you are talking about. I don't want to run a browser as root. I want to know why the command was not working as expected. –  Nathan Moinvaziri Jul 22 '12 at 1:02
    
Feel free to delete this answer if it's become irrelevant. By the way: You can always edit your answer – even if it radically changes its content. –  slhck Jul 22 '12 at 1:20
add comment

To see a log of the processess that have been run using sudo you can grep the system.log:

$ grep sudo /var/log/system.log

You can also use the Console application. Select "system.log" from the log list and type "sudo" in the search bar.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.