Re: [PATCH] Auth_Container_File

From: Date: Mon, 13 Oct 2003 08:15:54 +0000
Subject: Re: [PATCH] Auth_Container_File
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-22632@lists.php.net to get a copy of this message
Can you send me that as the full file, i don't have patch utils on my system. If you don't like the File container and you have valid problems you wish to address you are free to rewrite it and send it to me Yavor Michael Wallner wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I've written a patch for Auth_Container_File to support the new File_Passwd package. I only edited the most necessary lines, although I don't like the whole thing... Regards, - -- Michael - < mike(@)php.net > -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (Cygwin) iD8DBQE/hwJj2pTtEijQyW0RAg3QAJ9zSxiVOP5UpC6RL8BC6yd0VmN+DgCcDZnZ E2lmPDZnMwn2xVHZljbOcV8= =MSBm -----END PGP SIGNATURE----- ------------------------------------------------------------------------ Index: Auth/Container/File.php =================================================================== RCS file: /repository/pear/Auth/Container/File.php,v retrieving revision 1.10 diff -u -r1.10 File.php
--- Auth/Container/File.php     17 Jul 2003 18:55:21 -0000      1.10
+++ Auth/Container/File.php     10 Oct 2003 18:56:23 -0000
@@ -57,11 +57,12 @@
            return PEAR::raiseError("File \"$filename\" is not a valid filename.", 41);
        }
-        if (!$this->pwfile = new File_Passwd($filename,0)) {
+        $this->pwfile = &File_Passwd::factory('Cvs');
+        $this->pwfile->setFile($filename);
+
+        if (PEAR::isError($this->pwfile->load())) {
            return PEAR::raiseError("Error while reading file contents of file \"$filename\" .", 41);
        }
-
-        $this->pwfile->close();
    }
    // }}}
@@ -78,7 +79,7 @@
    {
        $result = $this->pwfile->verifyPassword($username, $password);
-        return $result;
+        return ($result && !PEAR::isError($result));
    }
    // }}}
@@ -93,10 +94,9 @@
        }
        foreach ($users as $key => $value) {
-            $cvsuser = $this->pwfile->getCvsUser($key);
            $retVal[] = array("username" => $key,
-                              "password" => $value,
-                              "cvsuser"  => $cvsuser);
+                              "password" => $value['passwd'],
+                              "cvsuser"  => $value['system']);
        }
        return $retVal;
@@ -115,18 +115,15 @@
     */
    function addUser($username, $password, $additional='')
    {
-        if (!($this->pwfile->isLocked())) {
-            $this->pwfile->lock();
-        }
-
        if (is_array($additional)) {
-            $cvsuser = $additional[cvsuser];
+            $cvsuser = $additional['cvsuser'];
        } else {
            $cvsuser = $additional;
        }
-        $retval = $this->pwfile->addUser($username, $password, $cvsuser);
-        $this->pwfile->close();
+        $retval = !PEAR::isError(
+            $this->pwfile->addUser($username, $password, $cvsuser)
+        );
        return($retval);
    }
@@ -141,11 +138,8 @@
     */
    function removeUser($username)
    {
-        if (!($this->pwfile->isLocked())) {
-            $this->pwfile->lock();
-        }
-        $retval = $this->pwfile->delUser($username);
-        $this->pwfile->close();
+        $retval = $this->pwfile->delUser($username);
+
        return($retval);
    }
-- Yavor Shahpasov yavo@siava.org

« previous php.pear.dev (#22632) next »