OpenSolaris Automagic homedir Creation

Often with LDAP setups a user will log into a box where his home directory doesn’t exist. Linux provides us with a pam_mkhomedir.so module that automagically creates missing home directories for you. No such module exists for opensolaris. This bug report offers an alternative using autofs.

#!/bin/bash
# if the filesystem is available under /export/home, then serve that
if [ -d /export/home/$1 ] ; then
    echo "localhost:/export/home/$1
    exit 0
fi  
 
# else create a file system under /export/home
/usr/sbin/zfs create "export/home/$1" || exit 1
# and copy /etc/skel stuff
/bin/find /etc/skel/ -type f -exec cp {} /export/home/$1/ \;
chown -R $1 /export/home/$1/  
 
# now we can serve our newly created file system
echo "localhost:/export/home/$1" exit 0

Comments are closed.