Fix for types other than md5 and crypt, e.g. SSHA where the the type is contained in the text of the password

This commit is contained in:
Miles Lott 2006-06-20 09:50:00 +00:00
parent 1961bf2170
commit 23ac553d70

View File

@ -72,7 +72,7 @@
} }
/** /**
* compagres an encrypted password * compares an encrypted password
* *
* encryption type set in setup and calls the appropriate encryption functions * encryption type set in setup and calls the appropriate encryption functions
* *
@ -84,6 +84,7 @@
function compare_password($cleartext,$encrypted,$type,$username='') function compare_password($cleartext,$encrypted,$type,$username='')
{ {
// allow to specify the hash type to prefix the hash, to easy migrate passwords from ldap // allow to specify the hash type to prefix the hash, to easy migrate passwords from ldap
$saved_enc = $encrypted;
if (preg_match('/^\\{([a-z_5]+)\\}(.+)$/i',$encrypted,$matches)) if (preg_match('/^\\{([a-z_5]+)\\}(.+)$/i',$encrypted,$matches))
{ {
$type = strtolower($matches[1]); $type = strtolower($matches[1]);
@ -97,6 +98,8 @@
case 'crypt': case 'crypt':
// nothing to do // nothing to do
break; break;
default:
$encrypted = $saved_enc;
// ToDo: the others ... // ToDo: the others ...
} }
} }