Streaming replication as a separate permissions

Lists: pgsql-hackers
From: Magnus Hagander <magnus(at)hagander(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Streaming replication as a separate permissions
Date: 2010-12-23 09:53:10
Message-ID: AANLkTimAFRqsaRkE5-D-7X1fxaoa+YHPdjewdpPht3GY@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Here's a patch that changes walsender to require a special privilege
for replication instead of relying on superuser permissions. We
discussed this back before 9.0 was finalized, but IIRC we ran out of
time. The motivation being that you really want to use superuser as
little as possible - and since being a replication slave is a read
only role, it shouldn't require the maximum permission available in
the system.

Obviously the patch needs docs and some system views updates, which I
will add later. But I wanted to post what I have so far for a quick
review to confirm whether I'm on the right track or not... How it
works should be rather obvious - adds a "WITH
REPLICATION/NOREPLICATION" to the create and alter role commands, and
then check this when a connection attempts to start the walsender.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/

Attachment Content-Type Size
repl_role.patch text/x-patch 12.1 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-23 15:15:21
Message-ID: 23446.1293117321@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Magnus Hagander <magnus(at)hagander(dot)net> writes:
> Here's a patch that changes walsender to require a special privilege
> for replication instead of relying on superuser permissions. We
> discussed this back before 9.0 was finalized, but IIRC we ran out of
> time. The motivation being that you really want to use superuser as
> little as possible - and since being a replication slave is a read
> only role, it shouldn't require the maximum permission available in
> the system.

Maybe it needn't require "max" permissions, but one of the motivations
for requiring superusernesss was to prevent Joe User from sucking every
last byte of data out of your database (and into someplace he could
examine it at leisure). This patch opens that barn door wide, because
so far as I can see, it allows anybody at all to grant the replication
privilege ... or revoke it, thereby breaking your replication setup.
I think only superusers should be allowed to change the flag.

regards, tom lane


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-23 15:49:45
Message-ID: AANLkTik6tdTe+4_OVxWkeXRdZS73pL-AJH129AruzBr-@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Dec 23, 2010 at 10:15 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>> Here's a patch that changes walsender to require a special privilege
>> for replication instead of relying on superuser permissions. We
>> discussed this back before 9.0 was finalized, but IIRC we ran out of
>> time. The motivation being that you really want to use superuser as
>> little as possible - and since being a replication slave is a read
>> only role, it shouldn't require the maximum permission available in
>> the system.
>
> Maybe it needn't require "max" permissions, but one of the motivations
> for requiring superusernesss was to prevent Joe User from sucking every
> last byte of data out of your database (and into someplace he could
> examine it at leisure).  This patch opens that barn door wide, because
> so far as I can see, it allows anybody at all to grant the replication
> privilege ... or revoke it, thereby breaking your replication setup.
> I think only superusers should be allowed to change the flag.

I haven't looked at the patch yet, but I think we should continue to
allow superuser-ness to be *sufficient* for replication - i.e.
superusers will automatically have the replication privilege just as
they do any other - and merely allow this as an option for when you
want to avoid doing it that way.

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-23 15:54:41
Message-ID: 24024.1293119681@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> I haven't looked at the patch yet, but I think we should continue to
> allow superuser-ness to be *sufficient* for replication - i.e.
> superusers will automatically have the replication privilege just as
> they do any other - and merely allow this as an option for when you
> want to avoid doing it that way.

I don't particularly mind breaking that. If we leave it as-is, we'll
be encouraging people to use superuser accounts for things that don't
need that, which can't be good from a security standpoint.

BTW, is it possible to set things up so that a REPLICATION account
can be NOLOGIN, thereby making it really hard to abuse for other
purposes? Or does the login privilege check come too soon?

regards, tom lane


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-23 15:57:23
Message-ID: AANLkTi=1TOzZ=t10zn7ps8t8642LN_MnvkgjKj_pkgQf@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Dec 23, 2010 at 10:54 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> I haven't looked at the patch yet, but I think we should continue to
>> allow superuser-ness to be *sufficient* for replication - i.e.
>> superusers will automatically have the replication privilege just as
>> they do any other - and merely allow this as an option for when you
>> want to avoid doing it that way.
>
> I don't particularly mind breaking that.  If we leave it as-is, we'll
> be encouraging people to use superuser accounts for things that don't
> need that, which can't be good from a security standpoint.

And if we break it, we'll be adding an additional, mandatory step to
make replication work that isn't required today. You might think
that's OK, but I think the majority opinion is that it's already
excessively complex.

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


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-23 19:57:08
Message-ID: AANLkTimpcNKVBO-SKJEtiQbYAvk8XD2Z-Jetx_trPEaR@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Dec 23, 2010 at 16:15, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>> Here's a patch that changes walsender to require a special privilege
>> for replication instead of relying on superuser permissions. We
>> discussed this back before 9.0 was finalized, but IIRC we ran out of
>> time. The motivation being that you really want to use superuser as
>> little as possible - and since being a replication slave is a read
>> only role, it shouldn't require the maximum permission available in
>> the system.
>
> Maybe it needn't require "max" permissions, but one of the motivations
> for requiring superusernesss was to prevent Joe User from sucking every
> last byte of data out of your database (and into someplace he could
> examine it at leisure).  This patch opens that barn door wide, because
> so far as I can see, it allows anybody at all to grant the replication
> privilege ... or revoke it, thereby breaking your replication setup.
> I think only superusers should be allowed to change the flag.

That was certainly not intentional - and doesn't work that way for me
at least, unless I broke it right before I submitted it.

oh hang on.. Yeah, it's allowing anybody *that has CREATE ROLE*
privilege to do it, I think. And I agree that's wrong and should be
fixed. But I can't see it allowing anybody at all to do it - am I
misreading the code?

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-23 19:59:02
Message-ID: AANLkTikshdMDYLO80jO_qVFZ_2Mz0_WaR1AZy6v61SPC@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Dec 23, 2010 at 16:57, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Thu, Dec 23, 2010 at 10:54 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>>> I haven't looked at the patch yet, but I think we should continue to
>>> allow superuser-ness to be *sufficient* for replication - i.e.
>>> superusers will automatically have the replication privilege just as
>>> they do any other - and merely allow this as an option for when you
>>> want to avoid doing it that way.
>>
>> I don't particularly mind breaking that.  If we leave it as-is, we'll
>> be encouraging people to use superuser accounts for things that don't
>> need that, which can't be good from a security standpoint.
>
> And if we break it, we'll be adding an additional, mandatory step to
> make replication work that isn't required today.  You might think
> that's OK, but I think the majority opinion is that it's already
> excessively complex.

Most of the people I run across in the real world are rather surprised
how *easy* it is to set up, and not how complex. And tbh, the only
complexity complaints I've heard there are about the requirement to
start/backup/stop to get it up and running. I've always told everybody
to create a separate account to do it, and not heard a single comment
about that.

That said, how about a compromise in that we add the replication flag
by default to the initial superuser when it's created? That way, it's
at least possible to remove it if you want to. Would that address your
complexity concern?

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-23 20:31:01
Message-ID: 27452.1293136261@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Magnus Hagander <magnus(at)hagander(dot)net> writes:
> On Thu, Dec 23, 2010 at 16:15, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> I think only superusers should be allowed to change the flag.

> That was certainly not intentional - and doesn't work that way for me
> at least, unless I broke it right before I submitted it.

> oh hang on.. Yeah, it's allowing anybody *that has CREATE ROLE*
> privilege to do it, I think. And I agree that's wrong and should be
> fixed. But I can't see it allowing anybody at all to do it - am I
> misreading the code?

Ah, sorry, yeah there are probably CREATE ROLE privilege checks
somewhere upstream of here. I was expecting to see a privilege check
added by the patch itself, and did not, so I complained.

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-23 20:34:33
Message-ID: 27513.1293136473@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Magnus Hagander <magnus(at)hagander(dot)net> writes:
> On Thu, Dec 23, 2010 at 16:57, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> On Thu, Dec 23, 2010 at 10:54 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> I don't particularly mind breaking that. If we leave it as-is, we'll
>>> be encouraging people to use superuser accounts for things that don't
>>> need that, which can't be good from a security standpoint.

>> And if we break it, we'll be adding an additional, mandatory step to
>> make replication work that isn't required today. You might think
>> that's OK, but I think the majority opinion is that it's already
>> excessively complex.

> Most of the people I run across in the real world are rather surprised
> how *easy* it is to set up, and not how complex. And tbh, the only
> complexity complaints I've heard there are about the requirement to
> start/backup/stop to get it up and running. I've always told everybody
> to create a separate account to do it, and not heard a single comment
> about that.

FWIW, it seems unreasonable to me to expect that we will not be breaking
any part of a 9.0 replication configuration over the next release or
two. We *knew* we were shipping a rough version that would require
refinements, and this is one of the planned refinements.

> That said, how about a compromise in that we add the replication flag
> by default to the initial superuser when it's created? That way, it's
> at least possible to remove it if you want to. Would that address your
> complexity concern?

It does nothing to address my security concern. I want to discourage
people from using superuser accounts for this, full stop.

regards, tom lane


From: Stefan Kaltenbrunner <stefan(at)kaltenbrunner(dot)cc>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-23 20:35:15
Message-ID: 4D13B283.8060409@kaltenbrunner.cc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 12/23/2010 08:59 PM, Magnus Hagander wrote:
> On Thu, Dec 23, 2010 at 16:57, Robert Haas<robertmhaas(at)gmail(dot)com> wrote:
>> On Thu, Dec 23, 2010 at 10:54 AM, Tom Lane<tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> Robert Haas<robertmhaas(at)gmail(dot)com> writes:
>>>> I haven't looked at the patch yet, but I think we should continue to
>>>> allow superuser-ness to be *sufficient* for replication - i.e.
>>>> superusers will automatically have the replication privilege just as
>>>> they do any other - and merely allow this as an option for when you
>>>> want to avoid doing it that way.
>>>
>>> I don't particularly mind breaking that. If we leave it as-is, we'll
>>> be encouraging people to use superuser accounts for things that don't
>>> need that, which can't be good from a security standpoint.
>>
>> And if we break it, we'll be adding an additional, mandatory step to
>> make replication work that isn't required today. You might think
>> that's OK, but I think the majority opinion is that it's already
>> excessively complex.
>
> Most of the people I run across in the real world are rather surprised
> how *easy* it is to set up, and not how complex. And tbh, the only
> complexity complaints I've heard there are about the requirement to
> start/backup/stop to get it up and running. I've always told everybody
> to create a separate account to do it, and not heard a single comment
> about that.

I agree - people I talked to are fairly surprised on us not using a
dedicated replication role but are surprised at the complexity of
actually initializing the replication (mostly the "we cannot do a base
backup over the replication connection" missfeature)

Stefan


From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-23 22:11:08
Message-ID: 4D13C8FC.4030500@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 12/23/10 7:49 AM, Robert Haas wrote:
> I haven't looked at the patch yet, but I think we should continue to
> allow superuser-ness to be *sufficient* for replication - i.e.
> superusers will automatically have the replication privilege just as
> they do any other - and merely allow this as an option for when you
> want to avoid doing it that way.

Yes. Currently I already create a separate "replicator" superuser just
so that I can simply track which connections belong to replication. It
would be great if it could make the "replicator" user less than a superuser.

If we still make it possible for "postgres" to replicate, then we don't
add any complexity to the simplest setup.

--
-- Josh Berkus
PostgreSQL Experts Inc.
http://www.pgexperts.com


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-23 22:21:53
Message-ID: 28898.1293142913@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Josh Berkus <josh(at)agliodbs(dot)com> writes:
> If we still make it possible for "postgres" to replicate, then we don't
> add any complexity to the simplest setup.

Well, that's one laudable goal here, but "secure by default" is another
one that ought to be taken into consideration.

regards, tom lane


From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-23 22:24:33
Message-ID: 4D13CC21.5030206@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 12/23/10 2:21 PM, Tom Lane wrote:
> Josh Berkus <josh(at)agliodbs(dot)com> writes:
>> If we still make it possible for "postgres" to replicate, then we don't
>> add any complexity to the simplest setup.
>
> Well, that's one laudable goal here, but "secure by default" is another
> one that ought to be taken into consideration.

I don't see how *not* granting the superuser replication permissions
makes things more secure. The superuser can grant replication
permissions to itself, so why is suspending them by default beneficial?
I'm not following your logic here.

--
-- Josh Berkus
PostgreSQL Experts Inc.
http://www.pgexperts.com


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-23 22:29:13
Message-ID: 29021.1293143353@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Josh Berkus <josh(at)agliodbs(dot)com> writes:
> On 12/23/10 2:21 PM, Tom Lane wrote:
>> Well, that's one laudable goal here, but "secure by default" is another
>> one that ought to be taken into consideration.

> I don't see how *not* granting the superuser replication permissions
> makes things more secure. The superuser can grant replication
> permissions to itself, so why is suspending them by default beneficial?
> I'm not following your logic here.

Well, the reverse of that is just as true: if we ship it without
replication permissions on the postgres user, people can change that if
they'd rather not create a separate role for replication. But I think
we should encourage people to NOT do it that way. Setting it up that
way by default hardly encourages use of a more secure arrangement.

regards, tom lane


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-23 22:33:42
Message-ID: 20101223223342.GA4933@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Josh Berkus (josh(at)agliodbs(dot)com) wrote:
> On 12/23/10 2:21 PM, Tom Lane wrote:
> > Well, that's one laudable goal here, but "secure by default" is another
> > one that ought to be taken into consideration.
>
> I don't see how *not* granting the superuser replication permissions
> makes things more secure. The superuser can grant replication
> permissions to itself, so why is suspending them by default beneficial?
> I'm not following your logic here.

The point is that the *replication* role can't grant itself superuser
privs. Having the replication role compromised isn't great, but if that
role is *also* a superuser, then the whole database server could be
compromised. Encouraging users to continue to configure remote systems
with the ability to connect as a superuser when it's not necessary is a
bad idea.

One compromise would be to:

a) let superusers be granted the replication permission
b) have pg_dump assume that superusers have that permission when dumping
from a version which pre-dates the replication grant
c) have pg_upgrade assume the superuser has that permission when
upgrading
d) *not* grant replication to the default superuser

A better alternative, imv, would be to just have a & d, and mention in
the release notes that users *should* create a dedicated replication
role which is *not* a superuser but *does* have the replication grant,
but if they don't want to change their existing configurations, they can
just grant the replication privilege to whatever role they're currently
using.

Thanks,

Stephen


From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-23 22:38:11
Message-ID: 4D13CF53.7030107@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 12/23/10 2:33 PM, Stephen Frost wrote:
> A better alternative, imv, would be to just have a & d, and mention in
> the release notes that users *should* create a dedicated replication
> role which is *not* a superuser but *does* have the replication grant,
> but if they don't want to change their existing configurations, they can
> just grant the replication privilege to whatever role they're currently
> using.

Well, if we really want people to change their behavior then we need to
make it easy for them:

1) have a replication permission
2) *by default* create a replication user with the replication
permission when we initdb.
3) have an example line for a replication connection by the replication
user in the default pg_hba.conf (commented out).
4) change all our docs and examples to use that replication user.

If using the replication user is easier than any other path, people
will. If it's harder, they won't.

--
-- Josh Berkus
PostgreSQL Experts Inc.
http://www.pgexperts.com


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-23 22:44:02
Message-ID: 29263.1293144242@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Josh Berkus <josh(at)agliodbs(dot)com> writes:
> On 12/23/10 2:33 PM, Stephen Frost wrote:
>> A better alternative, imv, would be to just have a & d, and mention in
>> the release notes that users *should* create a dedicated replication
>> role which is *not* a superuser but *does* have the replication grant,
>> but if they don't want to change their existing configurations, they can
>> just grant the replication privilege to whatever role they're currently
>> using.

> Well, if we really want people to change their behavior then we need to
> make it easy for them:

> 1) have a replication permission
> 2) *by default* create a replication user with the replication
> permission when we initdb.

Yeah, I could see doing that ... the entry would be wasted if you're not
doing any replication, but one wasted catalog entry isn't much.

However, it'd be a real good idea for that role to be NOLOGIN if it's
there by default.

regards, tom lane


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-23 22:45:19
Message-ID: 20101223224519.GB4933@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Josh Berkus (josh(at)agliodbs(dot)com) wrote:
> 1) have a replication permission

Right, that's what this patch is about.

> 2) *by default* create a replication user with the replication
> permission when we initdb.

I'm not entirely sure about this one.. I'm not against it but I'm also
not really 'for' it. :)

> 3) have an example line for a replication connection by the replication
> user in the default pg_hba.conf (commented out).

Sure.

> 4) change all our docs and examples to use that replication user.

I don't have a problem with that.

Thanks,

Stephen


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-23 22:49:14
Message-ID: 20101223224914.GC4933@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:
> However, it'd be a real good idea for that role to be NOLOGIN if it's
> there by default.

Definitely. I'd also suggest we WARN if someone creates a situation
where a role has both replication and login, and maybe prevent it
altogether, it's just a bad idea..

Thanks,

Stephen


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-23 22:57:25
Message-ID: AANLkTimYOxwY3iPz9hx4x2bV1t=zt+HDD4h3bvvEoUR0@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Dec 23, 2010 at 23:44, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Josh Berkus <josh(at)agliodbs(dot)com> writes:
>> On 12/23/10 2:33 PM, Stephen Frost wrote:
>>> A better alternative, imv, would be to just have a & d, and mention in
>>> the release notes that users *should* create a dedicated replication
>>> role which is *not* a superuser but *does* have the replication grant,
>>> but if they don't want to change their existing configurations, they can
>>> just grant the replication privilege to whatever role they're currently
>>> using.
>
>> Well, if we really want people to change their behavior then we need to
>> make it easy for them:
>
>> 1) have a replication permission
>> 2) *by default* create a replication user with the replication
>> permission when we initdb.
>
> Yeah, I could see doing that ... the entry would be wasted if you're not
> doing any replication, but one wasted catalog entry isn't much.
>
> However, it'd be a real good idea for that role to be NOLOGIN if it's
> there by default.

That shouldn't be too hard - I'll look at making the patch do that to
make sure it *isn't* that hard ;)

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Josh Berkus <josh(at)agliodbs(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-23 22:59:28
Message-ID: 4D13D450.3050206@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


> I'm not entirely sure about this one.. I'm not against it but I'm also
> not really 'for' it. :)

2 reasons: (a) if users need to CREATE USER, that *does* add an extra
step and they're more likely to just choose to grant to postgres
instead, (b) having a standard installed user (just like the user
"postgres" is standard) would make our docs, examples and tutorials much
easier to use.

--
-- Josh Berkus
PostgreSQL Experts Inc.
http://www.pgexperts.com


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-24 00:08:38
Message-ID: AANLkTik9192zA6fz4X=q8sMZGCz8P2XTz5KJJ-Yow5hk@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Dec 23, 2010 at 5:59 PM, Josh Berkus <josh(at)agliodbs(dot)com> wrote:
>
>> I'm not entirely sure about this one..  I'm not against it but I'm also
>> not really 'for' it. :)
>
> 2 reasons: (a) if users need to CREATE USER, that *does* add an extra
> step and they're more likely to just choose to grant to postgres
> instead, (b) having a standard installed user (just like the user
> "postgres" is standard) would make our docs, examples and tutorials much
> easier to use.

If the user exists but is disabled by default, I'm not sure that
really provides any advantage over not having it at all. And it
certainly can't be enabled by default.

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


From: Josh Berkus <josh(at)agliodbs(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-24 00:11:31
Message-ID: 4D13E533.9050808@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


> If the user exists but is disabled by default, I'm not sure that
> really provides any advantage over not having it at all. And it
> certainly can't be enabled by default.

I was presuming that NOLOGIN wouldn't prevent a replication connections
via the replication user. So the user would be "enabled" as far as
replication was concerned.

And currently, there is no replication connection in the pg_hba.conf.
So that's not a change; in fact, having a sample one would be an
improvement.

--
-- Josh Berkus
PostgreSQL Experts Inc.
http://www.pgexperts.com


From: Florian Pflug <fgp(at)phlo(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-24 02:37:30
Message-ID: 989E7376-8A83-4B09-9DD4-23DB84B980D8@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Dec23, 2010, at 16:54 , Tom Lane wrote:
> BTW, is it possible to set things up so that a REPLICATION account
> can be NOLOGIN, thereby making it really hard to abuse for other
> purposes? Or does the login privilege check come too soon?

Please don't. This violates the principle of least surprise big time!
And, whats worse, violate it in such a way that people *underestimate*
the permissions a particular role has, which from a security POV is
the worst than can happen. You pointed out yourself that REPLICATION
is a powerful permission to have because it essentially grants you read
access to the whole cluster. By allowing roles to connect a WAL receivers
even if they have NOLOGIN set, you're giving these powerful permission
to a role a DBA might think is disabled!

Now, I *can* see that having roles which may only connect as WAL receivers,
not to issue queries, is worthwhile. However, please either

A) Invert a new flag for that, for example SQL/NOSQL. A pure replication
role would have WITH REPLICATION NOSQL, while most other would have
WITH NOREPLICATION SQL. It's debatable wether postgres should have
WITH REPLICATION SQL or WITH NOREPLICATION SQL by default.

B) Forbid REPLICATION roles from connecting as anything else than WAL
receivers altogether. It'd then probably be a good idea to prevent
such roles from having SUPERUSER, CREATEDB, CREATEROLE and INHERIT
set as these flag wouldn't then make any sense.

The only downside of (B) that I can see is that it'd break setups that
work with 9.0.

best regards,
Florian Pflug


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Florian Pflug <fgp(at)phlo(dot)org>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-24 03:16:18
Message-ID: 2893.1293160578@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Florian Pflug <fgp(at)phlo(dot)org> writes:
> On Dec23, 2010, at 16:54 , Tom Lane wrote:
>> BTW, is it possible to set things up so that a REPLICATION account
>> can be NOLOGIN, thereby making it really hard to abuse for other
>> purposes? Or does the login privilege check come too soon?

> Please don't. This violates the principle of least surprise big time!

How so? (Please note I said *can be*, not *has to be*.)

The point of this is to ensure that if someone does illicitly come by
the replication role's password, they can't use it to log in. They can
still steal all your data, but they can't actually get into the
database. I don't see why it's a bad idea to configure things that way.

regards, tom lane


From: Florian Pflug <fgp(at)phlo(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-24 03:36:51
Message-ID: 8056BC58-2695-4D21-A96C-41FF54AD7BD7@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Dec24, 2010, at 04:16 , Tom Lane wrote:
> Florian Pflug <fgp(at)phlo(dot)org> writes:
>> On Dec23, 2010, at 16:54 , Tom Lane wrote:
>>> BTW, is it possible to set things up so that a REPLICATION account
>>> can be NOLOGIN, thereby making it really hard to abuse for other
>>> purposes? Or does the login privilege check come too soon?
>
>> Please don't. This violates the principle of least surprise big time!
>
> How so? (Please note I said *can be*, not *has to be*.)

Because a DBA might "ALTER ROLE replication WITH NOLOGIN", thinking he has
just disabled that role. Only to find out weeks later than he hasn't
and that someone has been using that role to stream weeks worth of
confidential data to who knows where.

The problem here is that you suggest NOLOGIN should mean "Not allowed
to issue SQL commands", which really isn't what the name "NOLOGIN"
conveys. The concept itself is perfectly fine, but the name is dangerously
confusing.

> The point of this is to ensure that if someone does illicitly come by
> the replication role's password, they can't use it to log in. They can
> still steal all your data, but they can't actually get into the
> database. I don't see why it's a bad idea to configure things that way.

It's perfectly fine to configure things that way, and is in fact what I would
do. I'd just prefer the name for that setting to convey it's actual meaning
which is why I suggested adding a SQL/NOSQL flag. (Or SESSION/NOSESSION,
or whatever). Or, much simpler, to prevent WITH REPLICATION roles from issuing
SQL commands altogether. That'd achieve your goal just as well and is way less
confusing.

best regards,
Florian Pflug


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Florian Pflug <fgp(at)phlo(dot)org>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-24 04:00:14
Message-ID: 3475.1293163214@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Florian Pflug <fgp(at)phlo(dot)org> writes:
> The problem here is that you suggest NOLOGIN should mean "Not allowed
> to issue SQL commands", which really isn't what the name "NOLOGIN"
> conveys.

No, it means "not allowed to connect". It's possible now to issue
commands as a NOLOGIN user, you just have to use SET ROLE to become the
user. I think you're arguing about a design choice that was already
made some time ago.

regards, tom lane


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Florian Pflug <fgp(at)phlo(dot)org>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-24 04:31:38
Message-ID: AANLkTimOBBxhJds37d4MHPy8r_zfeHa9mTt81ToiWc-r@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Dec 23, 2010 at 11:00 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Florian Pflug <fgp(at)phlo(dot)org> writes:
>> The problem here is that you suggest NOLOGIN should mean "Not allowed
>> to issue SQL commands", which really isn't what the name "NOLOGIN"
>> conveys.
>
> No, it means "not allowed to connect".  It's possible now to issue
> commands as a NOLOGIN user, you just have to use SET ROLE to become the
> user.  I think you're arguing about a design choice that was already
> made some time ago.

I think I agree with Florian about the confusing-ness of the proposed
semantics. Aren't you saying you want NOLOGIN mean "not allowed to
log in for the purposes of issuing SQL commands, but allowed to log in
for replication"? Uggh.

--
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: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Florian Pflug <fgp(at)phlo(dot)org>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-24 04:46:30
Message-ID: 20101224044630.GD4933@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Robert Haas (robertmhaas(at)gmail(dot)com) wrote:
> I think I agree with Florian about the confusing-ness of the proposed
> semantics. Aren't you saying you want NOLOGIN mean "not allowed to
> log in for the purposes of issuing SQL commands, but allowed to log in
> for replication"? Uggh.

I like the general idea of a replication-only "role" or "login". Maybe
implementing that as a role w/ all the things that come along with it
being a role isn't right, but we don't want to have to reinvent all the
supported auth mechanisms (and please don't propose limiting the auth
options for the replication login!). Is there a way we can leverage the
auth mechanisms, etc, while forcing the 'replication role' to only be
able to do what a 'replication role' should do?

Thanks,

Stephen


From: Florian Pflug <fgp(at)phlo(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-24 11:34:52
Message-ID: 4E1FCF6E-AF66-485C-8EC4-0F28C3AB12F9@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Dec24, 2010, at 05:00 , Tom Lane wrote:
> Florian Pflug <fgp(at)phlo(dot)org> writes:
>> The problem here is that you suggest NOLOGIN should mean "Not allowed
>> to issue SQL commands", which really isn't what the name "NOLOGIN"
>> conveys.
>
> No, it means "not allowed to connect".

Exactly. Which proves my point, unless you're ready to argue that
replication connections somehow don't count as "connections".

> It's possible now to issue
> commands as a NOLOGIN user, you just have to use SET ROLE to become the
> user. I think you're arguing about a design choice that was already
> made some time ago.

You've lost me, how is that an argument in your favour? I *wasn't* arguing
that NOLOGIN ought to mean "No allowed to issue SQL commands". It was what
*your* proposal of letting a role connect for replication purposes despite
a NOLOGIN flag would *make* NOLOGIN mean.

best regards,
Florian Pflug


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-27 08:32:21
Message-ID: 1293438742.1193.61839.camel@ebony
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, 2010-12-23 at 10:53 +0100, Magnus Hagander wrote:

> Here's a patch that changes walsender to require a special privilege
> for replication instead of relying on superuser permissions. We
> discussed this back before 9.0 was finalized, but IIRC we ran out of
> time. The motivation being that you really want to use superuser as
> little as possible - and since being a replication slave is a read
> only role, it shouldn't require the maximum permission available in
> the system.

Is backup part of this new privilege, or not?

I think if we're going to introduce a new level of privilege, then we
should introduce all delegatable privs in one software release. Much
better than having someone think up a new delegatable priv each release
for next 5 years.

Other possible ones include unsafe PL creation, seeing logged SQL etc..

--
Simon Riggs http://www.2ndQuadrant.com/books/
PostgreSQL Development, 24x7 Support, Training and Services


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-27 09:36:28
Message-ID: AANLkTi=wZ9AKgVj9xQ-=BUKkNrffdukv54QS0kE8awpR@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Dec 27, 2010 at 09:32, Simon Riggs <simon(at)2ndquadrant(dot)com> wrote:
> On Thu, 2010-12-23 at 10:53 +0100, Magnus Hagander wrote:
>
>> Here's a patch that changes walsender to require a special privilege
>> for replication instead of relying on superuser permissions. We
>> discussed this back before 9.0 was finalized, but IIRC we ran out of
>> time. The motivation being that you really want to use superuser as
>> little as possible - and since being a replication slave is a read
>> only role, it shouldn't require the maximum permission available in
>> the system.
>
> Is backup part of this new privilege, or not?

The "integrated base backup", once we have that, that's based on the
walsender protocol? yes.
pg_dump style backups? No.

> I think if we're going to introduce a new level of privilege, then we
> should introduce all delegatable privs in one software release. Much
> better than having someone think up a new delegatable priv each release
> for next 5 years.
>
> Other possible ones include unsafe PL creation, seeing logged SQL etc..

That's certainly an option, but that means someone would have to come
up with a list ;) And one that's reasonable - for example, "unsafe pl
creation" is from a security perspective (which is the only thing
that's really intersting here) the same as superuser.

Seeing logged SQL isn't - but being able to filter the logfiles on
that requires a *lot* more than just defining a security privilege. If
we mean "arbitrary log file reading", the easiest way to fix that
would be to stop checking for superuser permissions in the
read-file-function, and instead use the permissions *on the function*
to control it. In fact, that is something that we could (should?) do
for a bunch of other functions as well, so that we can in that way
provide much more granular permissions level than just blanked
assigning of privileges.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Dave Page <dpage(at)pgadmin(dot)org>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-27 09:52:57
Message-ID: AANLkTimUPXWfwgB0NZ_nmFmUSfSTrvWQVKXeK-kaZBVo@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Dec 27, 2010 at 9:36 AM, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
> Seeing logged SQL isn't - but being able to filter the logfiles on
> that requires a *lot* more than just defining a security privilege. If
> we mean "arbitrary log file reading", the easiest way to fix that
> would be to stop checking for superuser permissions in the
> read-file-function, and instead use the permissions *on the function*
> to control it. In fact, that is something that we could (should?) do
> for a bunch of other functions as well, so that we can in that way
> provide much more granular permissions level than just blanked
> assigning of privileges.

That would require having users change the permissions on system
objects, which seems, icky (would they even be dumped?). Given that
the superuser could already create a security definer wrapper function
with the privileges required, I don't think this is needed.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-27 09:53:22
Message-ID: AANLkTimj0b--wyMX4x6UhRTOc39mOZEXZgbFdiF+1nNa@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Dec 24, 2010 at 05:46, Stephen Frost <sfrost(at)snowman(dot)net> wrote:
> * Robert Haas (robertmhaas(at)gmail(dot)com) wrote:
>> I think I agree with Florian about the confusing-ness of the proposed
>> semantics.  Aren't you saying you want NOLOGIN mean "not allowed to
>> log in for the purposes of issuing SQL commands, but allowed to log in
>> for replication"?  Uggh.
>
> I like the general idea of a replication-only "role" or "login".  Maybe
> implementing that as a role w/ all the things that come along with it
> being a role isn't right, but we don't want to have to reinvent all the
> supported auth mechanisms (and please don't propose limiting the auth
> options for the replication login!).  Is there a way we can leverage the
> auth mechanisms, etc, while forcing the 'replication role' to only be
> able to do what a 'replication role' should do?

We could quite easily make a replication role *never* be able to
connect to a non-walsender backend. That would mean that if you set
your role to WITH REPLICATION, it can *only* be used for replication
and nothing else (well, you could still SET ROLE to it, but given that
it's not a superuser (anymore), that doesn't have any security
implications. Though we could perhaps restrict that as well in the SET
ROLE processing code).

This requires there to be a separate user for replication in all cases
- which isn't a bad thing IMHO. And it also doesn't "abuse"/confuse
the NOLOGIN attribute.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-27 10:34:55
Message-ID: 1293446095.1193.62470.camel@ebony
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, 2010-12-27 at 10:36 +0100, Magnus Hagander wrote:
> > Is backup part of this new privilege, or not?
>
> The "integrated base backup", once we have that, that's based on the
> walsender protocol? yes.
> pg_dump style backups? No.

Where does pg_start_backup()/stop fit?

--
Simon Riggs http://www.2ndQuadrant.com/books/
PostgreSQL Development, 24x7 Support, Training and Services


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-27 11:00:30
Message-ID: AANLkTinNt49iYab3-gVRfZV_AnTuSPp=kV5orcwTTHhh@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Dec 27, 2010 at 11:34, Simon Riggs <simon(at)2ndquadrant(dot)com> wrote:
> On Mon, 2010-12-27 at 10:36 +0100, Magnus Hagander wrote:
>> > Is backup part of this new privilege, or not?
>>
>> The "integrated base backup", once we have that, that's based on the
>> walsender protocol? yes.
>> pg_dump style backups? No.
>
> Where does pg_start_backup()/stop fit?

Good question :)

Given that the integrated-base-backup would call it for you, that one
would definitely get it automatically.

Given that the latest discissions seem to have most people wanting the
replication role *not* to be allowed to log in and run general SQL, we
should not drive the start/stop backup permissions from that
privilege.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-27 11:15:11
Message-ID: AANLkTin=m0BuEek1J0jyRZA4vvFFV53EppMN2W3fx3C2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Dec 27, 2010 at 10:53, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
> On Fri, Dec 24, 2010 at 05:46, Stephen Frost <sfrost(at)snowman(dot)net> wrote:
>> * Robert Haas (robertmhaas(at)gmail(dot)com) wrote:
>>> I think I agree with Florian about the confusing-ness of the proposed
>>> semantics.  Aren't you saying you want NOLOGIN mean "not allowed to
>>> log in for the purposes of issuing SQL commands, but allowed to log in
>>> for replication"?  Uggh.
>>
>> I like the general idea of a replication-only "role" or "login".  Maybe
>> implementing that as a role w/ all the things that come along with it
>> being a role isn't right, but we don't want to have to reinvent all the
>> supported auth mechanisms (and please don't propose limiting the auth
>> options for the replication login!).  Is there a way we can leverage the
>> auth mechanisms, etc, while forcing the 'replication role' to only be
>> able to do what a 'replication role' should do?
>
> We could quite easily make a replication role *never* be able to
> connect to a non-walsender backend. That would mean that if you set
> your role to WITH REPLICATION, it can *only* be used for replication
> and nothing else (well, you could still SET ROLE to it, but given that
> it's not a superuser (anymore), that doesn't have any security
> implications. Though we could perhaps restrict that as well in the SET
> ROLE processing code).
>
> This requires there to be a separate user for replication in all cases
> - which isn't a bad thing IMHO. And it also doesn't "abuse"/confuse
> the NOLOGIN attribute.

Actually, having implemented that and tested it, I realize that's a
pretty bad idea. For one thing, it broke my own pg_streamrecv program,
since it requires the ability to connect to the master and select a
pg_current_xlog_location().

We could allow NOLOGIN connections to do replication, but I agree with
those saying that's pretty confusing - to the point of making it very
easy for a DBA to think he's secure when he's not. And having the
*ability* to use the same role as replication and superuser isn't a
bad thing - it's either *requiring* it or *having it so by default*
that's the problem, IMHO.

I think it's Ok to ship with replication off and require people to
either create a replication role or assign the permissions to their
superuser - as long as this is well documented in the manual.

The compromise I think would be to ship with a replication role
installed and *enabled*. There's no win at all in shipping with a
disabled replication role - it would still require the "extra step"
that people want to avoid.

What I'd rather do is make the "all" keyword for databases in
pg_hba.conf actually include replication connections - now that we
have a separate permissions - thus removing the need to configure a
specific row in pg_hba.conf for those users who just put a "0.0.0.0/0
md5" row in there to dumb it down. That still let's those who care
about higher security lock it down if they want to, while still
removing a step for those users who don't care.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Florian Pflug <fgp(at)phlo(dot)org>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-27 11:42:19
Message-ID: F69E649F-3D10-4FEE-B5CF-353489234E93@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Dec27, 2010, at 12:15 , Magnus Hagander wrote:
> Actually, having implemented that and tested it, I realize that's a
> pretty bad idea. For one thing, it broke my own pg_streamrecv program,
> since it requires the ability to connect to the master and select a
> pg_current_xlog_location().

I'm starting to think what we really want here is a kind of read-only
superuser. WITH REPLICATION already essentially gives you read-only
access to the whole database. Thus, allowing WITH REPLICATION roles
read-only access to everything on the SQL level also doesn't really
extend their abilities, it merely makes getting some information faster
and more convenient. It'd also make WITH REPLICATION the perfect fit
for pg_dump-style backups, if you're uneasy about using a superuser
for that.

best regards,
Florian Pflug


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-27 13:25:29
Message-ID: 1293456329.1193.63371.camel@ebony
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, 2010-12-27 at 12:00 +0100, Magnus Hagander wrote:
> On Mon, Dec 27, 2010 at 11:34, Simon Riggs <simon(at)2ndquadrant(dot)com> wrote:
> > On Mon, 2010-12-27 at 10:36 +0100, Magnus Hagander wrote:
> >> > Is backup part of this new privilege, or not?
> >>
> >> The "integrated base backup", once we have that, that's based on the
> >> walsender protocol? yes.
> >> pg_dump style backups? No.
> >
> > Where does pg_start_backup()/stop fit?
>
> Good question :)
>
> Given that the integrated-base-backup would call it for you, that one
> would definitely get it automatically.
>
> Given that the latest discissions seem to have most people wanting the
> replication role *not* to be allowed to log in and run general SQL, we
> should not drive the start/stop backup permissions from that
> privilege.

So what your suggesting would actually defeat the purpose of having the
new privilege. Unless we trust in a new, untried method. Hmmm.

--
Simon Riggs http://www.2ndQuadrant.com/books/
PostgreSQL Development, 24x7 Support, Training and Services


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-27 13:41:27
Message-ID: AANLkTikeBeVkg-BHhX-bhU3mGD0MBGHhX8qNBeZb43ms@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Dec 27, 2010 at 14:25, Simon Riggs <simon(at)2ndquadrant(dot)com> wrote:
> On Mon, 2010-12-27 at 12:00 +0100, Magnus Hagander wrote:
>> On Mon, Dec 27, 2010 at 11:34, Simon Riggs <simon(at)2ndquadrant(dot)com> wrote:
>> > On Mon, 2010-12-27 at 10:36 +0100, Magnus Hagander wrote:
>> >> > Is backup part of this new privilege, or not?
>> >>
>> >> The "integrated base backup", once we have that, that's based on the
>> >> walsender protocol? yes.
>> >> pg_dump style backups? No.
>> >
>> > Where does pg_start_backup()/stop fit?
>>
>> Good question :)
>>
>> Given that the integrated-base-backup would call it for you, that one
>> would definitely get it automatically.
>>
>> Given that the latest discissions seem to have most people wanting the
>> replication role *not* to be allowed to log in and run general SQL, we
>> should not drive the start/stop backup permissions from that
>> privilege.
>
> So what your suggesting would actually defeat the purpose of having the
> new privilege. Unless we trust in a new, untried method. Hmmm.

No, it doesn't.

In my experience, most DBAs will connect with their DBA account
(usually the superuser, yes..) to run pg_start_backup() and
pg_stop_backup(). That's no reason to let the slave sever run with
superuser privileges all the time...

That said, I agree that the we shouldn't *prevent* the DBA from
setting up an account that is both superuser and replicator - just
that we shouldn't do it by default.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-27 13:51:50
Message-ID: 1293457910.1193.63509.camel@ebony
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, 2010-12-27 at 14:41 +0100, Magnus Hagander wrote:
> >> >
> >> > Where does pg_start_backup()/stop fit?
> >>
> >> Good question :)
> >>
> >> Given that the integrated-base-backup would call it for you, that one
> >> would definitely get it automatically.
> >>
> >> Given that the latest discissions seem to have most people wanting the
> >> replication role *not* to be allowed to log in and run general SQL, we
> >> should not drive the start/stop backup permissions from that
> >> privilege.
> >
> > So what your suggesting would actually defeat the purpose of having the
> > new privilege. Unless we trust in a new, untried method. Hmmm.
>
> No, it doesn't.
>
> In my experience, most DBAs will connect with their DBA account
> (usually the superuser, yes..) to run pg_start_backup() and
> pg_stop_backup(). That's no reason to let the slave sever run with
> superuser privileges all the time...

Remember the standby's superuser id is exactly the same as the main
server's superuserid. So unless you are going to stop the standby from
knowing its own superusers there's no huge benefit there. Is that what
you mean to do?

> That said, I agree that the we shouldn't *prevent* the DBA from
> setting up an account that is both superuser and replicator - just
> that we shouldn't do it by default.

--
Simon Riggs http://www.2ndQuadrant.com/books/
PostgreSQL Development, 24x7 Support, Training and Services


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-27 13:54:07
Message-ID: AANLkTikcnMh_tYgByUrdo4RrNHbqNWZG0K58WG8cfJmJ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Dec 27, 2010 at 14:51, Simon Riggs <simon(at)2ndquadrant(dot)com> wrote:
> On Mon, 2010-12-27 at 14:41 +0100, Magnus Hagander wrote:
>> >> >
>> >> > Where does pg_start_backup()/stop fit?
>> >>
>> >> Good question :)
>> >>
>> >> Given that the integrated-base-backup would call it for you, that one
>> >> would definitely get it automatically.
>> >>
>> >> Given that the latest discissions seem to have most people wanting the
>> >> replication role *not* to be allowed to log in and run general SQL, we
>> >> should not drive the start/stop backup permissions from that
>> >> privilege.
>> >
>> > So what your suggesting would actually defeat the purpose of having the
>> > new privilege. Unless we trust in a new, untried method. Hmmm.
>>
>> No, it doesn't.
>>
>> In my experience, most DBAs will connect with their DBA account
>> (usually the superuser, yes..) to run pg_start_backup() and
>> pg_stop_backup(). That's no reason to let the slave sever run with
>> superuser privileges all the time...
>
> Remember the standby's superuser id is exactly the same as the main
> server's superuserid. So unless you are going to stop the standby from
> knowing its own superusers there's no huge benefit there. Is that what
> you mean to do?

I'm sorry, I have no idea what you mean by that.

You will certainly be able to log into the standby with a superuser
account, nobody is preventing that. This is about protecting the
*master*. For example, from modifications made by a user who hacked
the standby.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-27 15:33:53
Message-ID: 14807.1293464033@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Magnus Hagander <magnus(at)hagander(dot)net> writes:
> On Mon, Dec 27, 2010 at 10:53, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
>> We could quite easily make a replication role *never* be able to
>> connect to a non-walsender backend. That would mean that if you set
>> your role to WITH REPLICATION, it can *only* be used for replication
>> and nothing else (well, you could still SET ROLE to it, but given that
>> it's not a superuser (anymore), that doesn't have any security
>> implications.

> Actually, having implemented that and tested it, I realize that's a
> pretty bad idea.

OK, so if we're not going to recommend that REPLICATION roles be
NOLOGIN, we're back to the original question: should the REPLICATION
bit give any other special privileges? I can see the point of allowing
such a user to issue pg_start_backup and pg_stop_backup.

regards, tom lane


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-27 15:40:10
Message-ID: AANLkTimekDJ=68OHBTrGjs8iYXO4gMsmus9ZEAzx3YAE@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Dec 27, 2010 at 16:33, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>> On Mon, Dec 27, 2010 at 10:53, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
>>> We could quite easily make a replication role *never* be able to
>>> connect to a non-walsender backend. That would mean that if you set
>>> your role to WITH REPLICATION, it can *only* be used for replication
>>> and nothing else (well, you could still SET ROLE to it, but given that
>>> it's not a superuser (anymore), that doesn't have any security
>>> implications.
>
>> Actually, having implemented that and tested it, I realize that's a
>> pretty bad idea.
>
> OK, so if we're not going to recommend that REPLICATION roles be
> NOLOGIN, we're back to the original question: should the REPLICATION
> bit give any other special privileges?  I can see the point of allowing
> such a user to issue pg_start_backup and pg_stop_backup.

Yes, those would definitely be useful.

We are, basically, talking about where we'll relax the "only
superuser" one, right? Since they are normal roles, the DBA can always
GRANT permissions on *objects* to them, but there are superuser-only
things taht you can't GRANT away...

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-27 15:45:39
Message-ID: 1293464739.1193.64083.camel@ebony
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, 2010-12-27 at 14:54 +0100, Magnus Hagander wrote:

> You will certainly be able to log into the standby with a superuser
> account, nobody is preventing that. This is about protecting the
> *master*. For example, from modifications made by a user who hacked
> the standby.

The users for master and standby are identical, so if they have access
to the standby, they have access to the master. That's why we allow
replication to be specifically excluded by the pg_hba.conf.

So I don't see how this helps.

--
Simon Riggs http://www.2ndQuadrant.com/books/
PostgreSQL Development, 24x7 Support, Training and Services


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-27 15:55:11
Message-ID: AANLkTinUK2eBL=MFM43cryj3LNcZOEObAgep-tO-T8j+@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Dec 27, 2010 at 16:45, Simon Riggs <simon(at)2ndquadrant(dot)com> wrote:
> On Mon, 2010-12-27 at 14:54 +0100, Magnus Hagander wrote:
>
>> You will certainly be able to log into the standby with a superuser
>> account, nobody is preventing that. This is about protecting the
>> *master*. For example, from modifications made by a user who hacked
>> the standby.
>
> The users for master and standby are identical, so if they have access
> to the standby, they have access to the master. That's why we allow
> replication to be specifically excluded by the pg_hba.conf.

You are assuming there *is* a standby.

This is a defence against someone connecting with psql (or whatever)
directly to the master, *pretending to be* the standby (same
username/password, possibly even the same server ip).

Currently, this user gets the key to the kingdom and can modify things
freely on the master. With the patch, this user cannot. He can still
initiate streaming and eventually capture all your data, but he can't
modify it.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-27 21:04:22
Message-ID: AANLkTimfDv3VCjm56Qe8Le+mUSKPGVBzWtath09p+jY2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Dec 27, 2010 at 16:40, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
> On Mon, Dec 27, 2010 at 16:33, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>>> On Mon, Dec 27, 2010 at 10:53, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
>>>> We could quite easily make a replication role *never* be able to
>>>> connect to a non-walsender backend. That would mean that if you set
>>>> your role to WITH REPLICATION, it can *only* be used for replication
>>>> and nothing else (well, you could still SET ROLE to it, but given that
>>>> it's not a superuser (anymore), that doesn't have any security
>>>> implications.
>>
>>> Actually, having implemented that and tested it, I realize that's a
>>> pretty bad idea.
>>
>> OK, so if we're not going to recommend that REPLICATION roles be
>> NOLOGIN, we're back to the original question: should the REPLICATION
>> bit give any other special privileges?  I can see the point of allowing
>> such a user to issue pg_start_backup and pg_stop_backup.
>
> Yes, those would definitely be useful.

Updated patch, still pending docs, but otherwise updated: allow
start/stop backup, make sure only superuser can turn on/off the flag,
include in system views, show properly in psql.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/

Attachment Content-Type Size
repl_role.patch text/x-patch 16.6 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-27 21:42:09
Message-ID: 6072.1293486129@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Magnus Hagander <magnus(at)hagander(dot)net> writes:
> Updated patch, still pending docs, but otherwise updated: allow
> start/stop backup, make sure only superuser can turn on/off the flag,
> include in system views, show properly in psql.

I'd suggest avoiding creating the static cache variable
AuthenticatedUserIsReplicationRole. This can't possibly be sufficiently
interesting from a performance point of view to justify the risks
associated with stale cache values. Just look up the pg_authid syscache
entry when needed, ie, treat it more like rolcreaterole than rolsuper.

BTW, you forgot pg_dumpall support.

regards, tom lane


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-27 21:53:35
Message-ID: AANLkTi=45okH-MdRPe7B2uvLkkQ83=ct7MPtgLwY=cZU@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Dec 27, 2010 at 22:42, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>> Updated patch, still pending docs, but otherwise updated: allow
>> start/stop backup, make sure only superuser can turn on/off the flag,
>> include in system views, show properly in psql.
>
> I'd suggest avoiding creating the static cache variable
> AuthenticatedUserIsReplicationRole.  This can't possibly be sufficiently
> interesting from a performance point of view to justify the risks
> associated with stale cache values.  Just look up the pg_authid syscache
> entry when needed, ie, treat it more like rolcreaterole than rolsuper.

Sure, I catually had it that way first. But doing it this way was less
code. But I realize I should've revisited that decision when I made
the change to pg_start_backup and pg_stop_backup - before that the
checks would only happen during a very short window of time at the
start of the connection, but now it can happen later..

> BTW, you forgot pg_dumpall support.

Gah. I knew that, but somehow dropped it from my TODO. Thanks for the reminder!

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-28 12:05:36
Message-ID: AANLkTimUMHSGMnz+CUjmQbVhQryGweXRs6zEVekbONe6@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Dec 27, 2010 at 22:53, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
> On Mon, Dec 27, 2010 at 22:42, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>>> Updated patch, still pending docs, but otherwise updated: allow
>>> start/stop backup, make sure only superuser can turn on/off the flag,
>>> include in system views, show properly in psql.
>>
>> I'd suggest avoiding creating the static cache variable
>> AuthenticatedUserIsReplicationRole.  This can't possibly be sufficiently
>> interesting from a performance point of view to justify the risks
>> associated with stale cache values.  Just look up the pg_authid syscache
>> entry when needed, ie, treat it more like rolcreaterole than rolsuper.
>
> Sure, I catually had it that way first. But doing it this way was less
> code. But I realize I should've revisited that decision when I made
> the change to pg_start_backup and pg_stop_backup - before that the
> checks would only happen during a very short window of time at the
> start of the connection, but now it can happen later..
>
>
>> BTW, you forgot pg_dumpall support.
>
> Gah. I knew that, but somehow dropped it from my TODO. Thanks for the reminder!

Ok, here's an updated patch that does both these and includes
documentation and regression test changes. With that, I think we're
good to go.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/

Attachment Content-Type Size
repl_role.patch text/x-patch 51.3 KB

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-29 10:09:06
Message-ID: AANLkTi==eDTc0E0L5OOM8fvjB45V9ifoJQV8r8boctGQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Dec 28, 2010 at 13:05, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
> On Mon, Dec 27, 2010 at 22:53, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
>> On Mon, Dec 27, 2010 at 22:42, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>>>> Updated patch, still pending docs, but otherwise updated: allow
>>>> start/stop backup, make sure only superuser can turn on/off the flag,
>>>> include in system views, show properly in psql.
>>>
>>> I'd suggest avoiding creating the static cache variable
>>> AuthenticatedUserIsReplicationRole.  This can't possibly be sufficiently
>>> interesting from a performance point of view to justify the risks
>>> associated with stale cache values.  Just look up the pg_authid syscache
>>> entry when needed, ie, treat it more like rolcreaterole than rolsuper.
>>
>> Sure, I catually had it that way first. But doing it this way was less
>> code. But I realize I should've revisited that decision when I made
>> the change to pg_start_backup and pg_stop_backup - before that the
>> checks would only happen during a very short window of time at the
>> start of the connection, but now it can happen later..
>>
>>
>>> BTW, you forgot pg_dumpall support.
>>
>> Gah. I knew that, but somehow dropped it from my TODO. Thanks for the reminder!
>
> Ok, here's an updated patch that does both these and includes
> documentation and regression test changes. With that, I think we're
> good to go.

I've applied this version (with some minor typo-fixes).

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-29 14:05:02
Message-ID: AANLkTinXRPHv8yF6VVv9g=jpeCe+vCD4qCGZGLS5K8YG@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Dec 29, 2010 at 5:09 AM, Magnus Hagander <magnus(at)hagander(dot)net>wrote:

> > Ok, here's an updated patch that does both these and includes
> > documentation and regression test changes. With that, I think we're
> > good to go.
>
> I've applied this version (with some minor typo-fixes).
>
>
Do you think we could have worded these a bit better

<entry>Prepare for performing on-line backup (restricted to superusers or
replication roles)</entry>

to say 'restricted to superusers _and_ replication roles'.

Saying 'restricted to superusers _or_ replication roles' may mean that at
any time we allow one or the other, but not both (reader might assume that
decision is based on some other GUC).

Using 'and' would mean that we allow it for both of those roles.

Any specific reason NOREPLICATION_P and REPLICATION_P use the _P suffix?
AIUI, that suffix is used in gram.y to tag a token to mean it belongs to
Parser, and to avoid conflict with the same token elsewhere; NULL_P is a
good example.

In pg_authid.h, 8 spaces used between 'bool' and 'rolreplication', instead
tabs should have been used as the surrounding code.

Regards,
--
gurjeet.singh
@ EnterpriseDB - The Enterprise Postgres Company
http://www.EnterpriseDB.com

singh(dot)gurjeet(at){ gmail | yahoo }.com
Twitter/Skype: singh_gurjeet

Mail sent from my BlackLaptop device


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-29 14:40:34
Message-ID: AANLkTi=uNxUz86oyBgJjTgNnbPm9vrV04LS9ijuO09_p@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Dec 29, 2010 at 15:05, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com> wrote:
> On Wed, Dec 29, 2010 at 5:09 AM, Magnus Hagander <magnus(at)hagander(dot)net>
> wrote:
>>
>> > Ok, here's an updated patch that does both these and includes
>> > documentation and regression test changes. With that, I think we're
>> > good to go.
>>
>> I've applied this version (with some minor typo-fixes).
>>
>
> Do you think we could have worded these a bit better
>
> <entry>Prepare for performing on-line backup (restricted to superusers or
> replication roles)</entry>
>
> to say 'restricted to superusers _and_ replication roles'.
>
> Saying 'restricted to superusers _or_ replication roles' may mean that at
> any time we allow one or the other, but not both (reader might assume that
> decision is based on some other GUC).

Uh, not sure, actually. I would read the "and" as meaning you needed
*both*, which isn't true. We do allow, at any time, one or the other -
*or* both.

> Any specific reason NOREPLICATION_P and REPLICATION_P use the _P suffix?

Um, I just copied it off a similar entry elsewhere. I saw no comment
about what _P actually means, and I can't say I know. I know very
little about the bison files :-)

> AIUI, that suffix is used in gram.y to tag a token to mean it belongs to
> Parser, and to avoid conflict with the same token elsewhere; NULL_P is a
> good example.
>
> In pg_authid.h, 8 spaces used between 'bool' and 'rolreplication', instead
> tabs should have been used as the surrounding code.

Bleh. Well, pgindent will fix that.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-29 19:12:21
Message-ID: 1293649808-sup-6269@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Excerpts from Magnus Hagander's message of mié dic 29 11:40:34 -0300 2010:
> On Wed, Dec 29, 2010 at 15:05, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com> wrote:

> > Any specific reason NOREPLICATION_P and REPLICATION_P use the _P suffix?
>
> Um, I just copied it off a similar entry elsewhere. I saw no comment
> about what _P actually means, and I can't say I know. I know very
> little about the bison files :-)

Some lexer keywords have a _P prefix because otherwise they'd collide
with some symbol in Windows header files or something like that. It's
old stuff, but I think you, Magnus, were around at that time.

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-30 11:57:09
Message-ID: AANLkTi=m4HDGFnarUyoSwtute81d9F=_fOFEO4R0k3H2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Dec 29, 2010 at 20:12, Alvaro Herrera
<alvherre(at)commandprompt(dot)com> wrote:
> Excerpts from Magnus Hagander's message of mié dic 29 11:40:34 -0300 2010:
>> On Wed, Dec 29, 2010 at 15:05, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com> wrote:
>
>> > Any specific reason NOREPLICATION_P and REPLICATION_P use the _P suffix?
>>
>> Um, I just copied it off a similar entry elsewhere. I saw no comment
>> about what _P actually means, and I can't say I know. I know very
>> little about the bison files :-)
>
> Some lexer keywords have a _P prefix because otherwise they'd collide
> with some symbol in Windows header files or something like that.  It's
> old stuff, but I think you, Magnus, were around at that time.

Heh. That doesn't mean I *remember* it :-)

But yes, I see in commit 12c942383296bd626131241c012c2ab81b081738 the
comment "convert some keywords.c symbols to KEYWORD_P to prevent
conflict".

Based on that, I should probably change it back, right? I just tried a
patch for it and it compiles and checks just fine with the _P parts
removed.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-30 13:59:41
Message-ID: 1293717273-sup-5710@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Excerpts from Magnus Hagander's message of jue dic 30 08:57:09 -0300 2010:
> On Wed, Dec 29, 2010 at 20:12, Alvaro Herrera
> <alvherre(at)commandprompt(dot)com> wrote:

> > Some lexer keywords have a _P prefix because otherwise they'd collide
> > with some symbol in Windows header files or something like that.  It's
> > old stuff, but I think you, Magnus, were around at that time.
>
> Heh. That doesn't mean I *remember* it :-)

:-)

> But yes, I see in commit 12c942383296bd626131241c012c2ab81b081738 the
> comment "convert some keywords.c symbols to KEYWORD_P to prevent
> conflict".

Wow, what a mess of a patch ... nowadays this would be like 10 commits
(or so I hope) ... hey, did Bruce sabotage the qnx4 port surreptitiously?

> Based on that, I should probably change it back, right? I just tried a
> patch for it and it compiles and checks just fine with the _P parts
> removed.

Hmm, I wouldn't bother really. It's not that important anyway, IMHO.

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-30 14:54:28
Message-ID: 1293720868.11838.24.camel@fsopti579.F-Secure.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On tor, 2010-12-23 at 17:29 -0500, Tom Lane wrote:
> Josh Berkus <josh(at)agliodbs(dot)com> writes:
> > On 12/23/10 2:21 PM, Tom Lane wrote:
> >> Well, that's one laudable goal here, but "secure by default" is another
> >> one that ought to be taken into consideration.
>
> > I don't see how *not* granting the superuser replication permissions
> > makes things more secure. The superuser can grant replication
> > permissions to itself, so why is suspending them by default beneficial?
> > I'm not following your logic here.
>
> Well, the reverse of that is just as true: if we ship it without
> replication permissions on the postgres user, people can change that if
> they'd rather not create a separate role for replication. But I think
> we should encourage people to NOT do it that way. Setting it up that
> way by default hardly encourages use of a more secure arrangement.

I think this argument is a bit inconsistent in the extreme. You might
as well argue that a superuser shouldn't have any permissions by
default, to discourage users from using it. They can always grant
permissions back to it. I don't see why this particular one is so
different.

If we go down this road, we'll end up with a mess of permissions that a
superuser has and doesn't have.


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-30 14:54:31
Message-ID: 1293720871.11838.25.camel@fsopti579.F-Secure.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On ons, 2010-12-29 at 11:09 +0100, Magnus Hagander wrote:
> I've applied this version (with some minor typo-fixes).

This page is now somewhat invalidated:

http://developer.postgresql.org/pgdocs/postgres/role-attributes.html

First, it doesn't mention the replication privilege, and second it
continues to claim that superuser status bypasses all permission checks.


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Josh Berkus <josh(at)agliodbs(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-30 15:08:09
Message-ID: AANLkTinp2zP6ARp_+Bd78fWRxXE4hxpOdcPsGKjb6=k8@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Dec 30, 2010 at 9:54 AM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
> On tor, 2010-12-23 at 17:29 -0500, Tom Lane wrote:
>> Josh Berkus <josh(at)agliodbs(dot)com> writes:
>> > On 12/23/10 2:21 PM, Tom Lane wrote:
>> >> Well, that's one laudable goal here, but "secure by default" is another
>> >> one that ought to be taken into consideration.
>>
>> > I don't see how *not* granting the superuser replication permissions
>> > makes things more secure.  The superuser can grant replication
>> > permissions to itself, so why is suspending them by default beneficial?
>> >  I'm not following your logic here.
>>
>> Well, the reverse of that is just as true: if we ship it without
>> replication permissions on the postgres user, people can change that if
>> they'd rather not create a separate role for replication.  But I think
>> we should encourage people to NOT do it that way.  Setting it up that
>> way by default hardly encourages use of a more secure arrangement.
>
> I think this argument is a bit inconsistent in the extreme.  You might
> as well argue that a superuser shouldn't have any permissions by
> default, to discourage users from using it.  They can always grant
> permissions back to it.  I don't see why this particular one is so
> different.
>
> If we go down this road, we'll end up with a mess of permissions that a
> superuser has and doesn't have.

+1.

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-30 15:53:24
Message-ID: 17126.1293724404@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Magnus Hagander <magnus(at)hagander(dot)net> writes:
> But yes, I see in commit 12c942383296bd626131241c012c2ab81b081738 the
> comment "convert some keywords.c symbols to KEYWORD_P to prevent
> conflict".

> Based on that, I should probably change it back, right? I just tried a
> patch for it and it compiles and checks just fine with the _P parts
> removed.

I'd leave it be, it's fine as-is.

regards, tom lane


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2010-12-31 14:38:29
Message-ID: AANLkTinTL4_vR+yyTBevLXV5e6BAbC3GTZhTUMhpLb1-@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Dec 30, 2010 at 15:54, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
> On ons, 2010-12-29 at 11:09 +0100, Magnus Hagander wrote:
>> I've applied this version (with some minor typo-fixes).
>
> This page is now somewhat invalidated:
>
> http://developer.postgresql.org/pgdocs/postgres/role-attributes.html

Hmm. Somehow I missed that page completely when looking through the
docs. I'll go update that.

> First, it doesn't mention the replication privilege, and second it
> continues to claim that superuser status bypasses all permission checks.

Well, that was *already* wrong.

superuser doesn't bypass NOLOGIN.

That doesn't mean it shouldn't be fixed, but that's independent of the
replication role.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2011-01-03 11:00:24
Message-ID: AANLkTikE6AzSntA-DNoVb59Wrh4Ny_pCLKsFeWma77=v@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Dec 31, 2010 at 15:38, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
> On Thu, Dec 30, 2010 at 15:54, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
>> On ons, 2010-12-29 at 11:09 +0100, Magnus Hagander wrote:
>>> I've applied this version (with some minor typo-fixes).
>>
>> This page is now somewhat invalidated:
>>
>> http://developer.postgresql.org/pgdocs/postgres/role-attributes.html
>
> Hmm. Somehow I missed that page completely when looking through the
> docs. I'll go update that.

BTW, shouldn't CONNECTION LIMIT be listed on that page? and INHERIT?
And VALID UNTIL? They're all role attributes, no? At least the last
two certainly interact with the authentication system...

>> First, it doesn't mention the replication privilege, and second it
>> continues to claim that superuser status bypasses all permission checks.
>
> Well, that was *already* wrong.
>
> superuser doesn't bypass NOLOGIN.
>
> That doesn't mean it shouldn't be fixed, but that's independent of the
> replication role.

I've committed a fix for this.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2011-01-03 15:59:54
Message-ID: AANLkTikfuJebhqpC865zT1izKCX2WhQgX-fcVxq-CQL8@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Jan 3, 2011 at 6:00 AM, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
> On Fri, Dec 31, 2010 at 15:38, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
>> On Thu, Dec 30, 2010 at 15:54, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
>>> On ons, 2010-12-29 at 11:09 +0100, Magnus Hagander wrote:
>>>> I've applied this version (with some minor typo-fixes).
>>>
>>> This page is now somewhat invalidated:
>>>
>>> http://developer.postgresql.org/pgdocs/postgres/role-attributes.html
>>
>> Hmm. Somehow I missed that page completely when looking through the
>> docs. I'll go update that.
>
> BTW, shouldn't CONNECTION LIMIT be listed on that page? and INHERIT?
> And VALID UNTIL? They're all role attributes, no?

+1.

>>> First, it doesn't mention the replication privilege, and second it
>>> continues to claim that superuser status bypasses all permission checks.
>>
>> Well, that was *already* wrong.
>>
>> superuser doesn't bypass NOLOGIN.
>>
>> That doesn't mean it shouldn't be fixed, but that's independent of the
>> replication role.
>
> I've committed a fix for this.

I still think this is the wrong approach. Saying superuser doesn't
bypass nologin is like saying that it doesn't bypass the need to enter
the correct password to authenticate to it. You have to BE the
superuser before you start bypassing permissions checks, and NOLOGIN
and a possible password prompts control WHO CAN BECOME superuser. On
the other hand, the REPLICATION privilege is denying you the right to
perform an operation *even though you already are authenticated as a
superuser*. I don't think there's anywhere else in the system where
we allow a privilege to non-super-users but deny that same privilege
to super-users, and I don't think we should be starting now.

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Stephen Frost <sfrost(at)snowman(dot)net>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2011-01-03 16:20:38
Message-ID: 20326.1294071638@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On the other hand, the REPLICATION privilege is denying you the right to
> perform an operation *even though you already are authenticated as a
> superuser*. I don't think there's anywhere else in the system where
> we allow a privilege to non-super-users but deny that same privilege
> to super-users, and I don't think we should be starting now.

You might want to reflect on rolcatupdate a bit before asserting that
there are no cases where privileges are ever denied to superusers.

However, that precedent would suggest that the default should be to
grant the replication bit to superusers.

regards, tom lane


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Stephen Frost <sfrost(at)snowman(dot)net>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2011-01-03 16:23:29
Message-ID: AANLkTimCGPX=QNQFasx++h3Lpw1UOb6NVMDfHxDo40i4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Jan 3, 2011 at 11:20 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> On the other hand, the REPLICATION privilege is denying you the right to
>> perform an operation *even though you already are authenticated as a
>> superuser*.  I don't think there's anywhere else in the system where
>> we allow a privilege to non-super-users but deny that same privilege
>> to super-users, and I don't think we should be starting now.
>
> You might want to reflect on rolcatupdate a bit before asserting that
> there are no cases where privileges are ever denied to superusers.

Oh, huh. I wasn't aware of that.

> However, that precedent would suggest that the default should be to
> grant the replication bit to superusers.

Yes it would.

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


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Stephen Frost <sfrost(at)snowman(dot)net>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2011-01-03 22:50:35
Message-ID: AANLkTikGK62xzg9wT9Jx0ofk=qNqGjBad5WV7rr5Tto2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Jan 3, 2011 at 17:23, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Mon, Jan 3, 2011 at 11:20 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>>> On the other hand, the REPLICATION privilege is denying you the right to
>>> perform an operation *even though you already are authenticated as a
>>> superuser*.  I don't think there's anywhere else in the system where
>>> we allow a privilege to non-super-users but deny that same privilege
>>> to super-users, and I don't think we should be starting now.
>>
>> You might want to reflect on rolcatupdate a bit before asserting that
>> there are no cases where privileges are ever denied to superusers.
>
> Oh, huh.  I wasn't aware of that.
>
>> However, that precedent would suggest that the default should be to
>> grant the replication bit to superusers.
>
> Yes it would.

Just to be clear: are we saying that "CREATE ROLE foo SUPERUSER"
should grant both superuser and replication, as well as the default
"postgres" user also having replication as well?

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Stephen Frost <sfrost(at)snowman(dot)net>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2011-01-05 03:24:20
Message-ID: AANLkTi=hWTN-YfH+F7WrXsp4AjddvmDP_SYH5BS=2vmD@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Jan 3, 2011 at 5:50 PM, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
> On Mon, Jan 3, 2011 at 17:23, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> On Mon, Jan 3, 2011 at 11:20 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>>>> On the other hand, the REPLICATION privilege is denying you the right to
>>>> perform an operation *even though you already are authenticated as a
>>>> superuser*.  I don't think there's anywhere else in the system where
>>>> we allow a privilege to non-super-users but deny that same privilege
>>>> to super-users, and I don't think we should be starting now.
>>>
>>> You might want to reflect on rolcatupdate a bit before asserting that
>>> there are no cases where privileges are ever denied to superusers.
>>
>> Oh, huh.  I wasn't aware of that.
>>
>>> However, that precedent would suggest that the default should be to
>>> grant the replication bit to superusers.
>>
>> Yes it would.
>
> Just to be clear: are we saying that "CREATE ROLE foo SUPERUSER"
> should grant both superuser and replication, as well as the default
> "postgres" user also having replication as well?

I think that's what we're saying.

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


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Stephen Frost <sfrost(at)snowman(dot)net>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2011-01-05 13:24:45
Message-ID: AANLkTimSEy7_iiz9xV5WqcY60Og4tFh24CMdTKC2Brrf@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Jan 5, 2011 at 04:24, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Mon, Jan 3, 2011 at 5:50 PM, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
>> On Mon, Jan 3, 2011 at 17:23, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>>> On Mon, Jan 3, 2011 at 11:20 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>>> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>>>>> On the other hand, the REPLICATION privilege is denying you the right to
>>>>> perform an operation *even though you already are authenticated as a
>>>>> superuser*.  I don't think there's anywhere else in the system where
>>>>> we allow a privilege to non-super-users but deny that same privilege
>>>>> to super-users, and I don't think we should be starting now.
>>>>
>>>> You might want to reflect on rolcatupdate a bit before asserting that
>>>> there are no cases where privileges are ever denied to superusers.
>>>
>>> Oh, huh.  I wasn't aware of that.
>>>
>>>> However, that precedent would suggest that the default should be to
>>>> grant the replication bit to superusers.
>>>
>>> Yes it would.
>>
>> Just to be clear: are we saying that "CREATE ROLE foo SUPERUSER"
>> should grant both superuser and replication, as well as the default
>> "postgres" user also having replication as well?
>
> I think that's what we're saying.

Ok, done and applied.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Stephen Frost <sfrost(at)snowman(dot)net>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2011-01-05 14:05:33
Message-ID: AANLkTinxC6GjH6RJqi1tAScLafAcK8Q43oNy03eDcAKH@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Jan 5, 2011 at 8:24 AM, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
> Ok, done and applied.

Thanks.

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


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Stephen Frost <sfrost(at)snowman(dot)net>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2011-01-06 04:55:11
Message-ID: 1294289711.3243.0.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On mån, 2011-01-03 at 11:20 -0500, Tom Lane wrote:
> You might want to reflect on rolcatupdate a bit before asserting that
> there are no cases where privileges are ever denied to superusers.

Arguably, the reason that that is hardly documented and slightly
deprecated is that the underlying design decision is questionable.


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>, Florian Pflug <fgp(at)phlo(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication as a separate permissions
Date: 2011-01-06 04:59:00
Message-ID: 1294289940.3243.3.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On tis, 2011-01-04 at 22:24 -0500, Robert Haas wrote:
> > Just to be clear: are we saying that "CREATE ROLE foo SUPERUSER"
> > should grant both superuser and replication, as well as the default
> > "postgres" user also having replication as well?
>
> I think that's what we're saying.

So now superusers have it by default but you can explicitly revoke it?

I guess that's still inconsistent with other superuser behavior. You
can't revoke a superuser's CREATEDB bit, for example. (You can, but it
won't have an effect, of course.)