pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephen Frost <sfrost@snowman.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Wolfgang Walther <walther@technowledgy.de>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: User with BYPASSRLS privilege can't change password
Date: Tue, 3 Nov 2020 15:02:38 -0500
Message-ID: <20201103200237.GY16415@tamriel.snowman.net> (raw)
In-Reply-To: <961302.1604429512@sss.pgh.pa.us>
References: <a5548a9f-89ee-3167-129d-162b5985fcf8@technowledgy.de>
	<923005.1604420579@sss.pgh.pa.us>
	<956994.1604425451@sss.pgh.pa.us>
	<3e771893-1ed1-97e7-6c4a-7b0d00992103@technowledgy.de>
	<958492.1604427541@sss.pgh.pa.us>
	<be39bd26-4024-0bf5-eb28-31984a887265@technowledgy.de>
	<961302.1604429512@sss.pgh.pa.us>

Greetings,

* Tom Lane (tgl@sss.pgh.pa.us) wrote:
> Wolfgang Walther <walther@technowledgy.de> writes:
> > Tom Lane:
> >> so AFAICS it's impossible to get there.  If it isn't impossible,
> >> we have a much bigger hole with respect to issuper.
> 
> > Yes, you're right. I read the || as &&. And also missed the ! in else if 
> > (!have_createrole_privilege()) btw. :)
> 
> Actually the right way to deal with this potential confusion is to
> add a comment, as below.  I fixed the docs too.
> 
> > I guess the error message "must be superuser to alter replication users" 
> > led me on the wrong path. I would be more precise as "must be superuser 
> > to alter replication users or change replication attribute" to cover the 
> > change-non-replication-to-replication user case, I think. The same thing 
> > for superusers.
> 
> I'd be okay with changing the error text in HEAD, but less so in the back
> branches, since that'd cause thrashing of translatable strings.

I tend to agree with that.

> diff --git a/doc/src/sgml/ref/alter_role.sgml b/doc/src/sgml/ref/alter_role.sgml
> index aef30521bc..5aa5648ae7 100644
> --- a/doc/src/sgml/ref/alter_role.sgml
> +++ b/doc/src/sgml/ref/alter_role.sgml
> @@ -71,7 +71,9 @@ ALTER ROLE { <replaceable class="parameter">role_specification</replaceable> | A
>     Attributes not mentioned in the command retain their previous settings.
>     Database superusers can change any of these settings for any role.
>     Roles having <literal>CREATEROLE</literal> privilege can change any of these
> -   settings, but only for non-superuser and non-replication roles.
> +   settings except <literal>SUPERUSER</literal>, <literal>REPLICATION</literal>,
> +   and <literal>BYPASSRLS</literal>; but only for non-superuser and
> +   non-replication roles.
>     Ordinary roles can only change their own password.
>    </para>

This looks good, though should we also mention that you have to be a
superuser to set BYPASSRLS on a role in the CREATE ROLE documentation
too..?  The error message there could also be improved, it looks like.
Also, we don't seem to document in CREATE ROLE that you have to be a
superuser to create a REPLICATION role either, even though the code
clearly says that.

Attached is a patch for all of those.  As mentioned, the error message
probably only makes sense to change in HEAD, though improving the
documentation could be back-patched.

Thanks,

Stephen

Attachments:

cleanup_bypassrls_v1.patch (text/x-diff, 1.6K) download diff --git a/doc/src/sgml/ref/create_role.sgml b/doc/src/sgml/ref/create_role.sgml index d23133945d..0d9c430789 100644 --- a/doc/src/sgml/ref/create_role.sgml +++ b/doc/src/sgml/ref/create_role.sgml @@ -181,6 +181,8 @@ in sync when changing the above synopsis! highly privileged role, and should only be used on roles actually used for replication. If not specified, <literal>NOREPLICATION</literal> is the default. + You must be a superuser to create a new role having the + <literal>REPLICATION</literal> attribute set. </para> </listitem> </varlistentry> @@ -196,7 +198,8 @@ in sync when changing the above synopsis! <literal>OFF</literal> by default, to ensure all contents of a table are dumped out. If the user running pg_dump does not have appropriate permissions, an error will be returned. The superuser and owner of the - table being dumped always bypass RLS. + table being dumped always bypass RLS. You must be a superuser to create + a new role having the <literal>BYPASSRLS</literal> attribute set. </para> </listitem> </varlistentry> diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c index 9ce9a66921..4a93b68ee3 100644 --- a/src/backend/commands/user.c +++ b/src/backend/commands/user.c @@ -305,7 +305,7 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt) if (!superuser()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("must be superuser to change bypassrls attribute"))); + errmsg("must be superuser to create bypassrls users"))); } else {
signature.asc (application/pgp-signature, 818B) download

view thread (14+ messages)  latest in thread

Message-ID: <20201103200237.GY16415@tamriel.snowman.net>
Permalink:  ../20201103200237.GY16415@tamriel.snowman.net/
Also on:    postgresql.org/message-id/20201103200237.GY16415@tamriel.snowman.net

 ·  · 

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: pgsql-bugs@postgresql.org
  Cc: sfrost@snowman.net, tgl@sss.pgh.pa.us, walther@technowledgy.de, pgsql-bugs@lists.postgresql.org
  Subject: Re: User with BYPASSRLS privilege can't change password
  In-Reply-To: <20201103200237.GY16415@tamriel.snowman.net>

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

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