From 026c7192517013393b08c10d041673a09d18b00f Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Wed, 16 Dec 2009 22:57:45 +1300 Subject: [PATCH] Better use of getent to extract user fullname. --- inc/drivers_squid_pam.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inc/drivers_squid_pam.php b/inc/drivers_squid_pam.php index a4a0de74..d2cd862d 100644 --- a/inc/drivers_squid_pam.php +++ b/inc/drivers_squid_pam.php @@ -67,7 +67,8 @@ 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 = trim( exec("getent passwd | grep ^" . $username ." | cut -d \":\" -f5"), ' ,' ); + $fullname = exec('getent passwd "'.$username.'"' ); + $fullname = preg_replace( '{^[^:]+:[^:]+:\d+:\d+:([^:,]+)(,[^:]*):}', '$1', $fullname ); $usr = (object) array( 'user_no' => 0, 'username' => $username,