pgsql: Refactor permissions-checking for role grants. - Mailing list pgsql-committers

From Robert Haas
Subject pgsql: Refactor permissions-checking for role grants.
Date
Msg-id E1pDVz6-002D11-GE@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Fix calculation of which GENERATED columns need to be updated.
Next
From: Robert Haas
Date:
Subject: pgsql: Pass down current user ID to AddRoleMems and DelRoleMems.