[evolvis-commits] r18486: make the name of the "maven user" configurable

mirabilos at evolvis.org mirabilos at evolvis.org
Thu Jul 12 13:26:10 CEST 2012


Author: mirabilos
Date: 2012-07-12 13:26:09 +0200 (Thu, 12 Jul 2012)
New Revision: 18486

Modified:
   trunk/gforge_base/evolvisforge-5.1/src/common/include/User.class.php
   trunk/gforge_base/evolvisforge-5.1/src/common/include/config-vars.php
   trunk/gforge_base/evolvisforge-5.1/src/common/include/system/pgsql.class.php
   trunk/gforge_base/evolvisforge-5.1/src/etc/config.ini.d/defaults.ini
   trunk/gforge_base/evolvisforge-5.1/src/etc/config.ini.d/evolvis.ini
   trunk/gforge_base/evolvisforge-5.1/src/utils/normalize_roles.php
Log:
make the name of the "maven user" configurable

Modified: trunk/gforge_base/evolvisforge-5.1/src/common/include/User.class.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/common/include/User.class.php	2012-07-12 11:26:04 UTC (rev 18485)
+++ trunk/gforge_base/evolvisforge-5.1/src/common/include/User.class.php	2012-07-12 11:26:09 UTC (rev 18486)
@@ -136,6 +136,20 @@
 	return user_get_objects (util_result_column_to_array($res,0)) ;
 }
 
+function &user_get_ci_user() {
+	/*
+	 * get the user that's supposed to be automatically added
+	 * to all groups, for use with CI (Continuum, Jenkins) SCM
+	 * checkouts, etc.
+	 */
+	$mvn_user = forge_get_config("ci_user");
+	$rv = false;
+	if ($mvn_user && $mvn_user != '-' && $mvn_user != 'nobody') {
+		$rv =& user_get_object_by_name($mvn_user);
+	}
+	return $rv;
+}
+
 class GFUser extends Error {
 	/** 
 	 * Associative array of data from db.

Modified: trunk/gforge_base/evolvisforge-5.1/src/common/include/config-vars.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/common/include/config-vars.php	2012-07-12 11:26:04 UTC (rev 18485)
+++ trunk/gforge_base/evolvisforge-5.1/src/common/include/config-vars.php	2012-07-12 11:26:09 UTC (rev 18486)
@@ -70,6 +70,7 @@
 } else {
 	forge_define_config_item ('apache_group', 'core', '') ;
 }
+forge_define_config_item ('ci_user', 'core', '-');
 forge_define_config_item ('scm_tarballs_path', 'core', '$core/data_path/scmtarballs') ;
 forge_define_config_item ('scm_snapshots_path', 'core', '$core/data_path/scmsnapshots') ;
 forge_define_config_item ('plugins_path', 'core', '$core/source_path/plugins') ;

Modified: trunk/gforge_base/evolvisforge-5.1/src/common/include/system/pgsql.class.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/common/include/system/pgsql.class.php	2012-07-12 11:26:04 UTC (rev 18485)
+++ trunk/gforge_base/evolvisforge-5.1/src/common/include/system/pgsql.class.php	2012-07-12 11:26:09 UTC (rev 18486)
@@ -310,6 +310,11 @@
 			$this->sysGroupAddUser ($group_id, $u->getID()) ;
 		}
 
+		$mvn =& user_get_ci_user();
+		if (!$mvn) {
+			/* no "maven" user, return success */
+			return true;
+		}
 
 		/*
 		 * Add user "maven" to all groups as well as all SCM
@@ -325,7 +330,7 @@
 					FROM users u, groups g
 					WHERE u.user_name=$1 AND
 					    g.group_id=$2",
-		    array('maven', $group_id));
+		    array($mvn->getUnixName(), $group_id));
 
 		if (!$res) {
 			$this->setError('ERROR - Could Not Insert Maven (GID): '.db_error());
@@ -340,7 +345,7 @@
 					FROM users u, groups g
 					WHERE u.user_name=$1 AND
 					    g.group_id=$2",
-		    array('maven', $group_id, 'scm_'));
+		    array($mvn->getUnixName(), $group_id, 'scm_'));
 
 		if (!$res) {
 			$this->setError('ERROR - Could Not Insert Maven (SCM): '.db_error());

Modified: trunk/gforge_base/evolvisforge-5.1/src/etc/config.ini.d/defaults.ini
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/etc/config.ini.d/defaults.ini	2012-07-12 11:26:04 UTC (rev 18485)
+++ trunk/gforge_base/evolvisforge-5.1/src/etc/config.ini.d/defaults.ini	2012-07-12 11:26:09 UTC (rev 18486)
@@ -34,6 +34,7 @@
 account_manager_type = pgsql
 apache_group = "www-data"
 apache_user = "www-data"
+ci_user = "nobody"
 default_country_code = US
 default_language = English
 default_theme = gforge

Modified: trunk/gforge_base/evolvisforge-5.1/src/etc/config.ini.d/evolvis.ini
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/etc/config.ini.d/evolvis.ini	2012-07-12 11:26:04 UTC (rev 18485)
+++ trunk/gforge_base/evolvisforge-5.1/src/etc/config.ini.d/evolvis.ini	2012-07-12 11:26:09 UTC (rev 18486)
@@ -1,6 +1,7 @@
 ; Evolvis-specific configuration
 
 [core]
+ci_user = "maven"
 forge_name = Evolvis
 use_survey = false
 use_snippet = false

Modified: trunk/gforge_base/evolvisforge-5.1/src/utils/normalize_roles.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/utils/normalize_roles.php	2012-07-12 11:26:04 UTC (rev 18485)
+++ trunk/gforge_base/evolvisforge-5.1/src/utils/normalize_roles.php	2012-07-12 11:26:09 UTC (rev 18486)
@@ -34,11 +34,15 @@
 session_set_admin () ;
 
 function normalise_maven_user() {
-	$mvn = 'maven';
+	$mvn =& user_get_ci_user();
+	if (!$mvn) {
+		/* no "maven" user, return success */
+		return true;
+	}
 
 	$res = db_query_params('
 		DELETE FROM nss_usergroups WHERE user_name=$1',
-	    array($mvn));
+	    array($mvn->getUnixName()));
 	if (!$res) {
 		echo "on deletion: " . db_error() . "\n";
 		return false;
@@ -49,7 +53,7 @@
 		SELECT DISTINCT u.user_id+20000, g.group_id+10000, u.user_id,
 		    g.group_id, u.user_name, g.unix_group_name
 		FROM users u, groups g WHERE u.user_name=$1',
-	    array($mvn));
+	    array($mvn->getUnixName()));
 	if (!$res) {
 		echo "on addition: " . db_error() . "\n";
 		return false;
@@ -60,7 +64,7 @@
 		SELECT DISTINCT u.user_id+20000, g.group_id+50000, u.user_id,
 		    g.group_id, u.user_name, $2 || g.unix_group_name
 		FROM users u, groups g WHERE u.user_name=$1',
-	    array($mvn, 'scm_'));
+	    array($mvn->getUnixName(), 'scm_'));
 	if (!$res) {
 		echo "on addition (SCM): " . db_error() . "\n";
 		return false;



More information about the evolvis-commits mailing list