Re: function privileges - Mailing list pgsql-novice

From Murat Tasan
Subject Re: function privileges
Date
Msg-id 5E51EF19-3E23-41BD-B98F-FACB6D5774C2@cwru.edu
Whole thread Raw
In response to Re: function privileges  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: function privileges
List pgsql-novice
On 2 Feb 2006, at 23:57, Tom Lane wrote:

> Murat Tasan <murat.tasan@cwru.edu> writes:
>> If user A comes along and has no SELECT privileges on T, but has
>> EXECUTE privileges on F, A is not permitted to run the function, with
>> an error stating access to T is needed.

All within schema "public"...
Let T be a table (say with primary key "id" and column "name") with
no SELECT privileges for user A.
Now, as the owner of the database, execute
CREATE FUNCTION F(T.id%TYPE) RETURNS T.name%TYPE AS $$ SELECT name
FROM T WHERE id = $1; $$ LANGUAGE SQL;

Now login as user A and try:
SELECT * FROM F(69);
(and let 69 be some id in T).

The execution fails, stating that user A doesn't have SELECT
privileges on T.

>> Now, if user B comes along and has SELECT privileges on T, but not
>> EXECUTE privileges on F, B is permitted to run the function.

This latter problem has been addressed by Michael Fuhr's email, I
didn't realize all new functions had PUBLIC execution permissions by
default, so revoking B's permissions to execute F don't make a
difference until I revoke PUBLIC's permissions as well.  In fact, I
didn't see this anywhere in the documentation, although that's
probably my fault from my frequent speed-reading ;-)

> I don't think I believe either of the above statements.  Perhaps you
> could provide a complete example of what you're doing?
>
>             regards, tom lane

Thanks again for all the help!

Murat

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: How do I interpret the data returned from a DeadLock-Exception?(Java)
Next
From: Tom Lane
Date:
Subject: Re: function privileges