LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (http://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Automount user filesystem on console login only (http://www.linuxquestions.org/questions/linux-desktop-74/automount-user-filesystem-on-console-login-only-4175487585/)

lpwevers 12-11-2013 04:36 AM

Automount user filesystem on console login only
 
Hello experts,

At my work I'm faced with a challenge. It has been decided that we're moving to a Linux desktop environment. Basically it's a cluster of RedHat Enterprise Virtualisation (RHEV) servers running VDI's for all our users. They can then connect to the console of a running VDI and start working.

Now all that is working fine, but there is still one challenge left. I'm asked to configure the systems that a user specific directory is mounted when the user logs in to the console. (So, that's logs in to Gnome in practice). The problem is that if, for example, I use ssh to connect to the machine, the directory should not be mounted. Hence I can't use .profile or automount to perform the mount.

Then I tried running a script on gnome login to perform the mount, using udisks, but since the filesystem to mount is an NFS share, udisks is not of much help.

I could of course add all these user specific entries to fstab and make them user mountable, but since we have about 1000 users (with several 10s changing every week) that's not really a workable solution.

Any suggestions on how I can get this to work?

pan64 12-11-2013 09:28 AM

automount can handle user's home dirs.
probably this link helps a bit: http://rivald.blogspot.hu/2009/11/au...er-nfs-in.html

lpwevers 12-12-2013 01:07 AM

Hi, thanks for the reply

Quote:

Originally Posted by pan64 (Post 5078979)
automount can handle user's home dirs.
probably this link helps a bit: http://rivald.blogspot.hu/2009/11/au...er-nfs-in.html

Unfortunately this is not what I'm looking for. As mentioned, I only want to mount this directory if the user logs in from the console. If I use automount, it will also be mounted if a user uses something like ssh to login to the system.

Maybe it was not clear from my first post, but it's not the home directory I need to mount. This is some extra space we want to give to our users on so called "cheap" storage. It will always be mounted using the exact same location, /scratch; no subdirectories like /scratch/<userid>. That's why I only want it at console login. Ohterwise I don't know what will happen, but I assume in that case what's mounted in /scratch will be of the last user logged into the system.

pan64 12-12-2013 01:11 AM

automount can handle that kind of mounts also, it will automatically mount drive if someone wants to access it. (if I understand it well)

lpwevers 03-03-2014 06:58 AM

In the end we managed to get this working by using pam. Adding something like this to /etc/security/console.handlers does the trick:
Code:

console consoledevs tty[0-9][0-9]* vc/[0-9][0-9]* :[0-9]+\.[0-9]+ :[0-9]+
/bin/mountscript.sh lock logfail wait tty user
/bin/umountscript.sh unlock logfail wait tty user

[/code]
And in the (u)mount script you can then use $1, as that holds the userID of the logged in user.


All times are GMT -5. The time now is 11:43 PM.