Skip to content

Commit ea24113

Browse files
committed
fix for md5 hashes
1 parent 5a4ba74 commit ea24113

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

bin/v-check-user-password

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,23 @@ fi
4949
#----------------------------------------------------------#
5050

5151
# Parsing user's salt
52-
salt=$(grep "^$user:" /etc/shadow |cut -f 3 -d \$)
52+
shadow=$(grep "^$user:" /etc/shadow)
53+
salt=$(echo "$shadow" |cut -f 3 -d \$)
54+
method=$(echo "$shadow" |cut -f 2 -d \$)
55+
if [ "$method" -eq '1' ]; then
56+
method='md5'
57+
else
58+
method='sha-512'
59+
fi
60+
5361
if [[ -z "$salt" ]] || [[ "${#salt}" -gt 12 ]]; then
5462
echo "Error: password missmatch"
5563
echo "$DATE $user $ip failed to login" >> $VESTA/log/auth.log
5664
exit 9
5765
fi
5866

5967
# Generating SHA-512
60-
hash=$($BIN/v-generate-password-hash sha-512 $salt <<< $password)
68+
hash=$($BIN/v-generate-password-hash $method $salt <<< $password)
6169
if [[ -z "$hash" ]]; then
6270
echo "Error: password missmatch"
6371
echo "$DATE $user $ip failed to login" >> $VESTA/log/auth.log

0 commit comments

Comments
 (0)