Hello,
From here -
Code:
There is a very neat trick in every Linux which will allow you to do so. It is called the SetUI bit.
Keep in mind that you will need to have the permissions locked down tight in this file for this to be secure.
Make the file owned by root and group root:
sudo chown root.root <my script>
Now set the SetUID bit, make it executable for all and writable only by root:
sudo chmod 4755 <my script>
Keep in mind if this script will allow any input or editing of files, this will also be done as root.
The SetUID bit makes a script or binary always run as the owner of the file/binary, an example of such a binary is 'passwd'.
There is a solution using sudoers here is an example you could use:
Cmnd_Alias CMDS = /path/to/your/script
<username> ALL=NOPASSWD: CMDS
Now just place sudo in front of your script and it should run without asking for a password.
I've never tried that but I have edited the sudoers file to stop the need for a password having to be entered in Terminal when required.
Did that by:
In the sudoers file change the line:
Code:
%sudo ALL=(ALL) ALL
to
Code:
%sudo ALL=(ALL) NOPASSWD: ALL
Logout then back in again.
Good luck.
Bookmarks