Added sha-512 authorization fix

This commit is contained in:
Alexey Berezhok
2025-01-07 15:27:17 +03:00
parent 4c51952ee3
commit 95a0e87271
3 changed files with 21 additions and 8 deletions

View File

@@ -145,13 +145,18 @@ function authenticate_user($user, $password, $twofa = "") {
} else {
$salt = $pam[$user]["SALT"];
$method = $pam[$user]["METHOD"];
$round = $pam[$user]["ROUND"];
if ($method == "md5") {
$hash = crypt($password, '$1$' . $salt . '$');
}
if ($method == "sha-512") {
$hash = crypt($password, '$6$rounds=5000$' . $salt . '$');
$hash = str_replace('$rounds=5000', "", $hash);
if ($round == "") {
$hash = crypt($password, '$6$rounds=5000$' . $salt . '$');
$hash = str_replace('$rounds=5000', "", $hash);
} else {
$hash = crypt($password, '$6$' . $round . '$' . $salt . '$');
}
}
if ($method == "yescrypt") {
$fp = tmpfile();