From 9469eb6d58523a39bc1d76e68d32a3bb0d4678f1 Mon Sep 17 00:00:00 2001 From: Jim Hague Date: Thu, 16 Sep 2010 11:37:22 +0100 Subject: [PATCH] PAM - get user name from a comma-less passwd comment field. PAM authentication uses a regular expression to extract the user's real name from the 'user name or comment field' passwd file when creating a new account. The current regular expression assumes the comment field contains the user name followed by a comma and some other comma-delimited information (the Linux 'adduser' command adds room number, work phone, home phone and 'other' info given half a chance). If the field just contains the user name, there is no trailing comma and the RE match fails. Make the trailing comma optional. Signed-off-by: Andrew McMillan --- inc/drivers_squid_pam.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/drivers_squid_pam.php b/inc/drivers_squid_pam.php index 24976e32..41139220 100644 --- a/inc/drivers_squid_pam.php +++ b/inc/drivers_squid_pam.php @@ -68,7 +68,7 @@ function SQUID_PAM_check($username, $password ){ else { dbg_error_log( "PAM", "user %s doesn't exist in local DB, we need to create it",$username ); $fullname = exec('getent passwd "'.$username.'"' ); - $fullname = preg_replace( '{^[^:]+:[^:]+:\d+:\d+:([^:,]+)(,[^:]*):.*$}', '$1', $fullname ); + $fullname = preg_replace( '{^[^:]+:[^:]+:\d+:\d+:([^:,]+)(,?[^:]*):.*$}', '$1', $fullname ); $usr = (object) array( 'user_no' => 0, 'username' => $username,