pam_script_auth 756 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  3. if grep "$PAM_USER" /etc/passwd > /dev/null; then
  4. exit -1;
  5. fi
  6. /usr/share/libpam-script/cifs-umount-all
  7. LOGIN="${PAM_USER,,}"
  8. PASSWORD="$PAM_AUTHTOK"
  9. #export LOGIN
  10. touch /dev/shm/.loginresult."$LOGIN"
  11. chmod 600 /dev/shm/.loginresult."$LOGIN"
  12. curl -F "login=$LOGIN" -F "password=$PASSWORD" https://auth.clab.mephi.ru/ 2>/dev/null | awk '{$1=""; print}' > /dev/shm/.loginresult."$LOGIN"
  13. if [ "$(jq .status /dev/shm/.loginresult.$LOGIN)" = '"OK"' ]; then
  14. touch /dev/shm/.~pamgate."$LOGIN" &&
  15. chmod 600 /dev/shm/.~pamgate."$LOGIN" &&
  16. chown "$LOGIN:0" /dev/shm/.~pamgate."$LOGIN" 2>/dev/null &&
  17. cat > /dev/shm/.~pamgate."$LOGIN" << EOF
  18. $PASSWORD
  19. EOF
  20. exit 0;
  21. fi
  22. exit -1;