Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nId1D-0002G9-9w for pgsql-general@arkaria.postgresql.org; Fri, 11 Feb 2022 20:59:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nId1B-0001po-SW for pgsql-general@arkaria.postgresql.org; Fri, 11 Feb 2022 20:59:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nId1B-0001pf-I0 for pgsql-general@lists.postgresql.org; Fri, 11 Feb 2022 20:59:49 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nId19-0000nm-6c for pgsql-general@lists.postgresql.org; Fri, 11 Feb 2022 20:59:48 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 21BKxkIt2176818; Fri, 11 Feb 2022 15:59:46 -0500 From: Tom Lane To: Bryn Llewellyn cc: pgsql-general list 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: <0994D6C4-EDF0-4854-B528-88DDE429172E@yugabyte.com> References: <0994D6C4-EDF0-4854-B528-88DDE429172E@yugabyte.com> Comments: In-reply-to Bryn Llewellyn message dated "Fri, 11 Feb 2022 12:46:11 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2176816.1644613186.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 11 Feb 2022 15:59:46 -0500 Message-ID: <2176817.1644613186@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Bryn Llewellyn writes: > If user "x" owns function "s.f()", and if you want user "z" to be able t= o 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, "permi= ssion 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