2

I am running a default fedora 15 install. My goal is to have a couple of network drives get mounted right after the user logs in graphically (not via ssh).

The script I want to execute is basically just a bunch of mount commands: sudo mount ...; sudo mount ...; sudo mount ...;.

I used visudo to let the user have NOPASSWD necessary when doing sudo mount.

Where can I put my simple script so that when the user logs in the script will execute?

  • each user would mount a different network drive... this is why I would like this to happen after login and not at the computer startup. – Trevor Boyd Smith Sep 15 '11 at 19:26

1 Answers1

2

Firstly, you should not simply allow unfettered access to mount as the superuser using NOPASSWD. You should instead create appropriate entries in /etc/fstab so that the filesystems can be mounted by unprivileged users.

If you really want to do this (you don't), you can do this in ~/.bash_profile if the users use bash as their shell, otherwise ~/.profile, or in /etc/profile by evalating $EUID.

Again, don't do that. Just add the fstab entries so that an unprivileged user can mount it without elevating.

Chris Down
  • 125,559
  • 25
  • 270
  • 266
  • If i put the mount into /etc/fstab, then the user can do on the command line: mount $NETWORK_DRIVE_NAME. I thought the user still needs to do 'sudo mount $NETWORK_DRIVE_NAME`? – Trevor Boyd Smith Sep 15 '11 at 22:55
  • Not if you set the mount options correctly. Check the documentation provided by your filesystem. – Chris Down Sep 15 '11 at 23:28
  • "check the documentation provided by your filesystem" is not low-level enough for me to take a next-action on "how can you make mount not require sudo?"... – Trevor Boyd Smith Sep 16 '11 at 01:05
  • and... there's another question that you forced me to ask... http://unix.stackexchange.com/questions/20838/does-mount-always-require-sudo-priveledge lol. – Trevor Boyd Smith Sep 16 '11 at 01:16