#! /bin/bash
# /etc/ppp/author
# Authorisierung FH-Einwahl

if [ "$2" = "" ] ; then
	echo "$0 user passwort"
	exit 1
fi

if [ "$1" = "" ] ; then
	echo "$0 user passwort"
	exit 2
fi

if [ -r "/etc/ppp/pap-secrets.$1" ] ; then
	echo "Benutzer $1 bekannt"
	else echo "Benutzer $1 unbekannt"
	exit 3
fi

PW=`cat /etc/ppp/pap-secrets.$1 | grep $1 | cut -c21-28` 

if [ "$2" = "$PW" ] ; then echo "Benutzer autorisiert"
	exit 0
else
	echo "falsches Passwort"
	exit 4
fi
