In addition to the normal pam_mkhomedir.so I wanted to create a directory for each user on an alternative disk. To do so I edited:
vi /etc/pam.d/password-auth
added the line below (just above the line: session optional pam_mkhomedir.so)
session optional pam_exec.so /usr/local/bin/create_dir.sh
Then created the create_dir.sh file:
vi /usr/local/bin/create_dir.sh
and added the following:
#!/bin/bash if [ ! -d /local/$PAM_USER ]; then mkdir /local/$PAM_USER chown $PAM_USER:ldapusers /local/$PAM_USER fi
chmod +x /usr/local/bin/create_dir.sh
It is also possible to add extra options to pam_exec.so (man pam_exec) for debugging e.g.
session optional pam_exec.so debug log=/tmp/pam_exec.log /usr/local/bin/create_dir.sh