diff --git a/config.inc.php b/config.inc.php index e6e5539b..3240bb9b 100644 --- a/config.inc.php +++ b/config.inc.php @@ -88,6 +88,7 @@ $CONF['smtp_port'] = '25'; // md5 = md5 sum of the password // system = whatever you have set as your PHP system default // cleartext = clear text passwords (ouch!) +// mysql_encrypt = useful for PAM integration $CONF['encrypt'] = 'md5crypt'; // Minimum length required for passwords. Postfixadmin will not diff --git a/functions.inc.php b/functions.inc.php index 666cabfe..13b34314 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -1146,6 +1146,20 @@ function pacrypt ($pw, $pw_db="") if ($CONF['encrypt'] == 'cleartext') { $password = $pw; } + + // See https://sourceforge.net/tracker/?func=detail&atid=937966&aid=1793352&group_id=191583 + // this is apparently useful for pam_mysql etc. + if ($CONF['encrypt'] == 'mysql_encrypt') + { + if ($pw_db!="") { + $salt=substr($pw_db,0,2); + $res=db_query("SELECT ENCRYPT('".$pw."','".$salt."');"); + } else { + $res=db_query("SELECT ENCRYPT('".$pw."');"); + } + $l = db_row($res["result"]); + $password = $l[0]; + } $password = escape_string ($password); return $password; }