From: Tom Lane <tgl@sss.pgh.pa.us>
To: Christophe Pettus <xof@thebuild.com>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: No warning for a no-op REVOKE
Date: Mon, 25 Mar 2024 10:09:42 -0400
Message-ID: <2475445.1711375782@sss.pgh.pa.us> (raw)
In-Reply-To: <B3BA06C0-EB3B-4AE7-8C03-61A8E4D13971@thebuild.com>
References: <B3BA06C0-EB3B-4AE7-8C03-61A8E4D13971@thebuild.com>
Christophe Pettus <xof@thebuild.com> 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 under the default grant of EXECUTE to PUBLIC. Since there was no previous grant to `lowpriv`, nothing actually changes in the ACL. This bit a client recently.
> 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=# create user alice;
CREATE ROLE
regression=# create role bob;
CREATE ROLE
regression=# revoke bob from alice;
WARNING: role "alice" has not been granted membership in role "bob" by role "postgres"
REVOKE ROLE
However, ordinary privileges are a bit more complicated since
multiple privilege bits can be specified:
regression=# revoke select,update on table t from alice;
REVOKE
or even
regression=# 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
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, xof@thebuild.com
Subject: Re: No warning for a no-op REVOKE
In-Reply-To: <2475445.1711375782@sss.pgh.pa.us>
References: <B3BA06C0-EB3B-4AE7-8C03-61A8E4D13971@thebuild.com> <2475445.1711375782@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