If a user’s home directory cannot be found then an attempt to log in with an X session will fail. No easily understandable explanation of why their login attempt has failed is displayed to the user and the user’s machine is useless until the server is operational again. Which is very annoying for the user. Ideally of course home directory servers do not fail. In practice, they sometimes do.

After a spate of such instances during which the Linux machines I administer were unusable, I decided to try and come up with a way to make the machines usable in such situations. (I feel I should point out that the structure of the organisation I work in means I have no control over the home directory servers and that the home directories have since been moved to vastly more reliable servers.)

This guide is written based upon the set up of machines I administer which is as follows:

  • X logins are done with GDM.
  • Authentication is done against an LDAP server (no user accounts are listed in /etc/passwd or /etc/shadow).
  • Home directories are mounted via NFS.
  • Mounting of home directories is controlled by autofs using a map supplied by a NIS server.

All the scripts mentioned below are in the attached tbz file. Minor alterations will probably be necessary to make them work in an environment other than the one for which they were written. Note that the HTML file has had answers that are specific to the organisation I work for removed and replaced with **********. You can fill in replacements if you wish, or just remove the questions.

Most of the work is done by the script tmphomedirhandler. This runs as root and is called after the user logs in by adding a line to /etc/gdm/PostLogin/Default

/usr/local/etc/tmphomefiles/tmphomedirhandler login

This causes tmphomdirhandler to do the following

  • Check if the user’s home directory is mounted and if not…
  • Display some useful information to the user explaining what has happened.
  • Turn off autofs
  • Create a home directory on the local disk. My machines have a partition users can use for local storage mounted at /local (with same permissions as /tmp) and the home directory is created in there. You can of course change the location by editing the scripts.
  • Put a .desktop file in to the new home directory that calls the vaguely named script dostuff when the user logs in. The dostuff script launches Firefox to display a HTML file that gives the user more helpful information. It also adds an icon to their panel which invites them to click on it. When clicked this icon launches Firefox as described in the previous sentence. It gives the user a way to display the information on demand. The dostuff script also sets the wallpaper to something that reminds the user they’re not logged in with their own home directory.
  • Create a symbolic link in /home that points at the home directory in /local, thus satisfying the requirement that the home directory effectively exists at the local it’s supposed to and GnomeVFS is happy. (This is why autofs needs to be turned off. Whilst autofs is running you can’t create anything in /home.)

The login process then continues as normal. The following screenshots illustrate what a user sees if their home directory cannot be mounted. Please note that the screenshots are cut off on the right hand edge because Cool Solutions limits images to 1200×1200.

Because autofs has been turned off, it needs to be turned back on again when the user logs out.

This is achieved by putting a line in /etc/gdm/Init/Default

/usr/local/etc/tmphomefiles/tmphomedirhandler logout

The causes tmphomedirhandler to delete the symbolic link in /home and then start autofs.

With these scripts in place, if a home directory server is down then whilst users do not have access to their files and usual settings, they can at least the use the machines.

It’s worth also mentioning a method of achieving the above that I found didn’t work – changing the value of $HOME. This was the first thing I tried. I put a script in /etc/X11/xinit/xinitrc.d which checked for the presence of the user’s home home directory and if it wasn’t there, created the new home directory and altered the value of $HOME to point at it. This is neat because everything runs as the user that’s logging in and there was no need to worry about autofs. In practice it doesn’t work because of GnomeVFS. When GnomeVFS wants to know where a user’s home directory is it doesn’t look at the value of $HOME, it goes a getent call. This call returns the path of where the user’s home directory is supposed to be. If that location doesn’t exist, as it won’t if the mounting via autofs has failed, then any application that depends upon GnomeVFS, which includes GNOME itself, won’t run. So there must be something present at the location the home directory is supposed to be at and hence a more complicated solution must be used than just altering that value of $HOME.

(Visited 1 times, 1 visits today)
Tags: ,
Category: SUSE Linux Enterprise Desktop, Technical Solutions
This entry was posted Thursday, 3 December, 2009 at 3:24 pm
You can follow any responses to this entry via RSS.

Leave a Reply

Your email address will not be published. Required fields are marked *

No comments yet