cvs: pearweb /include pear-auth.php
| From: | Stig Bakken | Date: | Sun, 29 Jul 2001 02:23:54 +0000 |
| Subject: | cvs: pearweb /include pear-auth.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-363@lists.php.net to get a copy of this message | ||
ssb Sat Jul 28 22:23:54 2001 EDT
Modified files:
/pearweb/include pear-auth.php
Log:
* added cvs auth functions
Index: pearweb/include/pear-auth.php
diff -u pearweb/include/pear-auth.php:1.4 pearweb/include/pear-auth.php:1.5
--- pearweb/include/pear-auth.php:1.4 Fri Apr 20 06:31:36 2001
+++ pearweb/include/pear-auth.php Sat Jul 28 22:23:54 2001
@@ -20,11 +20,45 @@
{
global $PHP_AUTH_USER, $PHP_AUTH_PW, $dbh, $auth_user;
- $auth_user =& new PEAR_User(&$dbh, strtolower($PHP_AUTH_USER));
+ $user = strtolower($PHP_AUTH_USER);
+ $auth_user =& new PEAR_User(&$dbh, $user);
+ if (md5($PHP_AUTH_PW) != $auth_user->password || !$auth_user->registered) {
+ if (cvs_verify_password($user, $PHP_AUTH_PW)) {
+ $auth_user = (object)array('handle' => $user);
+ } else {
+ auth_reject();
+ }
+ }
$auth_user->_readonly = true;
- if (DB::isError($auth_user) || md5($PHP_AUTH_PW) != $auth_user->password) {
- auth_reject();
+}
+
+$cvspasswd_file = "/repository/CVSROOT/passwd";
+
+function cvs_find_password($user)
+{
+ global $cvspasswd_file;
+ $fp = fopen($cvspasswd_file,"r");
+ while (!feof($fp)) {
+ $line = fgets($fp, 120);
+ list($luser, $passwd, $junk) = explode(":", $line);
+ if ($user == $luser) {
+ fclose($fp);
+ return $passwd;
+ }
+ }
+ fclose($fp);
+ return false;
+}
+
+function cvs_verify_password($user, $pass)
+{
+ $psw = cvs_find_password($user);
+ if (strlen($psw) > 0) {
+ if (crypt($pass,substr($psw,0,2)) == $psw) {
+ return true;
+ }
}
+ return false;
}
?>