mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-26 00:02:19 +03:00
44 lines
1.2 KiB
Bash
Executable file
44 lines
1.2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
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 == "gdm"* || $PAM_SERVICE == *"dm" )]]) || ([[ -n $PAM_TTY ]] && [[ $PAM_TTY == ":"* ]]); then
|
|
SERVICE="none"
|
|
if [[ -n $PAM_SERVICE ]]; then
|
|
SERVICE="$PAM_SERVICE"
|
|
fi
|
|
TTY_DISPLAY="none"
|
|
if [[ -n $PAM_TTY ]]; then
|
|
TTY_DISPLAY="$PAM_TTY"
|
|
fi
|
|
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"
|
|
python3 /usr/share/ahenk/ahenkd.py login $PAM_USER $SERVICE $TTY_DISPLAY $domain
|
|
else
|
|
log "login: $PAM_USER service: $SERVICE tty: $TTY_DISPLAY domain: none"
|
|
python3 /usr/share/ahenk/ahenkd.py login $PAM_USER $SERVICE $TTY_DISPLAY
|
|
fi
|
|
fi
|
|
fi
|