diff options
Diffstat (limited to 'src/backend/utils/adt/acl.c')
-rw-r--r-- | src/backend/utils/adt/acl.c | 38 |
1 files changed, 2 insertions, 36 deletions
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index 0a16f8156cb..5d939de3da7 100644 --- a/src/backend/utils/adt/acl.c +++ b/src/backend/utils/adt/acl.c @@ -4619,11 +4619,6 @@ pg_role_aclcheck(Oid role_oid, Oid roleid, AclMode mode) { if (mode & ACL_GRANT_OPTION_FOR(ACL_CREATE)) { - /* - * XXX For roleid == role_oid, is_admin_of_role() also examines the - * session and call stack. That suits two-argument pg_has_role(), but - * it gives the three-argument version a lamentable whimsy. - */ if (is_admin_of_role(roleid, role_oid)) return ACLCHECK_OK; } @@ -4935,38 +4930,9 @@ is_admin_of_role(Oid member, Oid role) if (superuser_arg(member)) return true; + /* By policy, a role cannot have WITH ADMIN OPTION on itself. */ if (member == role) - - /* - * A role can admin itself when it matches the session user and we're - * outside any security-restricted operation, SECURITY DEFINER or - * similar context. SQL-standard roles cannot self-admin. However, - * SQL-standard users are distinct from roles, and they are not - * grantable like roles: PostgreSQL's role-user duality extends the - * standard. Checking for a session user match has the effect of - * letting a role self-admin only when it's conspicuously behaving - * like a user. Note that allowing self-admin under a mere SET ROLE - * would make WITH ADMIN OPTION largely irrelevant; any member could - * SET ROLE to issue the otherwise-forbidden command. - * - * Withholding self-admin in a security-restricted operation prevents - * object owners from harnessing the session user identity during - * administrative maintenance. Suppose Alice owns a database, has - * issued "GRANT alice TO bob", and runs a daily ANALYZE. Bob creates - * an alice-owned SECURITY DEFINER function that issues "REVOKE alice - * FROM carol". If he creates an expression index calling that - * function, Alice will attempt the REVOKE during each ANALYZE. - * Checking InSecurityRestrictedOperation() thwarts that attack. - * - * Withholding self-admin in SECURITY DEFINER functions makes their - * behavior independent of the calling user. There's no security or - * SQL-standard-conformance need for that restriction, though. - * - * A role cannot have actual WITH ADMIN OPTION on itself, because that - * would imply a membership loop. Therefore, we're done either way. - */ - return member == GetSessionUserId() && - !InLocalUserIdChange() && !InSecurityRestrictedOperation(); + return false; (void) roles_is_member_of(member, ROLERECURSE_MEMBERS, role, &result); return result; |