BUG #18622: Attempt to grant role in absence of INHERIT option fails with internal error

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: exclusion(at)gmail(dot)com
Subject: BUG #18622: Attempt to grant role in absence of INHERIT option fails with internal error
Date: 2024-09-18 09:00:00
Message-ID: 18622-066b779aa707ab7a@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 18622
Logged by: Alexander Lakhin
Email address: exclusion(at)gmail(dot)com
PostgreSQL version: 17rc1
Operating system: Ubuntu 22.04
Description:

The last command of the following script:
CREATE ROLE role0;
CREATE ROLE role1 WITH CREATEROLE;
SET role role1;
CREATE ROLE role2 WITH CREATEROLE;
SET role role2;
CREATE ROLE role3;
CREATE ROLE role4;
SET role role1;

CREATE ROLE role5 IN ROLE role3;

fails with
ERROR: XX000: no possible grantors
LOCATION: check_role_grantor, user.c:2232

whilst:
CREATE ROLE role5 IN ROLE role0;
fails with
ERROR: permission denied to grant role "role0"
DETAIL: Only roles with the ADMIN option on role "role0" may grant this
role.

Another, simpler example:
GRANT role3 TO role4;
ERROR: no possible grantors

Both "no possible grantors" errors go away after:
GRANT role2 TO role1 WITH INHERIT OPTION;

This error is raised at check_role_grantor() where it accompanied by the
comment:
We shouldn't fail to find a best grantor ...

This was added by ce6b672e44 and was true back then, until cf5eb37c5.

Now this error is raised due to a difference between:
check_role_membership_authorization() -> is_admin_of_role() ->
roles_is_member_of(member, ROLERECURSE_MEMBERS, ...)
and
check_role_grantor() -> select_best_admin() ->
roles_is_member_of(member, ROLERECURSE_PRIVS, ...)

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2024-09-18 11:47:24 BUG #18623: postgresql v14.13.1 installation error
Previous Message David G. Johnston 2024-09-18 06:05:04 Re: INFORMATION_SCHEMA.routines column routine_definition does not show the source