Skip to content

Commit

Permalink
Bugfix: The GRANT statement for PostgreSQL is not correct.
Browse files Browse the repository at this point in the history
Modified the code to give the correct GRANT statement based on the tables in database-structure.inc.php.
Reported by grin. Closes: poweradmin#78.
  • Loading branch information
pbeernink committed Jul 14, 2008
1 parent f5b017c commit afc0da1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
7 changes: 7 additions & 0 deletions install/database-structure.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.'),
Expand Down
14 changes: 10 additions & 4 deletions install/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ function error($msg) {
$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>";
Expand All @@ -218,10 +222,12 @@ function error($msg) {
"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\">";
Expand Down

0 comments on commit afc0da1

Please sign in to comment.