Skip to content
Permalink
Browse files
check schema privilege before table privilege
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8289 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Mar 27, 2008
1 parent 857da2e commit a0757cd9d02d0052728ee3adfb15f0a906b74359
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/app/qgsdbsourceselect.cpp
@@ -530,7 +530,8 @@ bool QgsDbSourceSelect::getTableInfo(PGconn *pg, bool searchGeometryColumnsOnly,
QString sql = "select * from geometry_columns,pg_class,pg_namespace "
"where relname=f_table_name and f_table_schema=nspname "
"and pg_namespace.oid = pg_class.relnamespace "
"and has_table_privilege('\"'||pg_namespace.nspname||'\".\"'||pg_class.relname||'\"','select')" // user has select privilege
"and has_schema_privilege(pg_namespace.nspname,'usage') "
"and has_table_privilege('\"'||pg_namespace.nspname||'\".\"'||pg_class.relname||'\"','select') " // user has select privilege
"order by f_table_schema,f_table_name";

PGresult *result = PQexec(pg, sql.toUtf8());
@@ -587,11 +588,12 @@ bool QgsDbSourceSelect::getTableInfo(PGconn *pg, bool searchGeometryColumnsOnly,
// geometry_columns table. This code is specific to postgresql,
// but an equivalent query should be possible in other
// databases.
sql = "select pg_class.relname, pg_namespace.nspname, pg_attribute.attname, pg_class.relkind "
sql = "select pg_class.relname,pg_namespace.nspname,pg_attribute.attname,pg_class.relkind "
"from pg_attribute, pg_class, pg_namespace "
"where pg_namespace.oid = pg_class.relnamespace "
"and pg_attribute.atttypid = regtype('geometry') "
"and pg_attribute.attrelid = pg_class.oid "
"and has_schema_privilege(pg_namespace.nspname,'usage') "
"and has_table_privilege('\"'||pg_namespace.nspname||'\".\"'||pg_class.relname||'\"','select') ";
// user has select privilege
if (searchPublicOnly)

0 comments on commit a0757cd

Please sign in to comment.