/** * Base method for File_Passwd::staticAuth() * * Returns a PEAR_Error if: * o file doesn't exist * o file couldn't be opened in read mode * o file couldn't be locked exclusively * o file couldn't be unlocked (only if auth fails) * o file couldn't be closed (only if auth fails) * * @throws PEAR_Error * @access protected * @return mixed line of passwd file containing <var>$id</var>, * false if <var>$id</var> wasn't found or PEAR_Error * @param string $file path to passwd file * @param string $id user_id to search for * @param string $sep field separator */ function _auth($file, $id, $sep = ':') { $file = realpath($file); if (!is_file($file)) { return PEAR::raiseError("File '{$file}' couldn't be found.", 0); } $fh =& File_Passwd_Common::_open('r', $file); if (PEAR::isError($fh)) { return $fh; } $cmp = $id . $sep; $len = strlen($cmp); while ($line = fgets($fh)) { if (!strncmp($line, $cmp, $len)) { File_Passwd_Common::_close($fh); return trim($line); } } $e = File_Passwd_Common::_close($fh); if (PEAR::isError($e)) { return $e; } return false; }