#! /usr/bin/env sh if [ ! "${PAM_TYPE}" = "open_session" ] then exit 0 fi if [ -e /etc/notify-pam/ignore-list ] then while read line do user="$(echo "${line}" | cut -d' ' -f1)" service="$(echo "${line}" | cut -d' ' -f2)" if [ "${PAM_USER}" = "${user}" ] && [ "${PAM_SERVICE}" = "${service}" ] then exit 0 fi done < /etc/notify-pam/ignore-list fi { echo "User: $PAM_USER" echo "Ruser: $PAM_RUSER" echo "Rhost: $PAM_RHOST" echo "Service: $PAM_SERVICE" echo "TTY: $PAM_TTY" echo "Date: `date`" echo "Server: `hostname -f`" } | mail -s "`hostname -s` $PAM_SERVICE login: $PAM_USER" root