I have a directory in my Debian home: /home/myuser/pchome/ which i want to use as a mount point for a remote cifs filesystem. So i have a bash script, which is run on every myuser login. This script contains the command:
mount -t cifs //192.168.1.2/myuser -o username=myuser,password=mypassword,uid=1000,gid=1000 /home/myuser/pchome
The command works like a charm using itself in a console. But, the problem is that mount requires sudo and password introduction (or be run with root privileges).
First approach i thought about is configure the sudoers to allow the use of mount for myuser. Something like:
myuser ALL=(ALL) NOPASSWD: /bin/mount, /bin/umount
The problem with that, is that myuser could use mount without limits, even for mounting filesystems on /etc, for example. I'm not interested in allowing myuser the use of mount command freely.
Second approach i thought about, is using fstab to allow the mount. I did not test it, but i think that, with this solution, both the mount point and filesystem to mount could be fixed, and no other mount could be done. But, every user could perform the mount (if using the "user" option for fstab line).
From my point of view, none of the two ideas is correct enought, so i would like if any of you knows the valid approach to that problem. I only want to be allowed to mount a public remote filesystem using a mount point inside my home without any concern about security, passwords or exposing the system to malicious mounts. It should be easier, since the mount point is inside my own home.
Thanks in advance.