public inbox for [email protected]  
help / color / mirror / Atom feed
From: Pavel Luzanov <[email protected]>
To: David G. Johnston <[email protected]>
Cc: David Zhang <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: psql: Add role's membership options to the \du+ command
Date: Fri, 3 Mar 2023 14:01:59 +0300
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAKFQuwbkywHVFPL6TrJiHFd0KgEvdH0LZTSFxAdK4wzP-u8m-A@mail.gmail.com>
References: <[email protected]>
	<[email protected]>
	<CAKFQuwYt3ENZoYgY2RBh-U4id_=vntT9uJ83PvxPSsPQ0Cc_Jw@mail.gmail.com>
	<[email protected]>
	<CAKFQuwbmAFfDw9ScCiOxK4UGf8Z8ny1nDgAn41gOJCeJ76QC4Q@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<CAKFQuwYZ3S_A1ZKdnmOv-LueO1683UZf7AocNFTDjwEMLVfMOA@mail.gmail.com>
	<[email protected]>
	<CAKFQuwbkywHVFPL6TrJiHFd0KgEvdH0LZTSFxAdK4wzP-u8m-A@mail.gmail.com>

Hello,

On 22.02.2023 00:34, David G. Johnston wrote:
> I didn't even know this function existed. But I see that it was 
> changed in 3d14e171 with updated documentation:
> https://www.postgresql.org/docs/devel/functions-info.html#FUNCTIONS-INFO-ACCESS
> Maybe that's enough.
>
>
> I think that should probably have ADMIN as one of the options as well. 
> Also curious what it reports for an empty membership.

I've been experimenting for a few days and I want to admit that this is 
a very difficult and not obvious topic.
I'll try to summarize what I think.

1.
About ADMIN value for pg_has_role.
Implementation of ADMIN value will be different from USAGE and SET.
To be True, USAGE value requires the full chain of memberships to have 
INHERIT option.
Similar with SET: the full chain of memberships must have SET option.
But for ADMIN, only last member in the chain must have ADMIN option and 
all previous members
must have INHERIT (to administer directly) or SET option (to switch to 
role, last in the chain).
Therefore, it is not obvious to me that the function needs the ADMIN value.

2.
pg_has_role function description starts with: Does user have privilege 
for role?
     - This is not exact: function works not only with users, but with 
NOLOGIN roles too.
     - Term "privilege": this term used for ACL columns, such usage may 
be confusing,
       especially after adding INHERIT and SET in addition to ADMIN option.

3.
It is possible to grant membership with all three options turned off:
     grant a to b with admin false, inherit false, set false;
But such membership is completely useless (if i didn't miss something).
May be such grants must be prohibited. At least this may be documented 
in the GRANT command.

4.
Since v16 it is possible to grant membership from one role to another 
several times with different grantors.
And only grantor can revoke membership.
     - This is not documented anywhere.
     - Current behavior of \du command with duplicated roles in "Member 
of" column strongly confusing.
       This is one of the goals of the discussion patch.

I think to write about this to pgsql-docs additionally to this topic.

-- 
Pavel Luzanov
Postgres Professional:https://postgrespro.com


view thread (29+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: psql: Add role's membership options to the \du+ command
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox