Mounting a Windows Share to Linux as a non-root user
How to Change permisisons on RHEL5 to give users the abilty to mount window shares on the local machine
The CIFS mount procedure
This command, will mount a windows network path to any path on the local filesystem. Note that this must be done with root privileges.
Command Syantax
mount.cifs \\\\<server_name>\<share_name> /<mount_point> -o user=<username>
RHEL5_box:~ # mount.cifs \\\\fileserver\\scooke6 /mnt/scooke6 -o user=scooke6 Password: <type in windows network password here>
>RHEL5_box:~ # ls mnt scooke6
RHEL5_box:~ #
Above, "RHEL5_box" is the host, "\scooke6" is the share that we wish to access, and "/mnt/scooke6" is the desired mount point on the local filesystem.
It's also important to specify the user name needed to access the remote computer.
When we are finished with the share, we simply unmount the share from the mount point.
RHEL5_box:~ # umount.cifs /mnt Password: <type in windows network password here>
RHEL5_box:~ # ls /mnt
scooke6
RHEL5_box:~ #
How to mount for non-root users
You may notice from above, that the root user will be the only user capable of writing to the network share (if the share has writing enabled of course).
First let's make mount.cifs and unmount.cifs accesable to non-root users.
Make sure to change the ownership of the mount point to determine who can mount the network share. For cifs mounts, you have to be the owner of the mount point.
Next, we alter the /sbin/mount.cifs and /sbin/umount.cifs binaries to execute with root permissions. This is done by setting the SUID bit.
chmod 6755 /sbin/mount.cifsFor security reasons, be sure to do this only on a system where you trust the users who can execute mount.cifs & umount.cifs. Additionally, you can restrict the execution privileges to a group of users though as stated above, only one user will be able to mount the share.
chmod 6755 /sbin/umount.cifs
And that's it! Now, as your regular user, you can access the share!

