#!/bin/sh
#
#  Use Kerberos key as machine key if machine key is unavailable.
#

set -e

FILE="/tmp/krb5cc_diskless"

if [ "$PAM_USER" != "root" ] && [ ! -e /etc/krb5.keytab ] && [ ! -e $FILE ] ; then
    ID=$(id -u "$PAM_USER")
    cp -v /tmp/krb5cc_${ID}_* $FILE
    systemctl restart autofs
fi

exit 0
