Commit 1e3372e6 authored by Barry Lind's avatar Barry Lind

Fix bug in reading acls (didn't treat null acl as meaning the table owner had

full privs), also updated the regression test for this case.

 Modified Files:
 	jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
 	jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
parent 04897830
......@@ -2466,7 +2466,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
byte column[] = rs.getBytes("attname");
String owner = rs.getString("usename");
String acl = rs.getString("relacl");
Hashtable permissions = parseACL(acl);
Hashtable permissions = parseACL(acl, owner);
String permNames[] = new String[permissions.size()];
Enumeration e = permissions.keys();
int i=0;
......@@ -2569,7 +2569,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
byte table[] = rs.getBytes("relname");
String owner = rs.getString("usename");
String acl = rs.getString("relacl");
Hashtable permissions = parseACL(acl);
Hashtable permissions = parseACL(acl, owner);
String permNames[] = new String[permissions.size()];
Enumeration e = permissions.keys();
int i=0;
......@@ -2693,7 +2693,11 @@ public abstract class AbstractJdbc1DatabaseMetaData
* a Hashtable mapping the SQL permission name to a Vector of
* usernames who have that permission.
*/
protected Hashtable parseACL(String aclArray) {
protected Hashtable parseACL(String aclArray, String owner) {
if (aclArray == null || aclArray == "") {
//null acl is a shortcut for owner having full privs
aclArray = "{" + owner + "=arwdRxt}";
}
Vector acls = parseACLArray(aclArray);
Hashtable privileges = new Hashtable();
for (int i=0; i<acls.size(); i++) {
......
......@@ -9,7 +9,7 @@ import java.sql.*;
*
* PS: Do you know how difficult it is to type on a train? ;-)
*
* $Id: DatabaseMetaDataTest.java,v 1.16 2002/11/11 07:11:12 barry Exp $
* $Id: DatabaseMetaDataTest.java,v 1.17 2003/03/24 03:48:32 barry Exp $
*/
public class DatabaseMetaDataTest extends TestCase
......@@ -237,13 +237,19 @@ public class DatabaseMetaDataTest extends TestCase
public void testTablePrivileges()
{
// At the moment just test that no exceptions are thrown KJ
try
{
DatabaseMetaData dbmd = con.getMetaData();
assertNotNull(dbmd);
ResultSet rs = dbmd.getTablePrivileges(null,null,"grantme");
ResultSet rs = dbmd.getTablePrivileges(null,null,"testmetadata");
boolean l_foundSelect = false;
while (rs.next()) {
if (rs.getString("GRANTEE").equals(TestUtil.getUser())
&& rs.getString("PRIVILEGE").equals("SELECT")) l_foundSelect = true;
}
rs.close();
//Test that the table owner has select priv
assertTrue("Couldn't find SELECT priv on table testmetadata for " + TestUtil.getUser(),l_foundSelect);
} catch (SQLException sqle) {
sqle.printStackTrace();
fail(sqle.getMessage());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment