Ahenk/usr/share/libpam-script/pam_script_ses_open

31 lines
755 B
Text
Raw Normal View History

#!/bin/bash
2016-06-27 12:03:51 +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
if ([ -n $PAM_SERVICE ] && [[ $PAM_SERVICE == *"dm" ]]) || ([ -n $PAM_TTY ] && [[ $PAM_TTY == ":"* ]]); then
SERVICE="none"
if [ -n $PAM_SERVICE ]; then
2016-06-27 12:17:28 +03:00
$SERVICE="$PAM_SERVICE"
2016-06-27 12:03:51 +03:00
fi
TTY_DISPLAY="none"
if [ -n $PAM_TTY ]; then
2016-06-27 12:17:28 +03:00
$TTY_DISPLAY="$PAM_TTY"
2016-06-27 12:03:51 +03:00
fi
log "login: $PAM_USER service: $SERVICE tty: $TTY_DISPLAY"
2016-06-27 12:16:59 +03:00
sudo python3 /opt/ahenk/ahenkd.py login $PAM_USER $SERVICE $TTY_DISPLAY
fi
fi