Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rol1H-003CiD-9v for pgsql-general@arkaria.postgresql.org; Mon, 25 Mar 2024 14:09:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rol1F-003tQr-Hc for pgsql-general@arkaria.postgresql.org; Mon, 25 Mar 2024 14:09:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rol1F-003tQN-6O for pgsql-general@lists.postgresql.org; Mon, 25 Mar 2024 14:09:45 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rol1C-006LND-2Y for pgsql-general@lists.postgresql.org; Mon, 25 Mar 2024 14:09:44 +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 42PE9gV42475446; Mon, 25 Mar 2024 10:09:42 -0400 From: Tom Lane To: Christophe Pettus cc: "pgsql-generallists.postgresql.org" Subject: Re: No warning for a no-op REVOKE In-reply-to: References: Comments: In-reply-to Christophe Pettus message dated "Mon, 25 Mar 2024 06:54:30 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2475444.1711375782.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 25 Mar 2024 10:09:42 -0400 Message-ID: <2475445.1711375782@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Christophe Pettus writes: > Right now, if you do a REVOKE that doesn't actually revoke anything, it = works silently. This can be a bit of a foot-gun. For example: > CREATE FUNCTION f() RETURNS int as $$ SELECT 1; $$ LANGUAGE sql; > REVOKE EXECUTE ON FUNCTION f() FROM lowpriv; > Naively, it might be expected that `lowpriv` can't execute the function,= but unless default privileges have been changed, `lowpriv` still can unde= r the default grant of EXECUTE to PUBLIC. Since there was no previous gra= nt to `lowpriv`, nothing actually changes in the ACL. This bit a client r= ecently. > Is it worth generating a warning in this case? To be clear, even if there had been a grant of EXECUTE to lowpriv, that role would still be able to call the function thanks to the public EXECUTE permission. I'm not sure that warning about whether anything got revoked is going to help people who fundamentally misunderstand where the privilege is coming from. Still, I take your point that maybe the command should mention that nothing happened. To me the best argument for producing a warning is that we already do so for grants of roles: regression=3D# create user alice; CREATE ROLE regression=3D# create role bob; CREATE ROLE regression=3D# revoke bob from alice; WARNING: role "alice" has not been granted membership in role "bob" by ro= le "postgres" REVOKE ROLE However, ordinary privileges are a bit more complicated since multiple privilege bits can be specified: regression=3D# revoke select,update on table t from alice; REVOKE or even regression=3D# revoke select(x),update(y) on table t from alice; REVOKE Should we generate a warning when only some of the named privileges exist to be revoked? My initial reaction is that we should warn only when the command is a complete no-op, that is none of the mentioned privileges matched. But I've not thought about it very hard. regards, tom lane