[feladat @ 298]
authorpeter
Mon, 14 Jul 2008 20:17:34 +0000
changeset 189 b918c891f81d
parent 188 4066e4c0de01
child 190 7a683326ccec
[feladat @ 298] Bugfix: The GRANT statement for PostgreSQL is not correct. Modified the code to give the correct GRANT statement based on the tables in database-structure.inc.php. Reported by grin. Closes: #78.
install/database-structure.inc.php
install/index.php
--- a/install/database-structure.inc.php	Mon Jul 14 16:19:30 2008 +0000
+++ b/install/database-structure.inc.php	Mon Jul 14 20:17:34 2008 +0000
@@ -256,6 +256,13 @@
 			)
 		);
 
+// Tables from PowerDNS
+$grantTables = array('supermasters', 'domains', 'records');
+// Include PowerAdmin tables
+foreach($def_tables as $table) {
+	$grantTables[] = $table['table_name'];
+}
+
 $def_permissions = array(
 			array(41,'zone_master_add','User is allowed to add new master zones.'),
 			array(42,'zone_slave_add','User is allowed to add new slave zones.'),
--- a/install/index.php	Mon Jul 14 16:19:30 2008 +0000
+++ b/install/index.php	Mon Jul 14 20:17:34 2008 +0000
@@ -205,6 +205,10 @@
 		$dns_ns1 = $_POST['dns_ns1'];
 		$dns_ns2 = $_POST['dns_ns2'];
 
+		require_once("../inc/database.inc.php");
+		$db = dbConnect();
+		include_once("database-structure.inc.php");
+
 		echo "<p>" . _('You now want to give limited rights to Poweradmin so it can update the data in the tables. To do this, you should create a new user and give it rights to select, delete, insert and update records in the PowerDNS database.') . " ";
 		if ($db_type == 'mysql') {
 			echo _('In MySQL you should now perform the following command:') . "</p>";
@@ -218,10 +222,12 @@
 				"Shall the new user be allowed to create databases? (y/n) n<br>" . 
 				"Shall the new user be allowed to create more new users? (y/n) n<br>" . 
 				"CREATE USER<br>" . 
-				"$ psql " . $db_name . "<br>" .
-				"psql> GRANT SELECT, INSERT, DELETE, UPDATE<br>" . 
-				"ON " . $db_name . "<br>" .
-				"TO " . $db_user . ";</tt></p>\n";
+				"$ psql " . $db_name . "<br>";
+				foreach ($grantTables as $tableName) {
+					echo "psql> GRANT SELECT, INSERT, DELETE, UPDATE ON " . $tableName . " TO " . $db_user . ";<br />";
+					echo "GRANT<br />";
+				}
+				echo "</tt></p>\n";
 		}
 		echo "<p>" . _('After you have added the new user, proceed with this installation procedure.') . "</p>\n";
 		echo "<form method=\"post\">";