[Fusionforge-commits] r9611 - in trunk: gforge/common/include gforge/cronjobs gforge/plugins/quota_management/www gforge/plugins/scmcvs/cronjobs gforge/www/docman/admin gforge/www/frs/admin gforge/www/frs/include tests/code/deprecations

Roland Mas lolando at libremir.placard.fr.eu.org
Tue Apr 27 21:27:56 CEST 2010


Author: lolando
Date: 2010-04-27 21:27:56 +0200 (Tue, 27 Apr 2010)
New Revision: 9611

Modified:
   trunk/gforge/common/include/account.php
   trunk/gforge/common/include/config-vars.php
   trunk/gforge/cronjobs/auth_unix.php
   trunk/gforge/cronjobs/ftp_create_group_access.php
   trunk/gforge/cronjobs/homedirs.php
   trunk/gforge/plugins/quota_management/www/quota.php
   trunk/gforge/plugins/quota_management/www/quota_project.php
   trunk/gforge/plugins/scmcvs/cronjobs/ssh_create.php
   trunk/gforge/plugins/scmcvs/cronjobs/usergroup.php
   trunk/gforge/www/docman/admin/index.php
   trunk/gforge/www/frs/admin/editrelease.php
   trunk/gforge/www/frs/admin/qrs.php
   trunk/gforge/www/frs/include/frs_utils.php
   trunk/tests/code/deprecations/DeprecationsTest.php
Log:
Config API: prefixes for home directories

Modified: trunk/gforge/common/include/account.php
===================================================================
--- trunk/gforge/common/include/account.php	2010-04-27 19:21:38 UTC (rev 9610)
+++ trunk/gforge/common/include/account.php	2010-04-27 19:27:56 UTC (rev 9611)
@@ -232,7 +232,7 @@
  */
 function account_user_homedir($user) {
 	//return '/home/users/'.substr($user,0,1).'/'.substr($user,0,2).'/'.$user;
-	return $GLOBALS['homedir_prefix'].'/'.$user;
+	return forge_get_config('homedir_prefix').'/'.$user;
 }
 
 /**
@@ -243,7 +243,7 @@
  */
 function account_group_homedir($group) {
 	//return '/home/groups/'.substr($group,0,1).'/'.substr($group,0,2).'/'.$group;
-	return $GLOBALS['groupdir_prefix'].'/'.$group;
+	return forge_get_config('groupdir_prefix').'/'.$group;
 }
 
 // Local Variables:

Modified: trunk/gforge/common/include/config-vars.php
===================================================================
--- trunk/gforge/common/include/config-vars.php	2010-04-27 19:21:38 UTC (rev 9610)
+++ trunk/gforge/common/include/config-vars.php	2010-04-27 19:27:56 UTC (rev 9611)
@@ -84,6 +84,8 @@
 forge_define_config_item ('jpgraph_path', 'core', $GLOBALS['sys_path_to_jpgraph']) ;
 forge_define_config_item ('account_manager_type', 'core', $GLOBALS['sys_account_manager_type']) ;
 forge_define_config_item ('unix_cipher', 'core', $GLOBALS['unix_cipher']) ;
+forge_define_config_item ('homedir_prefix', 'core', $GLOBALS['homedir_prefix']) ;
+forge_define_config_item ('groupdir_prefix', 'core', $GLOBALS['groupdir_prefix']) ;
 // forge_define_config_item ('', 'core', $GLOBALS['sys_']) ;
 
 /* Long-term:

Modified: trunk/gforge/cronjobs/auth_unix.php
===================================================================
--- trunk/gforge/cronjobs/auth_unix.php	2010-04-27 19:21:38 UTC (rev 9610)
+++ trunk/gforge/cronjobs/auth_unix.php	2010-04-27 19:27:56 UTC (rev 9611)
@@ -56,7 +56,7 @@
 {
 	$err .= ", /etc/group.org missing!";
 }
-if (util_is_root_dir ($homedir_prefix) == true)
+if (util_is_root_dir (forge_get_config('homedir_prefix')) == true)
 {
 	$err .= ", homedir_prefix points to root directory!";
 }
@@ -111,7 +111,7 @@
 			{
 				$shell = $default_shell;
 			}
-			$line = $user_names [$i] . ":x:" . $user_ids [$i] . ":" . $user_ids [$i] . ":" . $user_realnames [$i] . ":" . $homedir_prefix . "/" . $user_names [$i] . ":" . $shell . "\n";
+			$line = $user_names [$i] . ":x:" . $user_ids [$i] . ":" . $user_ids [$i] . ":" . $user_realnames [$i] . ":" . forge_get_config('homedir_prefix') . "/" . $user_names [$i] . ":" . $shell . "\n";
 			fwrite ($h2, $line);
 		}
 

Modified: trunk/gforge/cronjobs/ftp_create_group_access.php
===================================================================
--- trunk/gforge/cronjobs/ftp_create_group_access.php	2010-04-27 19:21:38 UTC (rev 9610)
+++ trunk/gforge/cronjobs/ftp_create_group_access.php	2010-04-27 19:27:56 UTC (rev 9611)
@@ -30,7 +30,7 @@
 
 $chroot_dir = forge_get_config('chroot');
 $ftp_dir = forge_get_config('ftp_upload_dir')."/pub/";
-$home_dir = $chroot_dir.$homedir_prefix."/";
+$home_dir = $chroot_dir.forge_get_config('homedir_prefix')."/";
 
 
 $res_db = db_query_params ('SELECT groups.group_id, group_name, unix_group_name,

Modified: trunk/gforge/cronjobs/homedirs.php
===================================================================
--- trunk/gforge/cronjobs/homedirs.php	2010-04-27 19:21:38 UTC (rev 9610)
+++ trunk/gforge/cronjobs/homedirs.php	2010-04-27 19:27:56 UTC (rev 9611)
@@ -60,20 +60,20 @@
 //error variable
 $err = '';
 
-if (!isset($groupdir_prefix)) {		// this should be set in local.inc
-	$groupdir_prefix = '/home/groups';
+if (forge_get_config('groupdir_prefix') == '') {		// this should be set in local.inc
+	exit () ;
 }
 
-if (!is_dir($groupdir_prefix)) {
-	@mkdir($groupdir_prefix,0755,true);
+if (!is_dir(forge_get_config('groupdir_prefix'))) {
+	@mkdir(forge_get_config('groupdir_prefix'),0755,true);
 }
 
-if (!isset($homedir_prefix)) {		// this should be set in local.inc
-	$$homedir_prefix = '/home';
+if (forge_get_config('homedir_prefix') == '') {		// this should be set in local.inc
+	exit () ;
 }
 
-if (!is_dir($homedir_prefix)) {
-	@mkdir($homedir_prefix,0755,true);
+if (!is_dir(forge_get_config('homedir_prefix'))) {
+	@mkdir(forge_get_config('homedir_prefix'),0755,true);
 }
 
 $res = db_query_params ('SELECT distinct users.user_name,users.unix_pw,users.user_id
@@ -99,12 +99,12 @@
 //	this is where we give a user a home
 //
 foreach($users as $user) {
-	if (is_dir($homedir_prefix."/".$user)) {
+	if (is_dir(forge_get_config('homedir_prefix')."/".$user)) {
 		
 	} else {
-		@mkdir($homedir_prefix."/".$user);
+		@mkdir(forge_get_config('homedir_prefix')."/".$user);
 	}
-	system("chown $user:".USER_DEFAULT_GROUP." ".$homedir_prefix."/".$user);
+	system("chown $user:".USER_DEFAULT_GROUP." ".forge_get_config('homedir_prefix')."/".$user);
 }
 
 
@@ -125,12 +125,12 @@
 		}
 	}
 
-	if (is_dir($groupdir_prefix."/".$group)) {
+	if (is_dir(forge_get_config('groupdir_prefix')."/".$group)) {
 
 	} else {
-		@mkdir($groupdir_prefix."/".$group);
-		@mkdir($groupdir_prefix."/".$group."/htdocs");
-		@mkdir($groupdir_prefix."/".$group."/cgi-bin");
+		@mkdir(forge_get_config('groupdir_prefix')."/".$group);
+		@mkdir(forge_get_config('groupdir_prefix')."/".$group."/htdocs");
+		@mkdir(forge_get_config('groupdir_prefix')."/".$group."/cgi-bin");
 		$g =& group_get_object_by_name($group);
 		
 
@@ -167,20 +167,20 @@
 		//
 		//	Write the file back out to the project home dir
 		//
-		$fw=fopen($groupdir_prefix."/".$group."/htdocs/index.html",'w');
+		$fw=fopen(forge_get_config('groupdir_prefix')."/".$group."/htdocs/index.html",'w');
 		fwrite($fw,$contents);
 		fclose($fw);
 	}
 
 	if (forge_get_config('use_manual_uploads')) { 
-		$incoming = $groupdir_prefix/$group."/incoming" ;
+		$incoming = forge_get_config('groupdir_prefix')/$group."/incoming" ;
 		if (!is_dir($incoming))
 		{
 			@mkdir($incoming); 
 		}
 	}
 
-	system("chown -R ".forge_get_config('apache_user').":".forge_get_config('apache_group')." $groupdir_prefix/$group");
+	system("chown -R ".forge_get_config('apache_user').":".forge_get_config('apache_group')." forge_get_config('groupdir_prefix')/$group");
 
 }
 

Modified: trunk/gforge/plugins/quota_management/www/quota.php
===================================================================
--- trunk/gforge/plugins/quota_management/www/quota.php	2010-04-27 19:21:38 UTC (rev 9610)
+++ trunk/gforge/plugins/quota_management/www/quota.php	2010-04-27 19:27:56 UTC (rev 9611)
@@ -102,7 +102,7 @@
 $chroot_dir = forge_get_config('chroot');
 $ftp_dir = forge_get_config('ftp_upload_dir')."/pub/";
 $upload_dir = forge_get_config('upload_dir');
-$group_dir = $chroot_dir.$groupdir_prefix."/";
+$group_dir = $chroot_dir.forge_get_config('groupdir_prefix')."/";
 $cvs_dir = $chroot_dir.$cvsdir_prefix."/";
 $svn_dir = $chroot_dir.$svndir_prefix."/";
 

Modified: trunk/gforge/plugins/quota_management/www/quota_project.php
===================================================================
--- trunk/gforge/plugins/quota_management/www/quota_project.php	2010-04-27 19:21:38 UTC (rev 9610)
+++ trunk/gforge/plugins/quota_management/www/quota_project.php	2010-04-27 19:27:56 UTC (rev 9611)
@@ -122,7 +122,7 @@
 $upload_dir = forge_get_config('upload_dir') .  $group->getUnixName();
 $chroot_dir = forge_get_config('chroot');
 $ftp_dir = forge_get_config('ftp_upload_dir')."/pub/".$group->getUnixName();
-$group_dir = $chroot_dir.$groupdir_prefix . "/" . $group->getUnixName();
+$group_dir = $chroot_dir.forge_get_config('groupdir_prefix') . "/" . $group->getUnixName();
 $cvs_dir = $chroot_dir.$cvsdir_prefix . "/" . $group->getUnixName();
 $svn_dir = $chroot_dir.$svndir_prefix . "/" . $group->getUnixName();
 

Modified: trunk/gforge/plugins/scmcvs/cronjobs/ssh_create.php
===================================================================
--- trunk/gforge/plugins/scmcvs/cronjobs/ssh_create.php	2010-04-27 19:21:38 UTC (rev 9610)
+++ trunk/gforge/plugins/scmcvs/cronjobs/ssh_create.php	2010-04-27 19:27:56 UTC (rev 9611)
@@ -43,7 +43,7 @@
 
 	$ssh_key=db_result($res,$i,'authorized_keys');
 	$username=db_result($res,$i,'user_name');
-	$dir = $homedir_prefix.'/'.$username;
+	$dir = forge_get_config('homedir_prefix').'/'.$username;
 	if (util_is_root_dir($dir)) {
 		$err .=  "Error! homedir_prefix/username Points To Root Directory!";
 		continue;
@@ -53,7 +53,7 @@
 	$ssh_key=str_replace('###',"\n",$ssh_key);
 	$uid += 1000;
 
-	$ssh_dir = "$homedir_prefix/$username/.ssh";
+	$ssh_dir = "forge_get_config('homedir_prefix')/$username/.ssh";
 	if (!is_dir($ssh_dir)) {
 		mkdir ($ssh_dir, 0755);
 	}
@@ -69,7 +69,7 @@
 	posix_seteuid(0);
 	posix_setegid(0);
 		
-	system("chown $username:users $homedir_prefix/$username");
+	system("chown $username:users forge_get_config('homedir_prefix')/$username");
 	system("chown $username:users $ssh_dir");
 	system("chmod 0644 $ssh_dir/authorized_keys");
 	system("chown $username:users $ssh_dir/authorized_keys");

Modified: trunk/gforge/plugins/scmcvs/cronjobs/usergroup.php
===================================================================
--- trunk/gforge/plugins/scmcvs/cronjobs/usergroup.php	2010-04-27 19:21:38 UTC (rev 9610)
+++ trunk/gforge/plugins/scmcvs/cronjobs/usergroup.php	2010-04-27 19:27:56 UTC (rev 9611)
@@ -40,7 +40,7 @@
 define('DEFAULT_SHELL','/bin/cvssh.pl'); //use /bin/grap for cvs-only
 define('FILE_EXTENSION','.new'); // use .new when testing
 
-if (util_is_root_dir($groupdir_prefix)) {
+if (util_is_root_dir(forge_get_config('groupdir_prefix'))) {
 	$err .=  "Error! groupdir_prefix Points To Root Directory!";
 	echo $err;
 	cron_entry(16,$err);

Modified: trunk/gforge/www/docman/admin/index.php
===================================================================
--- trunk/gforge/www/docman/admin/index.php	2010-04-27 19:21:38 UTC (rev 9610)
+++ trunk/gforge/www/docman/admin/index.php	2010-04-27 19:27:56 UTC (rev 9611)
@@ -108,7 +108,7 @@
 			$data = fread(fopen($filename, 'r'), filesize($filename));
 			$filetype=$uploaded_data_type;
 		} elseif (forge_get_config('use_manual_uploads') && $uploaded_filename!=100 && util_is_valid_filename($uploaded_filename)) { //100==None
-			$incoming = $groupdir_prefix."/".$g->getUnixName()."/incoming" ;
+			$incoming = forge_get_config('groupdir_prefix')."/".$g->getUnixName()."/incoming" ;
 			$filename = $incoming.'/'.$uploaded_filename;
 			$data = addslashes(fread(fopen($filename, 'r'), filesize($filename)));
 			$finfo = finfo_open (FILEINFO_MIME_TYPE) ;
@@ -344,7 +344,7 @@
 			}
 		
 /*		if (forge_get_config('use_manual_uploads') && $u->getUnixStatus() == 'A') {
-			$incoming = $groupdir_prefix."/".$g->getUnixName()."/incoming" ;
+			$incoming = forge_get_config('groupdir_prefix')."/".$g->getUnixName()."/incoming" ;
 			
 			echo '<strong>' ;
 			printf (_("OR choose one you alrealy uploaded (by SFTP or SCP) to the project's incoming directory ($1$s)."),

Modified: trunk/gforge/www/frs/admin/editrelease.php
===================================================================
--- trunk/gforge/www/frs/admin/editrelease.php	2010-04-27 19:21:38 UTC (rev 9610)
+++ trunk/gforge/www/frs/admin/editrelease.php	2010-04-27 19:27:56 UTC (rev 9611)
@@ -300,7 +300,7 @@
 <?php } ?>
 
 <?php if (forge_get_config('use_manual_uploads')) {
-	$incoming = $groupdir_prefix."/".$g->getUnixName()."/incoming" ;
+	$incoming = forge_get_config('groupdir_prefix')."/".$g->getUnixName()."/incoming" ;
 
 	echo '<p>';
 	printf(_('Alternatively, you can use a file you already uploaded (by SFTP or SCP) to the project\'s incoming directory (%1$s).'),

Modified: trunk/gforge/www/frs/admin/qrs.php
===================================================================
--- trunk/gforge/www/frs/admin/qrs.php	2010-04-27 19:21:38 UTC (rev 9610)
+++ trunk/gforge/www/frs/admin/qrs.php	2010-04-27 19:27:56 UTC (rev 9611)
@@ -209,7 +209,7 @@
 		</p>
 		<?php } ?>
 <?php if (forge_get_config('use_manual_uploads')) {
-	$incoming = $groupdir_prefix."/".$g->getUnixName()."/incoming" ;
+	$incoming = forge_get_config('groupdir_prefix')."/".$g->getUnixName()."/incoming" ;
 
 	echo '<p>';
 	printf(_('Alternatively, you can use a file you already uploaded (by SFTP or SCP) to the project\'s incoming directory (%1$s).'),

Modified: trunk/gforge/www/frs/include/frs_utils.php
===================================================================
--- trunk/gforge/www/frs/include/frs_utils.php	2010-04-27 19:21:38 UTC (rev 9610)
+++ trunk/gforge/www/frs/include/frs_utils.php	2010-04-27 19:27:56 UTC (rev 9611)
@@ -222,10 +222,10 @@
 
 function frs_add_file_from_form ($release, $type_id, $processor_id, $release_date,
 				 $userfile, $ftp_filename, $manual_filename) {
-	global $groupdir_prefix ;
 
+
 	$group_unix_name = $release->getFRSPackage()->getGroup()->getUnixName() ;
-	$incoming = "$groupdir_prefix/$group_unix_name/incoming" ;
+	$incoming = "forge_get_config('groupdir_prefix')/$group_unix_name/incoming" ;
 
 	$filechecks = false ;
 

Modified: trunk/tests/code/deprecations/DeprecationsTest.php
===================================================================
--- trunk/tests/code/deprecations/DeprecationsTest.php	2010-04-27 19:21:38 UTC (rev 9610)
+++ trunk/tests/code/deprecations/DeprecationsTest.php	2010-04-27 19:27:56 UTC (rev 9611)
@@ -101,6 +101,8 @@
 			       'sys_path_to_jpgraph',
 			       'sys_account_manager_type',
 			       'unix_cipher',
+			       'homedir_prefix',
+			       'groupdir_prefix',
 			) ;
 
 		$pattern = implode ('|', $vars) ;




More information about the Fusionforge-commits mailing list