pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert Haas <rhaas@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Refactor permissions-checking for role grants.
Date: Thu, 05 Jan 2023 19:33:04 +0000
Message-ID: <E1pDVz6-002D11-GE@gemulon.postgresql.org> (raw)

Refactor permissions-checking for role grants.

Instead of having checks in AddRoleMems() and DelRoleMems(), have
the callers perform checks where it's required. In some cases it
isn't, either because the caller has already performed a check for
the same condition, or because the check couldn't possibly fail.

The "Skip permission check if nothing to do" check in each of
AddRoleMems() and DelRoleMems() is pointless. Some call sites
can't pass an empty list. Others can, but in those cases, the role
being modified is one that the current user has just created.
Therefore, they must have permission to modify it, and so no
permission check is required at all.

This patch is intended to have no user-visible consequences. It is
intended to simplify future work in this area.

Patch by me, reviewed by Mark Dilger.

Discussion: http://postgr.es/m/CA+TgmobFzTLkLwOquFrAcdsWBsOWDr-_H-jw+qBvfx-wSzMwDA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/25bb03166b16db1faf18c677ed88f046fb08103f

Modified Files
--------------
src/backend/commands/user.c | 116 +++++++++++++++++++++-----------------------
1 file changed, 54 insertions(+), 62 deletions(-)



Message-ID: <E1pDVz6-002D11-GE@gemulon.postgresql.org>
Permalink:  ../E1pDVz6-002D11-GE@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pDVz6-002D11-GE@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: rhaas@postgresql.org
  Subject: Re: pgsql: Refactor permissions-checking for role grants.
  In-Reply-To: <E1pDVz6-002D11-GE@gemulon.postgresql.org>
  References: <E1pDVz6-002D11-GE@gemulon.postgresql.org>

* 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