Linux – How to tell autofs to mount a home directory other than that described by LDAP

autofsldaplinux

I'm using CentOS 5.3 to connect to use Kerberos for authentication and LDAP for user information. Unfortunately, the home directory for all users as stored in LDAP is "/". Very bright! So, that doesn't work. Without having any access to LDAP, I need to figure out how to force users to use the local directory "/home/username" as HOME.

I've tried editing /etc/bashrc but it seems like at that point it's too late to set HOME. Plus, I might need to edit the user's default shell, which is also stored in LDAP. Doesn't seem like changing the local /etc/bashrc would help because it might not even be loaded!

So, when using these components — Kerberos, LDAP, pam, autofs — when and where can I specify the environment for my users, if necessary overriding the environment set in LDAP?

TIA!!!1

Best Answer

Warning: Ugly hack ahead! The best thing will of course be to change the data in the LDAP server, and save your self the trouble, but here it goes:

Add the following line at the end of /etc/security/pam_env.conf:

HOME           DEFAULT="/home/@{PAM_USER}"

This will override the users $HOME variable to point to the right directory. However, this is only set after login, so you'll still get an error that login can't find the users home directory. 2nd phase of ugly hack is to add a "cd ~" at the end of /etc/profile, which will bring your user to the right home directory. Hopefully at this stage you'll be able to use automount to map the home directory to the correct NFS server