Q: sudo in a bash script
Hi All-
I want to allow non-admin users to run a bash script that changes the ownership of a file to an admin user in a different group. I've run into a couple questions I'm hoping the more experienced could shed some light on.
First off, when I chown to an admin user, it requires sudo. So I've included the following in the script: `sudo chown <user>:<group> <file>`
Two issues:
1) Is there a way around the interactive "Password:" prompt? What's the safest way to do this, security-wise?
2) Only users listed in /private/etc/sudoers are able to run `sudo`. By default, this doesn't include any of my non-admin users. Am I required to add them to this file? Or is there a better way?
Thanks for any tips,
-Greg
PowerBook G4 Mac OS X (10.4.8) Sony KDL-40S2010 HDTV
I want to allow non-admin users to run a bash script that changes the ownership of a file to an admin user in a different group. I've run into a couple questions I'm hoping the more experienced could shed some light on.
First off, when I chown to an admin user, it requires sudo. So I've included the following in the script: `sudo chown <user>:<group> <file>`
Two issues:
1) Is there a way around the interactive "Password:" prompt? What's the safest way to do this, security-wise?
2) Only users listed in /private/etc/sudoers are able to run `sudo`. By default, this doesn't include any of my non-admin users. Am I required to add them to this file? Or is there a better way?
Thanks for any tips,
-Greg
PowerBook G4 Mac OS X (10.4.8) Sony KDL-40S2010 HDTV
Posted on Mar 15, 2007 5:07 PM
by Niel,Solvedanswer
Mac OS X
Move the script to the top level of the hard disk or a preinstalled folder only writable by root, such as /private. Next, use a tool such as visudo to edit the sudoers file so that non-admin users can use sudo to execute that script and only that script; the sudo in the script can then be removed, and the line in sudoers can be set so that no password is required to run it. From here, change the permissions on it so that only root is able to edit the script.
(20394)
(20394)
Posted on Mar 15, 2007 8:45 PM