[evolvis-commits] r18476: Let normalise_roles do the maven user re-insertion dance

mirabilos at evolvis.org mirabilos at evolvis.org
Thu Jul 12 11:13:40 CEST 2012


Author: mirabilos
Date: 2012-07-12 11:13:39 +0200 (Thu, 12 Jul 2012)
New Revision: 18476

Modified:
   trunk/gforge_base/evolvisforge-5.1/src/debian/changelog
   trunk/gforge_base/evolvisforge-5.1/src/utils/normalize_roles.php
Log:
Let normalise_roles do the maven user re-insertion dance

XXX why is this still necessary? I have a hunch that *something*
XXX is modifying our database directly, on that very one box this
XXX issue occurs…

Modified: trunk/gforge_base/evolvisforge-5.1/src/debian/changelog
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/debian/changelog	2012-07-12 09:13:34 UTC (rev 18475)
+++ trunk/gforge_base/evolvisforge-5.1/src/debian/changelog	2012-07-12 09:13:39 UTC (rev 18476)
@@ -1,3 +1,10 @@
+fusionforge (1:5.1.1+evolvis65) xunstable; urgency=low
+
+  * Let normalise_roles do the maven user re-insertion dance
+    (again, this is necessary on *one* system we run only… why?)
+
+ -- Thorsten Glaser <t.glaser at tarent.de>  Thu, 12 Jul 2012 10:47:58 +0200
+
 fusionforge (1:5.1.1+evolvis64) unstable; urgency=low
 
   * [#3178] Fix tracker item creation

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 09:13:34 UTC (rev 18475)
+++ trunk/gforge_base/evolvisforge-5.1/src/utils/normalize_roles.php	2012-07-12 09:13:39 UTC (rev 18476)
@@ -2,6 +2,8 @@
 <?php
 /**
  * Copyright 2010 Roland Mas
+ * Copyright © 2010, 2012
+ *      Thorsten “mirabilos” Glaser <t.glaser at tarent.de>
  *
  * This file is part of FusionForge. FusionForge is free software;
  * you can redistribute it and/or modify it under the terms of the
@@ -31,6 +33,51 @@
 setup_plugin_manager () ;
 session_set_admin () ;
 
+function normalise_maven_user() {
+	$mvn = 'maven';
+
+	$res = db_query_params('
+		DELETE FROM nss_usergroups WHERE user_name=$1',
+	    array($mvn));
+	if (!$res) {
+		echo "on deletion: " . db_error() . "\n";
+		return false;
+	}
+
+	$res = db_query_params('
+		INSERT INTO nss_usergroups
+		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));
+	if (!$res) {
+		echo "on addition: " . db_error() . "\n";
+		return false;
+	}
+
+	$res = db_query_params('
+		INSERT INTO nss_usergroups
+		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_'));
+	if (!$res) {
+		echo "on addition (SCM): " . db_error() . "\n";
+		return false;
+	}
+
+	return true;
+}
+
+db_begin();
+echo "Re-adding the maven user to all groups...\n";
+if (normalise_maven_user()) {
+	db_commit();
+} else {
+	echo "Re-inserting the maven user to all groups FAILED.\n";
+	db_rollback();
+}
+
 $res = db_query_params ('SELECT role_id FROM pfo_role ORDER BY role_id',
 			array ());
 



More information about the evolvis-commits mailing list