From: | Robert Haas <rhaas(at)postgresql(dot)org> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Refactor permissions-checking for role grants. |
Date: | 2023-01-05 19:33:04 |
Message-ID: | E1pDVz6-002D11-GE@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2023-01-05 19:35:20 | pgsql: Pass down current user ID to AddRoleMems and DelRoleMems. |
Previous Message | Tom Lane | 2023-01-05 19:12:34 | pgsql: Fix calculation of which GENERATED columns need to be updated. |