Patches for Class: File_Passwd
| From: | Jeffery C . Cann | Date: | Wed, 11 Apr 2001 20:31:45 +0000 |
| Subject: | Patches for Class: File_Passwd | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-208@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Greetings.
I am using the File_Passwd class to store logins for web site admins. I
would like to contribute the following patches (below).
Patch #1
- -------
In the constructor, the password file is opened with the 'r' mode. This
assumes that the file exists before a user of the File_Passwd class. I think
this is the case because the author writes changes to a password.lock file
and once the class user calls File_Passwd->close(), the old file is
overwritten. What happens if your PHP application needs to create a blank
passwd file? I don't think there should be another method to handle this
case, but maybe remove the 'or die' statement in fopen (see below).
Patch #2
- -------
During CGI process of user accounts, it would be convenient (IMHO) to know if
the user is already in the password file. If the user is in the password
file, then you would want to call File_Passwd->modUser() rather than
File_Passwd->addUser(). My patch is simple scan of the existing users in
passwd file, return true if user is in file.
Based on the information for the CVS account request
(http://www.php.net/cvs-php.php), I don't think I need a CVS account simply
to contribute a PEAR patch (yet!).
So, is my post here sufficient for the contribution of the patch? Do I need
to contact the author directly? Do I need to get a PHP CVS account and make
the patch myself?
Thanks
Jeffery Cann
- ------Patch #1 - File/Passwd.php ----------
41,47c41,50
< $fp = fopen($file,'r') or die("Unable to open $file");
< while(!feof($fp)) {
< $line = fgets($fp, 128);
< list($user,$pass,$cvsuser) = explode(':',$line);
< if(strlen($user)) {
< $this->users[$user] = $pass;
< $this->cvs[$user] = trim($cvsuser);
- ---
> $fp = fopen($file,'r');
>
> if ($fp) {
> while(!feof($fp)) {
> $line = fgets($fp, 128);
> list($user,$pass,$cvsuser) =
explode(':',$line);
> if(strlen($user)) {
> $this->users[$user] = $pass;
> $this->cvs[$user] = trim($cvsuser);
> }
48a52
> fclose($fp);
50d53
< fclose($fp);
111a115,125
> }
- --------- File/Passwd.php patch #2 -------------
> /**
> * Is user in password file?
> *
> * @param $user user id
> */
> function isUser($user) {
> if(isset($this->users[$user])) {
> return true;
> }
- ---------------------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iEYEARECAAYFAjrUvzoACgkQt0J81Q+7BCAyqwCfdwXq5Bvs4IRQEsOzrgg4OPyO
tJEAnjq2N+fFj9iaUmV7g62BYnsekDmt
=72FU
-----END PGP SIGNATURE-----