mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Fix a bug in roles_is_member_of.
Commit e3ce2de09d rearranged this
function to be able to identify which inherited role had admin option
on the target role, but it got the order of operations wrong, causing
the function to return wrong answers in the presence of non-inherited
grants.
Fix that, and add a test case that verifies the correct behavior.
Patch by me, reviewed by Nathan Bossart
Discussion: http://postgr.es/m/CA+TgmoYamnu-xt-u7CqjYWnRiJ6BQaSpYOHXP=r4QGTfd1N_EA@mail.gmail.com
This commit is contained in:
@@ -4852,10 +4852,6 @@ roles_is_member_of(Oid roleid, enum RoleRecurseType type,
|
||||
Form_pg_auth_members form = (Form_pg_auth_members) GETSTRUCT(tup);
|
||||
Oid otherid = form->roleid;
|
||||
|
||||
/* If we're supposed to ignore non-heritable grants, do so. */
|
||||
if (type == ROLERECURSE_PRIVS && !form->inherit_option)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* While otherid==InvalidOid shouldn't appear in the catalog, the
|
||||
* OidIsValid() avoids crashing if that arises.
|
||||
@@ -4864,6 +4860,10 @@ roles_is_member_of(Oid roleid, enum RoleRecurseType type,
|
||||
OidIsValid(admin_of) && !OidIsValid(*admin_role))
|
||||
*admin_role = memberid;
|
||||
|
||||
/* If we're supposed to ignore non-heritable grants, do so. */
|
||||
if (type == ROLERECURSE_PRIVS && !form->inherit_option)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Even though there shouldn't be any loops in the membership
|
||||
* graph, we must test for having already seen this role. It is
|
||||
|
||||
Reference in New Issue
Block a user