fix for md5 hashes

This commit is contained in:
Serghey Rodin 2015-06-04 14:18:42 +03:00
commit ea24113610

View file

@ -49,7 +49,15 @@ fi
#----------------------------------------------------------#
# Parsing user's salt
salt=$(grep "^$user:" /etc/shadow |cut -f 3 -d \$)
shadow=$(grep "^$user:" /etc/shadow)
salt=$(echo "$shadow" |cut -f 3 -d \$)
method=$(echo "$shadow" |cut -f 2 -d \$)
if [ "$method" -eq '1' ]; then
method='md5'
else
method='sha-512'
fi
if [[ -z "$salt" ]] || [[ "${#salt}" -gt 12 ]]; then
echo "Error: password missmatch"
echo "$DATE $user $ip failed to login" >> $VESTA/log/auth.log
@ -57,7 +65,7 @@ if [[ -z "$salt" ]] || [[ "${#salt}" -gt 12 ]]; then
fi
# Generating SHA-512
hash=$($BIN/v-generate-password-hash sha-512 $salt <<< $password)
hash=$($BIN/v-generate-password-hash $method $salt <<< $password)
if [[ -z "$hash" ]]; then
echo "Error: password missmatch"
echo "$DATE $user $ip failed to login" >> $VESTA/log/auth.log