From a1a81c9823ec873b36b3d2e64d5d98072f7d3ea6 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Thu, 15 Jan 2009 14:32:43 +0000 Subject: [PATCH] config.inc.php, functions.inc.php - add support for mysql_encrypt method for password encrpytion - useful for pam integration, apparently - see https://sourceforge.net/tracker/?func=detail&atid=937966&aid=1793352&group_id=191583 git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@525 a1433add-5e2c-0410-b055-b7f2511e0802 --- config.inc.php | 1 + functions.inc.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+) 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; }