*/ // we only accept page ids for auth_pam if(isset($_REQUEST['u'])) $_REQUEST['u'] = cleanID($_REQUEST['u']); /** * Check user+password [required auth function] * * Checks if the given user exists and the given * plaintext password is correct * * @author Andreas Gohr * @return bool */ function auth_checkPass($user,$pass){ return pam_auth($user, $pass, &$error); } /** * Return user info [required auth function] * * Returns info about the given user needs to contain * at least these fields: * * name string full name of the user * mail string email addres of the user * grps array list of groups the user is in * * @author Andreas Gohr */ function auth_getUserData($user){ $users = auth_plain_loadUserData(); return $users[$user]; } /** * Create a new User [required auth function] * * Returns false if the user already exists, null when an error * occured and the cleartext password of the new user if * everything went well. * * The new user HAS TO be added to the default group by this * function! * * @author Andreas Gohr */ function auth_createUser($user,$pass,$name,$mail){ msg('Creating users is not supported for the PAM backend. Use the standard tools for password administration',-1); return null; } /** * Load all user data * * Used by the plaintext auth functions * loads the user file into a datastructure * * @author Andreas Gohr */ function auth_plain_loadUserData(){ $data = array(); if(!@file_exists('/etc/passwd')){ return $data; } $lines = file('/etc/passwd'); foreach($lines as $line){ $line = trim($line); if(empty($line)) continue; $row = split(":",$line,7); $data[$row[0]]['name'] = urldecode($row[4]); $data[$row[0]]['mail'] = $row[4].'@'.$_SERVER['SERVER_NAME']; $data[$row[0]]['grps'] = array(); } if (@file_exists('/etc/group')){ $lines = file('/etc/group'); foreach($lines as $line){ $line = trim($line); if(empty($line)) continue; $row = split(":",$line,4); $users = split(",",$row[3]); foreach($users as $user){ $data[$user]['grps'][] = $row[0]; } } } return $data; } //Setup VIM: ex: et ts=2 enc=utf-8 :