Re: [SQL] Foreign keys breaks tables permissions - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [SQL] Foreign keys breaks tables permissions
Date
Msg-id 25918.958691826@sss.pgh.pa.us
Whole thread Raw
Responses Re: [SQL] Foreign keys breaks tables permissions  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
Resurrecting a bug report from mid-April:

wieck@debis.com (Jan Wieck) writes:
>> If one does:
>> 
>> [...]
>> grant select on master to a_user;
>> grant select, insert, update, delete on detail to a_user;
>> 
>> then if login as "a_user" and does:
>> 
>> insert into detail (id, master_id) values (1, 10);
>> 
>> this will result in: "ERROR:   master: Permission denied".
>> 
>> This seems a bug to me ? Isn't it ?

> Outch,

>     yes,  we  missed  something  here.  Peter,  you  said  you'll
>     probably work  on  the  ACL  stuff  after  7.0.  We  need  to
>     coordinate that work with the function manager redesign to go
>     for SETUID triggers and functions.

I looked at this some more because people were complaining that it
was still broken in 7.0.  AFAICT, it's got nothing to do with SETUID
triggers or anything so hairy, it's just a question of what permissions
we think ought to be required for which actions.  The issue is very
simple: the RI insert trigger doesn't do a SELECT on the master table,
it does a SELECT FOR UPDATE --- and execMain.c thinks that that should
require UPDATE access rights to the master.

So, two questions:

1. Why is RI_FKey_check() using SELECT FOR UPDATE and not plain SELECT?

2. What permissions should SELECT FOR UPDATE require?

If the existing code is correct on both these points, then I think the
answer is that there is no bug: updating a table that has a foreign
key reference will require update rights on the master as well.  I would
rather conclude that one of these two points is wrong...
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Cary O'Brien"
Date:
Subject: Re: LONG: How to migrate data from MS-SQL7 to PostgreSQL 7.0
Next
From: Peter Eisentraut
Date:
Subject: Re: [GENERAL] Question about databases in alternate locations...