SF.net SVN: postfixadmin:[562] trunk/functions.inc.php
Brought to you by:
christian_boltz,
gingerdog
From: <roe...@us...> - 2009-02-04 21:05:13
|
Revision: 562 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=562&view=rev Author: roehrijn Date: 2009-02-04 21:05:08 +0000 (Wed, 04 Feb 2009) Log Message: ----------- functions.inc.php: - fixed some remarks in pacrypt Modified Paths: -------------- trunk/functions.inc.php Modified: trunk/functions.inc.php =================================================================== --- trunk/functions.inc.php 2009-02-03 21:02:04 UTC (rev 561) +++ trunk/functions.inc.php 2009-02-04 21:05:08 UTC (rev 562) @@ -256,7 +256,7 @@ flash_error("emailcheck_resolve_domain is enabled, but function (checkdnsrr) missing!"); } } - + return true; } @@ -1128,7 +1128,7 @@ } if ($CONF['encrypt'] == 'system') { - if (ereg ("\$1\$", $pw_db)) { + if (ereg ("\$1\$", $pw_db)) { $split_salt = preg_split ('/\$/', $pw_db); $salt = $split_salt[2]; } @@ -1162,23 +1162,25 @@ } if ($CONF['encrypt'] == 'authlib') { - $flavor = $CONF['authlib_default_flavor']; - $salt = ' '; - if(ereg('^{.*}', $pw_db)) { - // we have a flavor in the db -> use it instead of default flavor - $result = split('{|}', $pw_db, 3); - $flavor = $result[1]; - $salt = substr($result[2], 0, 2); - } - - if(stripos($flavor, 'md5raw') === 0) { - $password = '{' . $flavor . '}' . md5($pw); - } else if(stripos($flavor, 'md5') === 0) { - $password = '{' . $flavor . '}' . base64_encode(md5($pw, TRUE)); - } else if(stripos($flavor, 'crypt') === 0) { - $password = '{' . $flavor . '}' . crypt($pw, $salt); - } - } + $flavor = $CONF['authlib_default_flavor']; + $salt = substr(create_salt(), 0, 2); + if(ereg('^{.*}', $pw_db)) { + // we have a flavor in the db -> use it instead of default flavor + $result = split('{|}', $pw_db, 3); + $flavor = $result[1]; + $salt = substr($result[2], 0, 2); + } + + if(stripos($flavor, 'md5raw') === 0) { + $password = '{' . $flavor . '}' . md5($pw); + } else if(stripos($flavor, 'md5') === 0) { + $password = '{' . $flavor . '}' . base64_encode(md5($pw, TRUE)); + } else if(stripos($flavor, 'crypt') === 0) { + $password = '{' . $flavor . '}' . crypt($pw, $salt); + } else { + die("authlib_default_flavor '" . $flavor . "' unknown. Valid flavors are 'md5raw', 'md5' and 'crypt'"); + } + } $password = escape_string ($password); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |