[Fusionforge-commits] r9964 - in trunk/gforge: common/include plugins/scmsvn/common

Franck VILLAUME nerville at libremir.placard.fr.eu.org
Wed Jun 2 14:00:21 CEST 2010


Author: nerville
Date: 2010-06-02 14:00:20 +0200 (Wed, 02 Jun 2010)
New Revision: 9964

Modified:
   trunk/gforge/common/include/utils.php
   trunk/gforge/plugins/scmsvn/common/SVNPlugin.class.php
Log:
anonymous user name & password are now definitly configurable

Modified: trunk/gforge/common/include/utils.php
===================================================================
--- trunk/gforge/common/include/utils.php	2010-06-02 11:25:48 UTC (rev 9963)
+++ trunk/gforge/common/include/utils.php	2010-06-02 12:00:20 UTC (rev 9964)
@@ -3,7 +3,7 @@
  * FusionForge miscellaneous utils
  *
  * Copyright 1999-2001, VA Linux Systems, Inc.
- * Copyright 2009, Roland Mas
+ * Copyright 2009-2010, Roland Mas, Franck Villaume
  *
  * This file is part of FusionForge.
  *
@@ -24,6 +24,39 @@
  */
 
 /**
+ * htpasswd_apr1_md5($plainpasswd) - generate htpasswd md5 format password
+ *
+ * From http://www.php.net/manual/en/function.crypt.php#73619
+ */
+function htpasswd_apr1_md5($plainpasswd) {
+    $salt = substr(str_shuffle("abcdefghijklmnopqrstuvwxyz0123456789"), 0, 8);
+    $len = strlen($plainpasswd);
+    $text = $plainpasswd.'$apr1$'.$salt;
+    $bin = pack("H32", md5($plainpasswd.$salt.$plainpasswd));
+    for($i = $len; $i > 0; $i -= 16) { $text .= substr($bin, 0, min(16, $i)); }
+    for($i = $len; $i > 0; $i >>= 1) { $text .= ($i & 1) ? chr(0) : $plainpasswd{0}; }
+    $bin = pack("H32", md5($text));
+    for($i = 0; $i < 1000; $i++) {
+        $new = ($i & 1) ? $plainpasswd : $bin;
+        if ($i % 3) $new .= $salt;
+        if ($i % 7) $new .= $plainpasswd;
+        $new .= ($i & 1) ? $bin : $plainpasswd;
+        $bin = pack("H32", md5($new));
+    }
+    for ($i = 0; $i < 5; $i++) {
+        $k = $i + 6;
+        $j = $i + 12;
+        if ($j == 16) $j = 5;
+        $tmp = $bin[$i].$bin[$k].$bin[$j].$tmp;
+    }
+    $tmp = chr(0).chr(0).$bin[11].$tmp;
+    $tmp = strtr(strrev(substr(base64_encode($tmp), 2)),
+    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
+    "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
+    return "$"."apr1"."$".$salt."$".$tmp;
+}
+ 
+/**
  * is_utf8($string) - utf-8 detection
  *
  * From http://www.php.net/manual/en/function.mb-detect-encoding.php#85294

Modified: trunk/gforge/plugins/scmsvn/common/SVNPlugin.class.php
===================================================================
--- trunk/gforge/plugins/scmsvn/common/SVNPlugin.class.php	2010-06-02 11:25:48 UTC (rev 9963)
+++ trunk/gforge/plugins/scmsvn/common/SVNPlugin.class.php	2010-06-02 12:00:20 UTC (rev 9964)
@@ -268,7 +268,7 @@
 		foreach ($svnusers as $user_id => $user) {
 			$password_data .= $user->getUnixName ().':'.$user->getMD5Passwd ()."\n" ;
 		}
-		$password_data .= forge_get_config('anonsvn_login', 'scmsvn').':$apr1$Kfr69/..$J08mbyNpD81y42x7xlFDm.'."\n";
+		$password_data .= forge_get_config('anonsvn_login', 'scmsvn').":".htpasswd_apr1_md5(forge_get_config('anonsvn_pass', 'scmsvn'))."\n";
 
 		$fname = forge_get_config('data_path').'/svnroot-authfile' ;
 		$f = fopen ($fname.'.new', 'w') ;




More information about the Fusionforge-commits mailing list