SF.net SVN: postfixadmin:[564] trunk/functions.inc.php
Brought to you by:
christian_boltz,
gingerdog
From: <chr...@us...> - 2009-02-09 19:11:48
|
Revision: 564 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=564&view=rev Author: christian_boltz Date: 2009-02-09 19:11:43 +0000 (Mon, 09 Feb 2009) Log Message: ----------- functions.inc.php - added comment about courier-authlib supporting only two-character salt (see mail from Jan R?\195?\182hrich in postfixadmin-devel about r560) - fixed vim: line - functions.inc.php uses 4 spaces - replaced "else if" with "elseif" - replaced tabs with spaces Modified Paths: -------------- trunk/functions.inc.php Modified: trunk/functions.inc.php =================================================================== --- trunk/functions.inc.php 2009-02-05 12:14:36 UTC (rev 563) +++ trunk/functions.inc.php 2009-02-09 19:11:43 UTC (rev 564) @@ -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,25 +1162,25 @@ } if ($CONF['encrypt'] == 'authlib') { - $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'"); - } - } + $flavor = $CONF['authlib_default_flavor']; + $salt = substr(create_salt(), 0, 2); # courier-authlib supports only two-character salts + 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); + } elseif(stripos($flavor, 'md5') === 0) { + $password = '{' . $flavor . '}' . base64_encode(md5($pw, TRUE)); + } elseif(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); @@ -2296,4 +2296,4 @@ $table_vacation = table_by_key ('vacation'); $table_vacation_notification = table_by_key('vacation_notification'); $table_quota = table_by_key ('quota'); -/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |