2016-06-20 10:08:08 +03:00
|
|
|
#!/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
|
|
|
|
}
|
|
|
|
|
2021-09-07 16:31:54 +03:00
|
|
|
if [[ -n $PAM_USER ]] && [[ $PAM_USER != "root" ]]; then
|
|
|
|
if ([[ -n $PAM_SERVICE ]] && [[ ( $PAM_SERVICE == "gdm"* || $PAM_SERVICE == *"dm" )]]) || ([[ -n $PAM_TTY ]] && [[ $PAM_TTY == ":"* ]]); then
|
2016-06-27 12:03:51 +03:00
|
|
|
SERVICE="none"
|
2021-09-07 16:31:54 +03:00
|
|
|
if [[ -n $PAM_SERVICE ]]; then
|
2016-06-27 12:20:09 +03:00
|
|
|
SERVICE="$PAM_SERVICE"
|
2016-06-27 12:03:51 +03:00
|
|
|
fi
|
|
|
|
TTY_DISPLAY="none"
|
2021-09-07 16:31:54 +03:00
|
|
|
if [[ -n $PAM_TTY ]]; then
|
2016-06-27 12:20:09 +03:00
|
|
|
TTY_DISPLAY="$PAM_TTY"
|
2016-06-27 12:03:51 +03:00
|
|
|
fi
|
2020-09-30 12:07:18 +03:00
|
|
|
domain="none"
|
|
|
|
if [[ $PAM_USER = *'\'* ]]; then
|
|
|
|
IFS='\' read -ra NAMES <<< "$PAM_USER"
|
|
|
|
log "login: \ ile geldi"
|
|
|
|
for i in "${NAMES[@]}"; do
|
|
|
|
domain="${NAMES[0]}"
|
|
|
|
PAM_USER="${NAMES[1]}"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
if [[ $domain != "none" ]]; then
|
|
|
|
log "login: $PAM_USER service: $SERVICE tty: $TTY_DISPLAY domain: $domain"
|
2021-09-07 16:31:54 +03:00
|
|
|
python3 /usr/share/ahenk/ahenkd.py login $PAM_USER $SERVICE $TTY_DISPLAY $domain
|
2020-09-30 12:07:18 +03:00
|
|
|
else
|
|
|
|
log "login: $PAM_USER service: $SERVICE tty: $TTY_DISPLAY domain: none"
|
2021-09-07 16:31:54 +03:00
|
|
|
python3 /usr/share/ahenk/ahenkd.py login $PAM_USER $SERVICE $TTY_DISPLAY
|
2020-09-30 12:07:18 +03:00
|
|
|
fi
|
2016-06-20 10:08:08 +03:00
|
|
|
fi
|
|
|
|
fi
|