| Justin Hendrickson 2004-04-25, 6:44 pm |
| Since the current PEAR::Auth File container is for CVS passwd files, I
did a quick overview of it and modified it to use unix passwd files.
Here's the diff, incase someone wants to add it to the PEAR::Auth
package or use it for themselves.
///////////////////////////////////////////////////////////////////////
diff -ubB pear/Auth/Container/File.php pear/Auth/Container
--- pear/Auth/Container/File.php Tue Feb 24 23:28:53 2004
+++ pear/Auth/Container/Unix.php Sun Apr 25 15:14:11 2004
@@ -28,14 +28,14 @@
/**
* Storage driver for fetching login data from an encrypted password file.
*
- * This storage container can handle CVS pserver style passwd files.
+ * This storage container can handle Unix style passwd files.
*
* @author Stefan Ekman <stekman@sedata.org>
* @author Michael Wallner <mike@php.net>
* @package Auth
* @version $Revision: 1.14 $
*/
-class Auth_Container_File extends Auth_Container
+class Auth_Container_Unix extends Auth_Container
{
/**
* Path to passwd file
@@ -52,7 +52,7 @@
* @param string $filename path to passwd file
* @return object Auth_Container_File new Auth_Container_File object
*/
- function Auth_Container_File($filename)
+ function Auth_Container_Unix($filename)
{
$this->pwfile = $filename;
}
@@ -69,7 +69,7 @@
*/
function fetchData($user, $pass)
{
- return File_Passwd::staticAuth('Cvs', $this->pwfile, $user, $pass);
+ return File_Passwd::staticAuth('Unix', $this->pwfile, $user,
$pass, 'des');
}
// }}}
@@ -94,8 +94,7 @@
foreach ($users as $key => $value) {
$retVal[] = array("username" => $key,
- "password" => $value['passwd'],
- "cvsuser" => $value['system']);
+ "password" => $value['passwd']);
}
return $retVal;
@@ -115,15 +114,12 @@
*/
function addUser($user, $pass, $additional='')
{
- $cvs = (string) (is_array($additional) &&
isset($additional['cvsuser'])) ?
- $additional['cvsuser'] : $additional;
-
$pw_obj = &$this->_load();
if (PEAR::isError($pw_obj)) {
return false;
}
- $res = $pw_obj->addUser($user, $pass, $cvs);
+ $res = $pw_obj->addUser($user, $pass, $additional);
if(PEAR::isError($res)){
return false;
}
@@ -179,7 +175,7 @@
static $pw_obj;
if (!isset($pw_obj)) {
- $pw_obj = File_Passwd::factory('Cvs');
+ $pw_obj = File_Passwd::factory('Unix');
if (PEAR::isError($pw_obj)) {
return $pw_obj;
}
///////////////////////////////////////////////////////////////////////
Not much to it, just a quick modification, but a good start for a new
container, should it be adopted.
|