[CentOS] Running mount in a script.

Will McDonald wmcdonald at gmail.com
Fri Apr 28 14:27:58 UTC 2006


On 28/04/06, Michael Jacks <michael_jem at yahoo.com> wrote:
> I am running CentOS 4 and have the need to run "mount -t cifs ..." from
> within a perl or bash script as part of an application.  The
> application does not run as root.  I have been trying to do a chmod +s
> on a root owned script but that doesn't seem to work. I still get
> permission errors.  I also took a look at sudo but that appears to
> require a user to periodically enter a password.  This would not work
> for this application.
>
> Does anyone have any suggestions on how to do a mount from a script
> based application not being run as root?

You can allow a user to run a command without entering a password
using sudo. Simplistically, something like the following in
/etc/sudoers (use visudo to edit it):

Host_Alias SERVERNAME = server1
User_Alias USER = username
Cmnd_Alias COMMAND1 = /bin/mount -t cifs
USERNAME SERVERNAME = NOPASSWD: COMMAND1

Would enable user "username" to run the command "/bin/mount -t cifs"
on server server1 as root by entering:

[username at server ~]$ sudo /bin/mount -t cifs

Will.



More information about the CentOS mailing list