0
0
mirror of https://github.com/postfixadmin/postfixadmin.git synced 2024-09-20 03:36:20 +02:00

functions.inc.php:

-  fixed some remarks in pacrypt

git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@562 a1433add-5e2c-0410-b055-b7f2511e0802
This commit is contained in:
Jan Roehrich 2009-02-04 21:05:08 +00:00
parent 48f3be29bf
commit 12dc358ad0

View File

@ -256,7 +256,7 @@ function check_domain ($domain)
flash_error("emailcheck_resolve_domain is enabled, but function (checkdnsrr) missing!"); flash_error("emailcheck_resolve_domain is enabled, but function (checkdnsrr) missing!");
} }
} }
return true; return true;
} }
@ -1128,7 +1128,7 @@ function pacrypt ($pw, $pw_db="")
} }
if ($CONF['encrypt'] == 'system') { if ($CONF['encrypt'] == 'system') {
if (ereg ("\$1\$", $pw_db)) { if (ereg ("\$1\$", $pw_db)) {
$split_salt = preg_split ('/\$/', $pw_db); $split_salt = preg_split ('/\$/', $pw_db);
$salt = $split_salt[2]; $salt = $split_salt[2];
} }
@ -1162,23 +1162,25 @@ function pacrypt ($pw, $pw_db="")
} }
if ($CONF['encrypt'] == 'authlib') { if ($CONF['encrypt'] == 'authlib') {
$flavor = $CONF['authlib_default_flavor']; $flavor = $CONF['authlib_default_flavor'];
$salt = ' '; $salt = substr(create_salt(), 0, 2);
if(ereg('^{.*}', $pw_db)) { if(ereg('^{.*}', $pw_db)) {
// we have a flavor in the db -> use it instead of default flavor // we have a flavor in the db -> use it instead of default flavor
$result = split('{|}', $pw_db, 3); $result = split('{|}', $pw_db, 3);
$flavor = $result[1]; $flavor = $result[1];
$salt = substr($result[2], 0, 2); $salt = substr($result[2], 0, 2);
} }
if(stripos($flavor, 'md5raw') === 0) { if(stripos($flavor, 'md5raw') === 0) {
$password = '{' . $flavor . '}' . md5($pw); $password = '{' . $flavor . '}' . md5($pw);
} else if(stripos($flavor, 'md5') === 0) { } else if(stripos($flavor, 'md5') === 0) {
$password = '{' . $flavor . '}' . base64_encode(md5($pw, TRUE)); $password = '{' . $flavor . '}' . base64_encode(md5($pw, TRUE));
} else if(stripos($flavor, 'crypt') === 0) { } else if(stripos($flavor, 'crypt') === 0) {
$password = '{' . $flavor . '}' . crypt($pw, $salt); $password = '{' . $flavor . '}' . crypt($pw, $salt);
} } else {
} die("authlib_default_flavor '" . $flavor . "' unknown. Valid flavors are 'md5raw', 'md5' and 'crypt'");
}
}
$password = escape_string ($password); $password = escape_string ($password);