pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bryn Llewellyn <bryn@yugabyte.com>
Cc: pgsql-general list <pgsql-general@lists.postgresql.org>
Subject: Re: "grant usage on schema" confers the ability to execute all user-defined functions in that schema, with needing to grant "execute"
Date: Fri, 11 Feb 2022 15:59:46 -0500
Message-ID: <2176817.1644613186@sss.pgh.pa.us> (raw)
In-Reply-To: <0994D6C4-EDF0-4854-B528-88DDE429172E@yugabyte.com>
References: <0994D6C4-EDF0-4854-B528-88DDE429172E@yugabyte.com>

Bryn Llewellyn <bryn@yugabyte.com> writes:
> If user "x" owns function "s.f()", and if you want user "z" to be able to execute it, then this alone is insufficient:

> grant execute on function s.f() to z;

> The attempt by "z" to execute "s.f()" this draws the 42501 error, "permission denied for schema s". But this _is_ sufficient:

> grant usage on schema s to z;
> revoke execute on function s.f() from z; -- Yes, really!

> *This surprises me*

It shouldn't.  Per the docs, the default permissions on a function
include GRANT EXECUTE TO PUBLIC.  Revoking the never-granted-in-the-
first-place permission to z doesn't remove the PUBLIC permission.

So, if you want to be selective about who can use your functions,
you should revoke the PUBLIC permission and then grant out
permissions to individual roles.

			regards, tom lane





view thread (18+ messages)  latest in thread

Message-ID: <2176817.1644613186@sss.pgh.pa.us>
Permalink:  ../2176817.1644613186@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2176817.1644613186@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, bryn@yugabyte.com
  Subject: Re: "grant usage on schema" confers the ability to execute all user-defined functions in that schema, with needing to grant "execute"
  In-Reply-To: <2176817.1644613186@sss.pgh.pa.us>
  References: <0994D6C4-EDF0-4854-B528-88DDE429172E@yugabyte.com> <2176817.1644613186@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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