pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
A function privilege problem
5+ messages / 3 participants
[nested] [flat]

* A function privilege problem
@ 2019-07-23 08:07 高 云龙 <gaoyunlong@biss.com>
  2019-07-23 16:50 ` Re: A function privilege problem Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 5+ messages in thread

From: 高 云龙 @ 2019-07-23 08:07 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

Hi ,my postgresql is 11.1 and find a problem about the execute privilege

Now I have a new db user  and a UDF. The function’s body is update a table

When I run grant update on table xxx to the new user, find that i can execute the function and don’t report "Execute permission for functions<https://www.postgresql.org/message-id/4C2BBAEA.6040805%40gmail.com; xxx”,Is this right?

How i find which db user have the privilege to a function?  and the \dp+ or \df+ is not work.




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: A function privilege problem
  2019-07-23 08:07 A function privilege problem 高 云龙 <gaoyunlong@biss.com>
@ 2019-07-23 16:50 ` Tom Lane <tgl@sss.pgh.pa.us>
  2019-07-25 02:05   ` Re: A function privilege problem 高 云龙 <gaoyunlong@biss.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Tom Lane @ 2019-07-23 16:50 UTC (permalink / raw)
  To: 高 云龙 <gaoyunlong@biss.com>; +Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

=?gb2312?B?uN8g1MbB+g==?= <gaoyunlong@biss.com> writes:
> Hi ,my postgresql is 11.1 and find a problem about the execute privilege
> Now I have a new db user  and a UDF. The function¡¯s body is update a table

> When I run grant update on table xxx to the new user, find that i can execute the function and don¡¯t report "Execute permission for functions<https://www.postgresql.org/message-id/4C2BBAEA.6040805%40gmail.com; xxx¡±£¬Is this right£¿

This is not a bug.  Per the GRANT manual page [1]:

    PostgreSQL grants default privileges on some types of objects to
    PUBLIC. No privileges are granted to PUBLIC by default on tables,
    table columns, sequences, foreign data wrappers, foreign servers,
    large objects, schemas, or tablespaces. For other types of objects,
    the default privileges granted to PUBLIC are as follows: CONNECT and
    TEMPORARY (create temporary tables) privileges for databases;
    EXECUTE privilege for functions and procedures; and USAGE privilege
    for languages and data types (including domains). The object owner
    can, of course, REVOKE both default and expressly granted
    privileges. (For maximum security, issue the REVOKE in the same
    transaction that creates the object; then there is no window in which
    another user can use the object.) Also, these initial default
    privilege settings can be changed using the ALTER DEFAULT PRIVILEGES
    command.

So the new user is making use of the default grant of EXECUTE to PUBLIC.
If you don't want that, revoke execute privilege on that function from
PUBLIC and then grant it to just the users who should be allowed to call
the function.

			regards, tom lane

[1] https://www.postgresql.org/docs/current/sql-grant.html





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: A function privilege problem
  2019-07-23 08:07 A function privilege problem 高 云龙 <gaoyunlong@biss.com>
  2019-07-23 16:50 ` Re: A function privilege problem Tom Lane <tgl@sss.pgh.pa.us>
@ 2019-07-25 02:05   ` 高 云龙 <gaoyunlong@biss.com>
  2019-07-25 03:08     ` Re: A function privilege problem David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: 高 云龙 @ 2019-07-25 02:05 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>



> 在 2019年7月24日,上午10:09,yunlong <gaoyunlong@biss.com> 写道:
> 
> What’s PUBLIC mean ? public schema ?
> My function is not in public schema, and I still can execute the function with the new db user after run revoke execute on function xxx from xxx
> 
>> 在 2019年7月24日,上午12:50,Tom Lane <tgl@sss.pgh.pa.us> 写道:
>> 
>> =?gb2312?B?uN8g1MbB+g==?= <gaoyunlong@biss.com> writes:
>>> Hi ,my postgresql is 11.1 and find a problem about the execute privilege
>>> Now I have a new db user  and a UDF. The function¡¯s body is update a table
>> 
>>> When I run grant update on table xxx to the new user, find that i can execute the function and don¡¯t report "Execute permission for functions<https://www.postgresql.org/message-id/4C2BBAEA.6040805%40gmail.com; xxx¡±£¬Is this right£¿
>> 
>> This is not a bug.  Per the GRANT manual page [1]:
>> 
>>   PostgreSQL grants default privileges on some types of objects to
>>   PUBLIC. No privileges are granted to PUBLIC by default on tables,
>>   table columns, sequences, foreign data wrappers, foreign servers,
>>   large objects, schemas, or tablespaces. For other types of objects,
>>   the default privileges granted to PUBLIC are as follows: CONNECT and
>>   TEMPORARY (create temporary tables) privileges for databases;
>>   EXECUTE privilege for functions and procedures; and USAGE privilege
>>   for languages and data types (including domains). The object owner
>>   can, of course, REVOKE both default and expressly granted
>>   privileges. (For maximum security, issue the REVOKE in the same
>>   transaction that creates the object; then there is no window in which
>>   another user can use the object.) Also, these initial default
>>   privilege settings can be changed using the ALTER DEFAULT PRIVILEGES
>>   command.
>> 
>> So the new user is making use of the default grant of EXECUTE to PUBLIC.
>> If you don't want that, revoke execute privilege on that function from
>> PUBLIC and then grant it to just the users who should be allowed to call
>> the function.
>> 
>> 			regards, tom lane
>> 
>> [1] https://www.postgresql.org/docs/current/sql-grant.html
> 
Make a copy for pgsql-bugs@lists.postgresql.org

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: A function privilege problem
  2019-07-23 08:07 A function privilege problem 高 云龙 <gaoyunlong@biss.com>
  2019-07-23 16:50 ` Re: A function privilege problem Tom Lane <tgl@sss.pgh.pa.us>
  2019-07-25 02:05   ` Re: A function privilege problem 高 云龙 <gaoyunlong@biss.com>
@ 2019-07-25 03:08     ` David G. Johnston <david.g.johnston@gmail.com>
  2019-07-26 03:56       ` Re: A function privilege problem 高 云龙 <gaoyunlong@biss.com>
  0 siblings, 1 reply; 5+ messages in thread

From: David G. Johnston @ 2019-07-25 03:08 UTC (permalink / raw)
  To: 高 云龙 <gaoyunlong@biss.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

On Wednesday, July 24, 2019, 高 云龙 <gaoyunlong@biss.com> wrote:
>
> > 在 2019年7月24日,上午10:09,yunlong <gaoyunlong@biss.com> 写道:
> >
> > What’s PUBLIC mean ? public schema ?
> > My function is not in public schema, and I still can execute the
> function with the new db user after run revoke execute on function xxx from
> xxx
> >
>
>
PUBLIC here is referring to the system group that all roles are implicitly
and permanently members of.

You need to replace xxx with actual values and a self-contained script if
you want others to understand what is being questioned.

David J.

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: A function privilege problem
  2019-07-23 08:07 A function privilege problem 高 云龙 <gaoyunlong@biss.com>
  2019-07-23 16:50 ` Re: A function privilege problem Tom Lane <tgl@sss.pgh.pa.us>
  2019-07-25 02:05   ` Re: A function privilege problem 高 云龙 <gaoyunlong@biss.com>
  2019-07-25 03:08     ` Re: A function privilege problem David G. Johnston <david.g.johnston@gmail.com>
@ 2019-07-26 03:56       ` 高 云龙 <gaoyunlong@biss.com>
  0 siblings, 0 replies; 5+ messages in thread

From: 高 云龙 @ 2019-07-26 03:56 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

Thx for you , get it

在 2019年7月25日,上午11:08,David G. Johnston <david.g.johnston@gmail.com<mailto:david.g.johnston@gmail.com>> 写道:

On Wednesday, July 24, 2019, 高 云龙 <gaoyunlong@biss.com<mailto:gaoyunlong@biss.com>> wrote:
> 在 2019年7月24日,上午10:09,yunlong <gaoyunlong@biss.com<mailto:gaoyunlong@biss.com>> 写道:
>
> What’s PUBLIC mean ? public schema ?
> My function is not in public schema, and I still can execute the function with the new db user after run revoke execute on function xxx from xxx
>


PUBLIC here is referring to the system group that all roles are implicitly and permanently members of.

You need to replace xxx with actual values and a self-contained script if you want others to understand what is being questioned.

David J.



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2019-07-26 03:56 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-07-23 08:07 A function privilege problem 高 云龙 <gaoyunlong@biss.com>
2019-07-23 16:50 ` Tom Lane <tgl@sss.pgh.pa.us>
2019-07-25 02:05   ` 高 云龙 <gaoyunlong@biss.com>
2019-07-25 03:08     ` David G. Johnston <david.g.johnston@gmail.com>
2019-07-26 03:56       ` 高 云龙 <gaoyunlong@biss.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox