Re: CATUPDATE confusion?

Lists: pgsql-hackers
From: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: CATUPDATE confusion?
Date: 2014-11-24 21:28:46
Message-ID: CAKRt6CQOvT2KiyKg2gFf7h9k8+JVU1149zLb0EXTkKk7TAQGMQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

All,

While reviewing the supporting documentation and functions for role
attributes I noticed that there seems to be some confusion (at least for
me) with CATUPDATE.

This was prompted by the following comment from Peter about
'has_rolcatupdate' not having a superuser check.

http://www.postgresql.org/message-id/54590BBF.1080008@gmx.net

So, where I find this confusing is that the documentation supports this
functionality and the check keeps superuser separate from CATUPDATE...
however... comments and implementation in user.c state/do the opposite and
couple them together.

Documentation:
http://www.postgresql.org/docs/9.4/static/catalog-pg-authid.html - "Role
can update system catalogs directly. (Even a superuser cannot do this
unless this column is true)"

src/backend/commands/user.c

/* superuser gets catupdate right by default */
new_record[Anum_pg_authid_rolcatupdate - 1] = BoolGetDatum(issuper);

and...

/*
* issuper/createrole/catupdate/etc
*
* XXX It's rather unclear how to handle catupdate. It's probably best to
* keep it equal to the superuser status, otherwise you could end up with
* a situation where no existing superuser can alter the catalogs,
* including pg_authid!
*/
if (issuper >= 0)
{
new_record[Anum_pg_authid_rolsuper - 1] = BoolGetDatum(issuper > 0);
new_record_repl[Anum_pg_authid_rolsuper - 1] = true;

new_record[Anum_pg_authid_rolcatupdate - 1] = BoolGetDatum(issuper > 0);
new_record_repl[Anum_pg_authid_rolcatupdate - 1] = true;
}

Perhaps this is not an issue but it seemed odd to me, especially after
giving Peter's comment more thought. So, I suppose the question is whether
or not a superuser check should be added to 'has_rolcatupdate' or not? I
believe I understand the reasoning for coupling the two at role
creation/alter time, however, is there really a case where a superuser
wouldn't be allowed to bypass this check? Based on the comments, there
seems like there is potentially enough concern to allow it. And if it is
allowed, couldn't CATUPDATE then be treated like every other attribute and
the coupling with superuser removed? Thoughts?

Thanks,
Adam

--
Adam Brightwell - adam(dot)brightwell(at)crunchydatasolutions(dot)com
Database Engineer - www.crunchydatasolutions.com


From: Noah Misch <noah(at)leadboat(dot)com>
To: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2014-12-27 08:09:26
Message-ID: 20141227080926.GA2035611@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Nov 24, 2014 at 04:28:46PM -0500, Adam Brightwell wrote:
> So, where I find this confusing is that the documentation supports this
> functionality and the check keeps superuser separate from CATUPDATE...
> however... comments and implementation in user.c state/do the opposite and
> couple them together.
>
> Documentation:
> http://www.postgresql.org/docs/9.4/static/catalog-pg-authid.html - "Role
> can update system catalogs directly. (Even a superuser cannot do this
> unless this column is true)"
>
> src/backend/commands/user.c
>
> /* superuser gets catupdate right by default */
> new_record[Anum_pg_authid_rolcatupdate - 1] = BoolGetDatum(issuper);
>
> and...
>
> /*
> * issuper/createrole/catupdate/etc
> *
> * XXX It's rather unclear how to handle catupdate. It's probably best to
> * keep it equal to the superuser status, otherwise you could end up with
> * a situation where no existing superuser can alter the catalogs,
> * including pg_authid!
> */
> if (issuper >= 0)
> {
> new_record[Anum_pg_authid_rolsuper - 1] = BoolGetDatum(issuper > 0);
> new_record_repl[Anum_pg_authid_rolsuper - 1] = true;
>
> new_record[Anum_pg_authid_rolcatupdate - 1] = BoolGetDatum(issuper > 0);
> new_record_repl[Anum_pg_authid_rolcatupdate - 1] = true;
> }

That documentation is correct as far it goes. It does neglect to mention
that, as you have discovered, any CREATE ROLE or ALTER ROLE [NO]SUPERUSER will
change rolcatupdate to match.

> Perhaps this is not an issue but it seemed odd to me, especially after
> giving Peter's comment more thought. So, I suppose the question is whether
> or not a superuser check should be added to 'has_rolcatupdate' or not? I

I would not. PostgreSQL has had this feature since day one (original name
"usecatupd"). It has two use cases, (1) giving effect to non-superuser
catalog grants and (2) preventing a narrow class of superuser mistakes. We
wouldn't add such a thing today, but one can safely ignore its existence.
Making has_rolcatupdate() approve superusers unconditionally would exclude use
case (2). Neither use case is valuable, but if I had to pick, (2) is more
valuable than (1).

> believe I understand the reasoning for coupling the two at role
> creation/alter time, however, is there really a case where a superuser
> wouldn't be allowed to bypass this check? Based on the comments, there
> seems like there is potentially enough concern to allow it. And if it is
> allowed, couldn't CATUPDATE then be treated like every other attribute and
> the coupling with superuser removed? Thoughts?

A superuser always has _some_ way to bypass the check, if nothing else by
loading a C-language function to update pg_authid. The user.c code you quoted
ensures that, if the DBA manages to remove rolcatupdate from every user, a
simple CREATE ROLE or ALTER ROLE can fix things.


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2014-12-27 15:10:34
Message-ID: 20141227151034.GU3062@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Noah Misch (noah(at)leadboat(dot)com) wrote:
> On Mon, Nov 24, 2014 at 04:28:46PM -0500, Adam Brightwell wrote:
> > Perhaps this is not an issue but it seemed odd to me, especially after
> > giving Peter's comment more thought. So, I suppose the question is whether
> > or not a superuser check should be added to 'has_rolcatupdate' or not? I
>
> I would not. PostgreSQL has had this feature since day one (original name
> "usecatupd"). It has two use cases, (1) giving effect to non-superuser
> catalog grants and (2) preventing a narrow class of superuser mistakes. We
> wouldn't add such a thing today, but one can safely ignore its existence.
> Making has_rolcatupdate() approve superusers unconditionally would exclude use
> case (2). Neither use case is valuable, but if I had to pick, (2) is more
> valuable than (1).

What's confusing about this is that use-case (2) appears to have been
the intent of the option, but because it's tied directly to superuser
and isn't an independently controllable option, the only way change it
is to do an 'update pg_authid ...'. Even when set that way, it isn't
visible that it's been set through \du, you have to query the catalog
directly.

I wonder if the option had originally been intended to be independent
and *not* given to superusers by default, but because of the concern
about dealing with corrupt systems, etc, it was never actually done.
I'm fine with the line of thinking that says we can't deny superusers
this power because of corruption/debugging concerns, but if that's the
case, then there is no use-case (2) and we should just remove the option
entirely.

I don't buy into use-case (1) above being at all reasonable. With it,
one can trivially make themselves a superuser, and in many ways the
catupdate capability is *more* dangerous than superuser- if you have
catupdate but not superuser, you'd be tempted to hack at the catalog to
make the changes you want instead of using the regular ALTER TABLE, etc,
commands.

Thanks,

Stephen


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Noah Misch <noah(at)leadboat(dot)com>, Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2014-12-27 18:02:04
Message-ID: 28382.1419703324@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Stephen Frost <sfrost(at)snowman(dot)net> writes:
> * Noah Misch (noah(at)leadboat(dot)com) wrote:
>> On Mon, Nov 24, 2014 at 04:28:46PM -0500, Adam Brightwell wrote:
>>> Perhaps this is not an issue but it seemed odd to me, especially after
>>> giving Peter's comment more thought. So, I suppose the question is whether
>>> or not a superuser check should be added to 'has_rolcatupdate' or not? I

>> I would not. PostgreSQL has had this feature since day one (original name
>> "usecatupd"). It has two use cases, (1) giving effect to non-superuser
>> catalog grants and (2) preventing a narrow class of superuser mistakes. We
>> wouldn't add such a thing today, but one can safely ignore its existence.
>> Making has_rolcatupdate() approve superusers unconditionally would exclude use
>> case (2). Neither use case is valuable, but if I had to pick, (2) is more
>> valuable than (1).

> What's confusing about this is that use-case (2) appears to have been
> the intent of the option,

Yes. Noah's claim that anybody intended (1) seems to be mere historical
revisionism, especially since as you note CATUPDATE could be trivially
parlayed into superuser if someone were to grant it to a non-superuser.

> but because it's tied directly to superuser
> and isn't an independently controllable option, the only way change it
> is to do an 'update pg_authid ...'. Even when set that way, it isn't
> visible that it's been set through \du, you have to query the catalog
> directly.

This is not hard to understand either: the option dates from long before
there was any concerted effort to invent bespoke SQL commands for every
interesting catalog manipulation. If CATUPDATE had any significant use,
we'd have extended ALTER USER (and \du, and pg_dump ...) at some point
to make it more easily controllable. But since it's of such marginal
usefulness, nobody ever bothered; and I doubt we should bother now.

In short, I agree with Noah's conclusion (do nothing) though not his
reasoning.

Plan C (remove CATUPDATE altogether) also has some merit. But adding a
superuser override there would be entirely pointless.

regards, tom lane


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Noah Misch <noah(at)leadboat(dot)com>, Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2014-12-27 23:18:29
Message-ID: 20141227231829.GX3062@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Tom Lane (tgl(at)sss(dot)pgh(dot)pa(dot)us) wrote:
> Plan C (remove CATUPDATE altogether) also has some merit. But adding a
> superuser override there would be entirely pointless.

This is be my recommendation. I do not see the point of carrying the
option around just to confuse new users of pg_authid and reviewers of
the code.

Thanks,

Stephen


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Noah Misch <noah(at)leadboat(dot)com>, Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2014-12-27 23:26:02
Message-ID: 1952.1419722762@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Stephen Frost <sfrost(at)snowman(dot)net> writes:
> * Tom Lane (tgl(at)sss(dot)pgh(dot)pa(dot)us) wrote:
>> Plan C (remove CATUPDATE altogether) also has some merit. But adding a
>> superuser override there would be entirely pointless.

> This is be my recommendation. I do not see the point of carrying the
> option around just to confuse new users of pg_authid and reviewers of
> the code.

Yeah ... if no one's found it interesting in the 20 years since the
code left Berkeley, it's unlikely that interest will emerge in the
future.

regards, tom lane


From: Noah Misch <noah(at)leadboat(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2014-12-27 23:31:50
Message-ID: 20141227233150.GA2046947@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Dec 27, 2014 at 06:26:02PM -0500, Tom Lane wrote:
> Stephen Frost <sfrost(at)snowman(dot)net> writes:
> > * Tom Lane (tgl(at)sss(dot)pgh(dot)pa(dot)us) wrote:
> >> Plan C (remove CATUPDATE altogether) also has some merit. But adding a
> >> superuser override there would be entirely pointless.
>
> > This is be my recommendation. I do not see the point of carrying the
> > option around just to confuse new users of pg_authid and reviewers of
> > the code.
>
> Yeah ... if no one's found it interesting in the 20 years since the
> code left Berkeley, it's unlikely that interest will emerge in the
> future.

No objection here.


From: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2014-12-30 00:16:29
Message-ID: CAKRt6CTrOf6w5sE5GDRQAJ+JQrfK4h8VM=jVCtiGC+mdFsmXGg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

All,

On Sat, Dec 27, 2014 at 6:31 PM, Noah Misch <noah(at)leadboat(dot)com> wrote:

> On Sat, Dec 27, 2014 at 06:26:02PM -0500, Tom Lane wrote:
> > Stephen Frost <sfrost(at)snowman(dot)net> writes:
> > > * Tom Lane (tgl(at)sss(dot)pgh(dot)pa(dot)us) wrote:
> > >> Plan C (remove CATUPDATE altogether) also has some merit. But adding
> a
> > >> superuser override there would be entirely pointless.
> >
> > > This is be my recommendation. I do not see the point of carrying the
> > > option around just to confuse new users of pg_authid and reviewers of
> > > the code.
> >
> > Yeah ... if no one's found it interesting in the 20 years since the
> > code left Berkeley, it's unlikely that interest will emerge in the
> > future.
>
> No objection here.
>

Given this discussion, I have attached a patch that removes CATUPDATE for
review/discussion.

One of the interesting behaviors (or perhaps not) is how 'pg_class_aclmask'
handles an invalid role id when checking permissions against 'rolsuper'
instead of 'rolcatupdate'. This is demonstrated by the
'has_table_privilege' regression test expected results. In summary,
'has_rolcatupdate' raises an error when an invalid OID is provided,
however, as documented in the source 'superuser_arg' does not, simply
returning false. Therefore, when checking for superuser-ness of an
non-existent role, the result will be false and not an error. Perhaps this
is OK, but my concern would be on the expected behavior around items like
'has_table_privilege'. My natural thought would be that we would want to
preserve that specific functionality, though short of adding a
'has_rolsuper' function that will raise an appropriate error, I'm uncertain
of an approach. Thoughts?

Thanks,
Adam

--
Adam Brightwell - adam(dot)brightwell(at)crunchydatasolutions(dot)com
Database Engineer - www.crunchydatasolutions.com

Attachment Content-Type Size
remove-catupdate-v1.patch text/x-patch 10.7 KB

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>
Cc: Noah Misch <noah(at)leadboat(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2014-12-30 01:34:36
Message-ID: 20141230013435.GI3062@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Adam,

* Adam Brightwell (adam(dot)brightwell(at)crunchydatasolutions(dot)com) wrote:
> Given this discussion, I have attached a patch that removes CATUPDATE for
> review/discussion.

Thanks!

> One of the interesting behaviors (or perhaps not) is how 'pg_class_aclmask'
> handles an invalid role id when checking permissions against 'rolsuper'
> instead of 'rolcatupdate'. This is demonstrated by the
> 'has_table_privilege' regression test expected results. In summary,
> 'has_rolcatupdate' raises an error when an invalid OID is provided,
> however, as documented in the source 'superuser_arg' does not, simply
> returning false. Therefore, when checking for superuser-ness of an
> non-existent role, the result will be false and not an error. Perhaps this
> is OK, but my concern would be on the expected behavior around items like
> 'has_table_privilege'. My natural thought would be that we would want to
> preserve that specific functionality, though short of adding a
> 'has_rolsuper' function that will raise an appropriate error, I'm uncertain
> of an approach. Thoughts?

This role oid check is only getting called in this case because it's
pg_authid which is getting checked (because it's a system catalog table)
and it's then falling into this one case. I don't think we need to
preserve that.

If you do the same query with that bogus OID but a normal table, you get
the same 'f' result that the regression test gives with this change.
We're not back-patching this and I seriously doubt anyone is relying on
this special response for system catalog tables.

So, unless anyone wants to object, I'll continue to look over this patch
for eventual application against master. If there are objections, it'd
be great if they could be voiced sooner rather than later.

Thanks!

Stephen


From: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Noah Misch <noah(at)leadboat(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-01-19 17:47:08
Message-ID: CAKRt6CTD4OPkgXFSqRQjZ5mr8xoaqcNhAdUaS0VuOiDxiQuSGQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

>
> * Adam Brightwell (adam(dot)brightwell(at)crunchydatasolutions(dot)com) wrote:
> > Given this discussion, I have attached a patch that removes CATUPDATE for
> > review/discussion.
>
> Thanks!

I've added this patch (up-thread) to the next CommitFest (2015-02).

-Adam

--
Adam Brightwell - adam(dot)brightwell(at)crunchydatasolutions(dot)com
Database Engineer - www.crunchydatasolutions.com


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, Noah Misch <noah(at)leadboat(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-02-19 21:05:04
Message-ID: 54E65000.8030304@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 12/29/14 7:16 PM, Adam Brightwell wrote:
> Given this discussion, I have attached a patch that removes CATUPDATE
> for review/discussion.
>
> One of the interesting behaviors (or perhaps not) is how
> 'pg_class_aclmask' handles an invalid role id when checking permissions
> against 'rolsuper' instead of 'rolcatupdate'.

I'd get rid of that whole check, not just replace rolcatupdate by rolsuper.


From: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Noah Misch <noah(at)leadboat(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-02-19 23:08:09
Message-ID: CAKRt6CQmJ1PXh+FSzxwQFu5PT2=sQkNpGER7QUP=uL0Ob_Jhig@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter,

Thanks for the review and feedback.

> One of the interesting behaviors (or perhaps not) is how
> > 'pg_class_aclmask' handles an invalid role id when checking permissions
> > against 'rolsuper' instead of 'rolcatupdate'.
>
> I'd get rid of that whole check, not just replace rolcatupdate by rolsuper.
>

Ah yes, that's a good point. I have updated and attached a new version of
the patch.

Thanks,
Adam

--
Adam Brightwell - adam(dot)brightwell(at)crunchydatasolutions(dot)com
Database Engineer - www.crunchydatasolutions.com

Attachment Content-Type Size
remove-catupdate-v2.patch application/octet-stream 10.6 KB

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Noah Misch <noah(at)leadboat(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-02-25 05:53:55
Message-ID: CAB7nPqQqDypK52VThzS9-jj+k83bKUYN4rv4g8NCiG+Fv1SSsQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Feb 20, 2015 at 8:08 AM, Adam Brightwell <
adam(dot)brightwell(at)crunchydatasolutions(dot)com> wrote:

> Thanks for the review and feedback.
>
> > One of the interesting behaviors (or perhaps not) is how
>> > 'pg_class_aclmask' handles an invalid role id when checking permissions
>> > against 'rolsuper' instead of 'rolcatupdate'.
>>
>> I'd get rid of that whole check, not just replace rolcatupdate by
>> rolsuper.
>>
>
> Ah yes, that's a good point. I have updated and attached a new version of
> the patch.
>

I just had a look at this patch and it works as intended, simply removing
catupdate and all its code paths. As everybody on this thread seems to
agree about the removal of rolcatupdate, I think that we could let a
committer have a look at it.
Thoughts?
--
Michael


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-02-25 20:39:56
Message-ID: 20150225203955.GY29780@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Peter Eisentraut (peter_e(at)gmx(dot)net) wrote:
> On 12/29/14 7:16 PM, Adam Brightwell wrote:
> > Given this discussion, I have attached a patch that removes CATUPDATE
> > for review/discussion.
> >
> > One of the interesting behaviors (or perhaps not) is how
> > 'pg_class_aclmask' handles an invalid role id when checking permissions
> > against 'rolsuper' instead of 'rolcatupdate'.
>
> I'd get rid of that whole check, not just replace rolcatupdate by rolsuper.

Err, wouldn't this make it possible to grant normal users the ability to
modify system catalogs? I realize that they wouldn't have that
initially, but I'm not sure we want the superuser to be able to grant
that to non-superusers..

I'm fine with making it "if system table and not superuser, error".

Thanks!

Stephen


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-02-26 03:01:02
Message-ID: 54EE8C6E.8090506@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2/25/15 3:39 PM, Stephen Frost wrote:
>> I'd get rid of that whole check, not just replace rolcatupdate by rolsuper.
>
> Err, wouldn't this make it possible to grant normal users the ability to
> modify system catalogs? I realize that they wouldn't have that
> initially, but I'm not sure we want the superuser to be able to grant
> that to non-superusers..

Why not? I thought we are trying to get rid of special superuser behavior.

After all, superusers can also make the other user a superuser to bypass
this issue.


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-02-26 03:05:41
Message-ID: 20150226030541.GG29780@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Peter Eisentraut (peter_e(at)gmx(dot)net) wrote:
> On 2/25/15 3:39 PM, Stephen Frost wrote:
> >> I'd get rid of that whole check, not just replace rolcatupdate by rolsuper.
> >
> > Err, wouldn't this make it possible to grant normal users the ability to
> > modify system catalogs? I realize that they wouldn't have that
> > initially, but I'm not sure we want the superuser to be able to grant
> > that to non-superusers..
>
> Why not? I thought we are trying to get rid of special superuser behavior.

Agreed, but I'd also like to get rid of any reason, beyond emergency
cases, for people to modify the catalog directly. There's a few places
which we aren't yet doing that, but I'd rather fix those cases than
encourage people to give out rights to modify them and end up making
things like:

"UPDATE pg_database SET datallowconn = false where datname = 'xyz';"

an accepted interface.

> After all, superusers can also make the other user a superuser to bypass
> this issue.

Sure, but that gives us the option to write off whatever happens next as
not our fault.

Thanks,

Stephen


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-02-28 21:47:26
Message-ID: 54F2376E.9080501@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2/25/15 10:05 PM, Stephen Frost wrote:
> * Peter Eisentraut (peter_e(at)gmx(dot)net) wrote:
>> On 2/25/15 3:39 PM, Stephen Frost wrote:
>>>> I'd get rid of that whole check, not just replace rolcatupdate by rolsuper.
>>>
>>> Err, wouldn't this make it possible to grant normal users the ability to
>>> modify system catalogs? I realize that they wouldn't have that
>>> initially, but I'm not sure we want the superuser to be able to grant
>>> that to non-superusers..
>>
>> Why not? I thought we are trying to get rid of special superuser behavior.
>
> Agreed, but I'd also like to get rid of any reason, beyond emergency
> cases, for people to modify the catalog directly. There's a few places
> which we aren't yet doing that, but I'd rather fix those cases than
> encourage people to give out rights to modify them and end up making
> things like:
>
> "UPDATE pg_database SET datallowconn = false where datname = 'xyz';"
>
> an accepted interface.

I'm not sure those things are related.

Getting rid of the *reasons* for updating catalogs directly might be
worthwhile, but I don't see why we need to install (or maintain) a
special invisible permission trap for it. We have a permission system,
and it works pretty well.

The Unix kernels don't have special traps for someone to modify
/etc/shadow or similar directly. That file has appropriate permissions,
and that's it. I think that works pretty well.


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-02-28 23:32:45
Message-ID: 20150228233245.GO29780@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter,

* Peter Eisentraut (peter_e(at)gmx(dot)net) wrote:
> On 2/25/15 10:05 PM, Stephen Frost wrote:
> > Agreed, but I'd also like to get rid of any reason, beyond emergency
> > cases, for people to modify the catalog directly. There's a few places
> > which we aren't yet doing that, but I'd rather fix those cases than
> > encourage people to give out rights to modify them and end up making
> > things like:
> >
> > "UPDATE pg_database SET datallowconn = false where datname = 'xyz';"
> >
> > an accepted interface.
>
> I'm not sure those things are related.

Eh, I feel they are, but either way.

> Getting rid of the *reasons* for updating catalogs directly might be
> worthwhile, but I don't see why we need to install (or maintain) a
> special invisible permission trap for it. We have a permission system,
> and it works pretty well.

We have this "invisible permission trap" known as checking if you're a
superuser all over the place. I'm not against revisiting those cases
and considering using the GRANT permission system to manage access, but
that's certainly a larger project to work on. What I'm referring to
here are all the functions that check if you're a superuser, instead of
just revoking EXECUTE from public and letting the user manage the
permission.

> The Unix kernels don't have special traps for someone to modify
> /etc/shadow or similar directly. That file has appropriate permissions,
> and that's it. I think that works pretty well.

This isn't really /etc/shadow though, this is more like direct access to
the filesystem through the device node- and you'll note that Linux
certainly has got an independent set of permissions for that called the
capabilities system. That's because messing with those pieces can crash
the kernel. You're not going to crash the kernel if you goof up
/etc/shadow.

Thanks!

Stephen


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-03-03 21:32:27
Message-ID: 54F6286B.90802@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2/28/15 6:32 PM, Stephen Frost wrote:
> This isn't really /etc/shadow though, this is more like direct access to
> the filesystem through the device node- and you'll note that Linux
> certainly has got an independent set of permissions for that called the
> capabilities system. That's because messing with those pieces can crash
> the kernel. You're not going to crash the kernel if you goof up
> /etc/shadow.

I think this characterization is incorrect. The Linux capability system
does not exist because the actions are scary or can crash the kernel.
Capabilities exist because they are not attached to file system objects
and can therefore not be represented using the usual permission system.

Note that one can write directly to raw devices or the kernel memory
through various /dev and /proc files. No "capability" protects against
that. It's only the file permissions, possibly in combination with
mount options.


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-03-05 02:59:23
Message-ID: 54F7C68B.9060609@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Any other opinions?

The options are:

0) Leave as is.

1) Remove catupdate and replace with superuser checks.

2) Remove catupdate and rely on regular table permissions on catalogs.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-03-05 03:38:40
Message-ID: 5067.1425526720@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> Any other opinions?
> The options are:
> 0) Leave as is.
> 1) Remove catupdate and replace with superuser checks.
> 2) Remove catupdate and rely on regular table permissions on catalogs.

I think I vote for (1). I do not like (2) because of the argument I made
upthread that write access on system catalogs is far more dangerous than
a naive DBA might think. (0) has some attraction but really CATUPDATE
is one more concept than we need.

On the other hand, if Stephen is going to push forward with his plan to
subdivide superuserness, we might have the equivalent of CATUPDATE right
back again. (But at least it would be properly documented and
supported...)

regards, tom lane


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-03-05 16:49:07
Message-ID: 20150305164907.GB29780@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Tom Lane (tgl(at)sss(dot)pgh(dot)pa(dot)us) wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> > Any other opinions?
> > The options are:
> > 0) Leave as is.
> > 1) Remove catupdate and replace with superuser checks.
> > 2) Remove catupdate and rely on regular table permissions on catalogs.
>
> I think I vote for (1). I do not like (2) because of the argument I made
> upthread that write access on system catalogs is far more dangerous than
> a naive DBA might think. (0) has some attraction but really CATUPDATE
> is one more concept than we need.

I agree with #1 on this.

> On the other hand, if Stephen is going to push forward with his plan to
> subdivide superuserness, we might have the equivalent of CATUPDATE right
> back again. (But at least it would be properly documented and
> supported...)

The subdivision of superuserness is intended only for operations which
can't be used to directly give the user superuser access back and
therefore I don't think we'd ever put back CATUPDATE or an equivilant.

I'd much rather reduce the need for direct catalog modifications by
adding additional syntax for those operations which can't be done
without modifying the catalog directly and, where it makes sense to, add
a way to control access to those operations.

For example, changing a database to not accept connections seems like
something the database owner should be allowed to do. Perhaps that'd be
interesting to allow users other than the owner to do, perhaps it
doesn't, but that would be an independent question to address.

Thanks!

Stephen


From: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Noah Misch <noah(at)leadboat(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-03-06 15:36:25
Message-ID: CAKRt6CQUA+mFS0Qcoe862R1hyeae+ZOHK=C1Eza9RgtCFYSEUw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

All,

Thanks for all the feedback and review.

> I think I vote for (1). I do not like (2) because of the argument I made
> > upthread that write access on system catalogs is far more dangerous than
> > a naive DBA might think. (0) has some attraction but really CATUPDATE
> > is one more concept than we need.
>
> I agree with #1 on this.
>

#1 makes sense to me as well. The current version of the patch takes this
approach. Also, I have verified against 'master' as of c6ee39b.

Thanks,
Adam

--
Adam Brightwell - adam(dot)brightwell(at)crunchydatasolutions(dot)com
Database Engineer - www.crunchydatasolutions.com


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, Noah Misch <noah(at)leadboat(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-03-07 04:43:47
Message-ID: 54FA8203.8080709@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 12/29/14 7:16 PM, Adam Brightwell wrote:
> Given this discussion, I have attached a patch that removes CATUPDATE
> for review/discussion.

committed this version


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-03-07 05:31:03
Message-ID: 4593.1425706263@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> On 12/29/14 7:16 PM, Adam Brightwell wrote:
>> Given this discussion, I have attached a patch that removes CATUPDATE
>> for review/discussion.

> committed this version

Hmm .. I'm not sure that summarily removing usecatupd from those three
system views was well thought out. pg_shadow, especially, has no reason
to live at all except for backwards compatibility, and clients might well
expect that column to still be there. I wonder if we'd not be better off
to keep the column in the views but have it read from rolsuper.

regards, tom lane


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-03-07 14:11:20
Message-ID: 54FB0708.7070200@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 3/7/15 12:31 AM, Tom Lane wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
>> On 12/29/14 7:16 PM, Adam Brightwell wrote:
>>> Given this discussion, I have attached a patch that removes CATUPDATE
>>> for review/discussion.
>
>> committed this version
>
> Hmm .. I'm not sure that summarily removing usecatupd from those three
> system views was well thought out. pg_shadow, especially, has no reason
> to live at all except for backwards compatibility, and clients might well
> expect that column to still be there. I wonder if we'd not be better off
> to keep the column in the views but have it read from rolsuper.

I doubt anyone is reading the column. And if they are, they should stop.

pg_shadow and pg_user have been kept around because it is plausible that
a lot of tools want to have a list of users, and requiring all of them
to change to pg_authid at once was deemed too onerous at the time. I
don't think this requires us to keep all the details the same forever.


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-03-07 14:24:41
Message-ID: 20150307142441.GD29780@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Peter Eisentraut (peter_e(at)gmx(dot)net) wrote:
> On 3/7/15 12:31 AM, Tom Lane wrote:
> > Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> >> On 12/29/14 7:16 PM, Adam Brightwell wrote:
> >>> Given this discussion, I have attached a patch that removes CATUPDATE
> >>> for review/discussion.
> >
> >> committed this version
> >
> > Hmm .. I'm not sure that summarily removing usecatupd from those three
> > system views was well thought out. pg_shadow, especially, has no reason
> > to live at all except for backwards compatibility, and clients might well
> > expect that column to still be there. I wonder if we'd not be better off
> > to keep the column in the views but have it read from rolsuper.
>
> I doubt anyone is reading the column. And if they are, they should stop.

Certainly pgAdmin and similar tools are. From that standpoint though, I
agree that they should be modified to no longer read it, as the whole
point of those kinds of tools is to allow users to modify those
attributes and having CATUPDATE in the view would surely be confusing as
the user wouldn't be able to modify it.

> pg_shadow and pg_user have been kept around because it is plausible that
> a lot of tools want to have a list of users, and requiring all of them
> to change to pg_authid at once was deemed too onerous at the time. I
> don't think this requires us to keep all the details the same forever.

pg_shadow, pg_user and pg_group were added when role support was added,
specifically for backwards compatibility. I don't believe there was
ever discussion about keeping them because filtering pg_roles based on
rolcanlogin was too onerous. That said, we already decided recently
that we wanted to keep them updated to match the actual attributes
available (note that the replication role attribute modified those
views) and I think that makes sense on the removal side as well as the
new-attribute side.

I continue to feel that we really should officially deprecate those
views as I don't think they're actually all that useful any more and
maintaining them ends up bringing up all these questions, discussion,
and ends up being largely busy-work if no one really uses them.

Thanks,

Stephen


From: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Noah Misch <noah(at)leadboat(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-03-07 23:40:18
Message-ID: CAKRt6CRJVrSixLPfQQDh5k9rkviCxCv8CvFhr_wuB8HMwX-BDA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

All,

> pg_shadow, pg_user and pg_group were added when role support was added,
> specifically for backwards compatibility. I don't believe there was
> ever discussion about keeping them because filtering pg_roles based on
> rolcanlogin was too onerous. That said, we already decided recently
> that we wanted to keep them updated to match the actual attributes
> available (note that the replication role attribute modified those
> views) and I think that makes sense on the removal side as well as the
> new-attribute side.
>
> I continue to feel that we really should officially deprecate those
> views as I don't think they're actually all that useful any more and
> maintaining them ends up bringing up all these questions, discussion,
> and ends up being largely busy-work if no one really uses them.
>

Deprecation would certainly seem like an appropriate path for 'usecatupd'
(and the mentioned views). Though, is there a 'formal' deprecation
policy/process that the community follows? I certainly understand and
support giving client/dependent tools the time and opportunity to update
accordingly. Therefore, I think having them read from 'rolsuper' for the
time being would be ok, provided that they are actually removed at the next
possible opportunity. Otherwise, I'd probably lean towards just removing
them now and getting it over with.

-Adam

--
Adam Brightwell - adam(dot)brightwell(at)crunchydatasolutions(dot)com
Database Engineer - www.crunchydatasolutions.com


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Noah Misch <noah(at)leadboat(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-03-10 12:52:54
Message-ID: CA+TgmoaCea0wKzT0W4z7onHTVzogemP5Za+6wwWKsC4WJoin5A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Mar 7, 2015 at 6:40 PM, Adam Brightwell
<adam(dot)brightwell(at)crunchydatasolutions(dot)com> wrote:
>> pg_shadow, pg_user and pg_group were added when role support was added,
>> specifically for backwards compatibility. I don't believe there was
>> ever discussion about keeping them because filtering pg_roles based on
>> rolcanlogin was too onerous. That said, we already decided recently
>> that we wanted to keep them updated to match the actual attributes
>> available (note that the replication role attribute modified those
>> views) and I think that makes sense on the removal side as well as the
>> new-attribute side.
>>
>> I continue to feel that we really should officially deprecate those
>> views as I don't think they're actually all that useful any more and
>> maintaining them ends up bringing up all these questions, discussion,
>> and ends up being largely busy-work if no one really uses them.
>
> Deprecation would certainly seem like an appropriate path for 'usecatupd'
> (and the mentioned views). Though, is there a 'formal' deprecation
> policy/process that the community follows? I certainly understand and
> support giving client/dependent tools the time and opportunity to update
> accordingly. Therefore, I think having them read from 'rolsuper' for the
> time being would be ok, provided that they are actually removed at the next
> possible opportunity. Otherwise, I'd probably lean towards just removing
> them now and getting it over with.

Unless some popular tool like pgAdmin is using these views, I'd say we
should just nuke them outright. If it breaks somebody's installation,
then they can always recreate the view on their particular system.
That seems like an adequate workaround to me.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Noah Misch <noah(at)leadboat(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-03-13 02:36:17
Message-ID: 20150313023617.GX29780@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Robert Haas (robertmhaas(at)gmail(dot)com) wrote:
> On Sat, Mar 7, 2015 at 6:40 PM, Adam Brightwell
> <adam(dot)brightwell(at)crunchydatasolutions(dot)com> wrote:
> >> pg_shadow, pg_user and pg_group were added when role support was added,
> >> specifically for backwards compatibility. I don't believe there was
> >> ever discussion about keeping them because filtering pg_roles based on
> >> rolcanlogin was too onerous. That said, we already decided recently
> >> that we wanted to keep them updated to match the actual attributes
> >> available (note that the replication role attribute modified those
> >> views) and I think that makes sense on the removal side as well as the
> >> new-attribute side.
> >>
> >> I continue to feel that we really should officially deprecate those
> >> views as I don't think they're actually all that useful any more and
> >> maintaining them ends up bringing up all these questions, discussion,
> >> and ends up being largely busy-work if no one really uses them.
> >
> > Deprecation would certainly seem like an appropriate path for 'usecatupd'
> > (and the mentioned views). Though, is there a 'formal' deprecation
> > policy/process that the community follows? I certainly understand and
> > support giving client/dependent tools the time and opportunity to update
> > accordingly. Therefore, I think having them read from 'rolsuper' for the
> > time being would be ok, provided that they are actually removed at the next
> > possible opportunity. Otherwise, I'd probably lean towards just removing
> > them now and getting it over with.
>
> Unless some popular tool like pgAdmin is using these views, I'd say we
> should just nuke them outright. If it breaks somebody's installation,
> then they can always recreate the view on their particular system.
> That seems like an adequate workaround to me.

As near as I can tell, pgAdmin3 does still use pg_user (though I don't
think it uses pg_group or pg_shadow except when connected to an ancient
server) in some cases. Where it is used, based on my quick review at
least, it looks like it'd be pretty easy to fix.

The rolcatupdate usage appears to all be associated with pg_authid
though, and the changes required to remove the places where it shows up
doesn't look particularly bad either. There are no references to
usecatupdate. Where there are references to 'use*', they'd have to also
be updated with the change to pg_user, naturally.

Looking at phppgadmin, there are quite a few more uses of pg_user there,
along with references to pg_group and even pg_shadow (for 8.0 and
earlier backends). Amusingly, the only place 'catupdate' is referenced
there is in the Polish language file. Updating phppgadmin to not
reference pg_user or the other views looks like it'd be a bit more work,
but not a huge effort either.

Basically, in my view at least, these programs are likely to continue to
use these backwards compatibility views until we either formally
deprecate them or (more likely) until we actually remove them and things
break. As such, I'm not sure if this information really helps us make a
decision here.

Thanks!

Stephen


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Noah Misch <noah(at)leadboat(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-03-13 13:21:46
Message-ID: CA+TgmoZshwViqpXO7G_qmoALyi1v3FGAn3aBJwwRTzGw=0ZBgw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Mar 12, 2015 at 10:36 PM, Stephen Frost <sfrost(at)snowman(dot)net> wrote:
> As near as I can tell, pgAdmin3 does still use pg_user (though I don't
> think it uses pg_group or pg_shadow except when connected to an ancient
> server) in some cases. Where it is used, based on my quick review at
> least, it looks like it'd be pretty easy to fix.
>
> The rolcatupdate usage appears to all be associated with pg_authid
> though, and the changes required to remove the places where it shows up
> doesn't look particularly bad either. There are no references to
> usecatupdate. Where there are references to 'use*', they'd have to also
> be updated with the change to pg_user, naturally.
>
> Looking at phppgadmin, there are quite a few more uses of pg_user there,
> along with references to pg_group and even pg_shadow (for 8.0 and
> earlier backends). Amusingly, the only place 'catupdate' is referenced
> there is in the Polish language file. Updating phppgadmin to not
> reference pg_user or the other views looks like it'd be a bit more work,
> but not a huge effort either.
>
> Basically, in my view at least, these programs are likely to continue to
> use these backwards compatibility views until we either formally
> deprecate them or (more likely) until we actually remove them and things
> break. As such, I'm not sure if this information really helps us make a
> decision here.

After poking at this a bit, I am guessing the reason they still use
pg_user is that regular users don't have permission to access
pg_authid directly. We don't want to make it impossible for pgAdmin
to work for non-superusers.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Noah Misch <noah(at)leadboat(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-03-13 13:47:42
Message-ID: 20150313134742.GZ29780@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert,

* Robert Haas (robertmhaas(at)gmail(dot)com) wrote:
> On Thu, Mar 12, 2015 at 10:36 PM, Stephen Frost <sfrost(at)snowman(dot)net> wrote:
> > Basically, in my view at least, these programs are likely to continue to
> > use these backwards compatibility views until we either formally
> > deprecate them or (more likely) until we actually remove them and things
> > break. As such, I'm not sure if this information really helps us make a
> > decision here.
>
> After poking at this a bit, I am guessing the reason they still use
> pg_user is that regular users don't have permission to access
> pg_authid directly. We don't want to make it impossible for pgAdmin
> to work for non-superusers.

I should have been more specific. I don't believe they've moved to
using pg_roles completely (which was created specifically to address the
issue that regular users can't select from pg_authid). Both of the
tools being discussed use pg_roles also (and, in fact, I believe they
have to for certain fields which pg_user doesn't include..
rolcreaterole being a pretty big one, but also rolconnlimit and
rolinherit, which wouldn't make sense in pg_user anyway..). I agree
that they can't simply move to pg_authid today since only superusers
have access to that table today. Of course, with column-level
privileges, we could potentially change that too..

In any case, looking at this again, it seems clear that we've not been
keeping pg_user up to date and no one seems to care. I don't think it
makes sense to go back and try to add "useconnlimit", "usecanlogin",
"usecreateuser" for 9.5 when pg_user was only ever intended for
backwards compatibility and clearly hasn't been getting the love and
attention it would deserve if it was really useful.

As such, I'm coming down on the side of simply removing pg_user,
pg_shadow, and pg_group for 9.5. Having a half-maintained mish-mash of
things from pg_authid making their way into pg_user/pg_shadow (which
suffers all the same problems of missing important fields) isn't doing
anyone any favors, and pg_group is an inefficient way of getting at the
information that's in pg_auth_members which implies that groups are
somehow different from roles, which hasn't been the case in 10 years.

Thanks!

Stephen


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Noah Misch <noah(at)leadboat(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-03-13 13:52:21
Message-ID: 20150313135221.GB29780@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Stephen Frost (sfrost(at)snowman(dot)net) wrote:
> I should have been more specific. I don't believe they've moved to
> using pg_roles completely (which was created specifically to address the
> issue that regular users can't select from pg_authid).

Err, forgot to finish that thought, sorry. Let's try again:

I should have been more specific. I don't believe they've moved to
using pg_roles completely (which was created specifically to address the
issue that regular users can't select from pg_authid) simply because
they haven't had reason to.

Thanks,

Stephen


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Noah Misch <noah(at)leadboat(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-03-16 15:52:55
Message-ID: CA+TgmoanWZqp0gNhZTmPRT5ceJdscG+-0a7nRZLjiCookJGjwQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Mar 13, 2015 at 9:52 AM, Stephen Frost <sfrost(at)snowman(dot)net> wrote:
> * Stephen Frost (sfrost(at)snowman(dot)net) wrote:
>> I should have been more specific. I don't believe they've moved to
>> using pg_roles completely (which was created specifically to address the
>> issue that regular users can't select from pg_authid).
>
> Err, forgot to finish that thought, sorry. Let's try again:
>
> I should have been more specific. I don't believe they've moved to
> using pg_roles completely (which was created specifically to address the
> issue that regular users can't select from pg_authid) simply because
> they haven't had reason to.

That's another way of saying "removing pg_user would be creating extra
work for tool authors that otherwise wouldn't need to be done".

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Noah Misch <noah(at)leadboat(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-03-16 15:56:50
Message-ID: 20150316155650.GP29780@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Robert Haas (robertmhaas(at)gmail(dot)com) wrote:
> On Fri, Mar 13, 2015 at 9:52 AM, Stephen Frost <sfrost(at)snowman(dot)net> wrote:
> > * Stephen Frost (sfrost(at)snowman(dot)net) wrote:
> >> I should have been more specific. I don't believe they've moved to
> >> using pg_roles completely (which was created specifically to address the
> >> issue that regular users can't select from pg_authid).
> >
> > Err, forgot to finish that thought, sorry. Let's try again:
> >
> > I should have been more specific. I don't believe they've moved to
> > using pg_roles completely (which was created specifically to address the
> > issue that regular users can't select from pg_authid) simply because
> > they haven't had reason to.
>
> That's another way of saying "removing pg_user would be creating extra
> work for tool authors that otherwise wouldn't need to be done".

Sure, if we never deprecate anything then tool authors would never need
to change their existing code. I don't think that's actually a viable
solution though; the reason we're discussing the removal of these
particular views is that they aren't really being maintained and, when
they are, they're making work for us. That's certainly a trade-off to
consider, of course, but in this case I'm coming down on the side of
dropping support and our own maintenance costs associated with these
views in favor of asking the tooling community to complete the migration
to the new views which have been around for the past 10 years.

Thanks!

Stephen


From: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Noah Misch <noah(at)leadboat(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CATUPDATE confusion?
Date: 2015-03-16 17:38:01
Message-ID: CAKRt6CR92MOx6EZQw0610W=FB8jXBEP7bd8zpagajA78x2xwRQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

All,

Sure, if we never deprecate anything then tool authors would never need
> to change their existing code. I don't think that's actually a viable
> solution though; the reason we're discussing the removal of these
> particular views is that they aren't really being maintained and, when
> they are, they're making work for us. That's certainly a trade-off to
> consider, of course, but in this case I'm coming down on the side of
> dropping support and our own maintenance costs associated with these
> views in favor of asking the tooling community to complete the migration
> to the new views which have been around for the past 10 years.
>

Perhaps this is naive or has been attempted in the past without success,
but would it be possible to maintain a list of deprecated features? I
noticed the following wiki page, (though it hasn't been updated recently)
that I think could be used for this purpose.

https://wiki.postgresql.org/wiki/Deprecated_Features

Using this page as a model, having an "official deprecation list" that does
the following might be very useful:

* Lists feature that is deprecated.
* Reason it was deprecated.
* What to use instead, perhaps with example.
* Version the feature will be removed.

Or perhaps such a list could be included as part of the official
documentation? In either case, if it is well known that such a list is
available/exists then tool developers, etc. should have adequate time,
opportunity and information to make the appropriate changes to their
products with a "minimal" impact.

Thoughts?

-Adam

--
Adam Brightwell - adam(dot)brightwell(at)crunchydatasolutions(dot)com
Database Engineer - www.crunchydatasolutions.com