Permission to Select - Mailing list pgsql-sql

From Eugene E.
Subject Permission to Select
Date
Msg-id 441540AA.3090202@bankir.ru
Whole thread Raw
In response to Re: REINDEX DATABASE  (Achilleus Mantzios <achill@matrix.gatewaynet.com>)
Responses Constraint Error effect on PostgreSQL
Re: Permission to Select
Re: Permission to Select
List pgsql-sql
Hi all
the serious problem with permissions is encountered

NOTE: the following example is really useful but there is no room to 
describe it's use.


db=# CREATE USER u;
db=# CREATE TABLE t (i int, a text);
db=# REVOKE all ON t FROM u;
db=# GRANT update,insert,delete ON t TO u;
db=# \c - u

db=> INSERT INTO t VALUES (1,'x');
INSERT
db=> UPDATE t SET a='y' WHERE i=1;
ERROR: Permission denied for relation t;
db=> UPDATE t SET a='y';
UPDATE

1) The user "u" is permitted but unable to perfom the operation !
2) A user is able to update WHOLE table but unable to update ANY part of 
it !


Please examine the following patch and make your judgment:

--- src/backend/executor/execMain.c.orig 2005-11-22 1:23:08.000000000 +0300
+++ src/backend/executor/execMain.c 2006-02-17 13:19:29.000000000 +0300
@@ -460,6 +460,16 @@
bool            do_select_into;
TupleDesc       tupType;

+       if ( operation == CMD_UPDATE || operation == CMD_DELETE )
+       {
+               ListCell   *l;
+               foreach(l, parseTree->rtable)
+               {
+                       RangeTblEntry *rte = lfirst(l);
+                       rte->requiredPerms ^= ACL_SELECT;
+               }
+       }
+
/*
* Do permissions checks.  It's sufficient to examine the query's top
* rangetable here --- subplan RTEs will be checked during




pgsql-sql by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Question re: relational technique
Next
From: "Christian Paul B. Cosinas"
Date:
Subject: Constraint Error effect on PostgreSQL