From ea241136106cde8ea4ee33a7e60bf94a5f75a40e Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Thu, 4 Jun 2015 14:18:42 +0300 Subject: [PATCH] fix for md5 hashes --- bin/v-check-user-password | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/v-check-user-password b/bin/v-check-user-password index af87f77d6..a93770627 100755 --- a/bin/v-check-user-password +++ b/bin/v-check-user-password @@ -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