max-mapper / monu

menubar process monitor mac app [ALPHA]
https://github.com/maxogden/monu/releases
BSD 2-Clause "Simplified" License
1.11k stars 74 forks source link

sudo processes #14

Open potomak opened 9 years ago

potomak commented 9 years ago

I'd like to run a process as super user. Is it possible for monu to ask credentials to run processes that need special permissions?

max-mapper commented 9 years ago

I actually have no idea how to implement this. I'm thinking if you launch Monu.app from the command line using 'sudo' it will inherit the sudoness for all spawned child processes, but even then i'm not sure that will work.

Ideally there would be some way to e.g. use Keychain to authenticate once and give permission to Monu to always spawn processes as sudo, but I have no idea how to do that or if that is possible

potomak commented 9 years ago

Me neither, I'm going to close this issue. Thanks anyway for your help.

max-mapper commented 9 years ago

No worries. I actually am gonna reopen just to see if anyone ever comes through with a suggestion of how they might implement this

elmariofredo commented 9 years ago

@potomak You need to setup sudoers in order to allow to escalate rights without passing password.

So just run sudo visudo in command line and add line at the end of file

YourUserName ALL = (root) /bin/commandToExecute

Then you can add to monu config sudo /bin/commandToExecute and command is executed as super user. For more info see http://osxdaily.com/2014/02/06/add-user-sudoers-file-mac/

potomak commented 9 years ago

@elmariofredo I think you need also to add the tag NOPASSWD.

elmariofredo commented 9 years ago

@potomak yes you are right, totally forgot about it, so for others correct sudoers line is

YourUserName ALL = (root) NOPASSWD: /bin/commandToExecute

shaynem commented 8 years ago

Try this

https://www.npmjs.com/package/sudo-fn