2016-06-20 10:08:08 +03:00
|
|
|
#!/bin/bash
|
2016-06-27 12:37:12 +03:00
|
|
|
|
|
|
|
function error_exit() {
|
|
|
|
log "$1:$2 failed, exit status $?"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
trap 'error_exit "${BASH_SOURCE}" "${LINENO}"' ERR
|
|
|
|
|
|
|
|
LOG=/var/log/pam_script.log
|
|
|
|
|
|
|
|
function log() {
|
|
|
|
logger --priority auth.info --tag "$0" "$@"
|
|
|
|
echo "$(date) $0: $@" >> $LOG
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -n $PAM_USER ] && [ $PAM_USER != "root" ]; then
|
2020-04-22 15:30:28 +03:00
|
|
|
if ([ -n $PAM_SERVICE ] && [[ ( $PAM_SERVICE == *"dm" || $PAM_SERVICE == "gdm"* )]]) || ([ -n $PAM_TTY ] && [[ $PAM_TTY == ":"* ]]); then
|
2016-06-27 12:37:12 +03:00
|
|
|
SERVICE="none"
|
|
|
|
if [ -n $PAM_SERVICE ]; then
|
|
|
|
SERVICE="$PAM_SERVICE"
|
|
|
|
fi
|
|
|
|
TTY_DISPLAY="none"
|
|
|
|
if [ -n $PAM_TTY ]; then
|
|
|
|
TTY_DISPLAY="$PAM_TTY"
|
|
|
|
fi
|
|
|
|
log "logout: $PAM_USER service: $SERVICE tty: $TTY_DISPLAY"
|
2017-11-21 11:36:11 +03:00
|
|
|
sudo python3 /usr/share/ahenk/ahenkd.py logout $PAM_USER
|
2016-06-20 10:08:08 +03:00
|
|
|
fi
|
|
|
|
fi
|