Re: Fix for pg_upgrade user flag

Lists: pgsql-hackers
From: Bruce Momjian <bruce(at)momjian(dot)us>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Fix for pg_upgrade user flag
Date: 2011-05-07 12:56:10
Message-ID: 201105071256.p47CuAb01225@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

The attached, applied patch checks that the pg_upgrade user specified is
a super-user. It also reports the error message when the post-pg_ctl
connection fails.

This was prompted by a private bug report from EnterpriseDB.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Attachment Content-Type Size
/rtmp/pg_upgrade text/x-diff 3.2 KB

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix for pg_upgrade user flag
Date: 2011-05-07 13:50:40
Message-ID: BANLkTimW_xqApB0eg2Ax6Q7CrhcAtxfoDQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, May 7, 2011 at 8:56 AM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> The attached, applied patch checks that the pg_upgrade user specified is
> a super-user.  It also reports the error message when the post-pg_ctl
> connection fails.
>
> This was prompted by a private bug report from EnterpriseDB.

It strikes me that it's fairly crazy to think you're going to be able
to catch all the possible errors the server might throw this way.
Don't we need some way of letting the actual server errors leak out?

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


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix for pg_upgrade user flag
Date: 2011-05-07 13:55:35
Message-ID: BANLkTikxNYAaagiakyLniwmd07FowtCnYQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, May 7, 2011 at 9:50 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Sat, May 7, 2011 at 8:56 AM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>> The attached, applied patch checks that the pg_upgrade user specified is
>> a super-user.  It also reports the error message when the post-pg_ctl
>> connection fails.
>>
>> This was prompted by a private bug report from EnterpriseDB.
>
> It strikes me that it's fairly crazy to think you're going to be able
> to catch all the possible errors the server might throw this way.
> Don't we need some way of letting the actual server errors leak out?

Or, hmm. Maybe you just did that. If so, never mind. :-)

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


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix for pg_upgrade user flag
Date: 2011-05-07 16:21:12
Message-ID: 201105071621.p47GLCe26989@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas wrote:
> On Sat, May 7, 2011 at 9:50 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> > On Sat, May 7, 2011 at 8:56 AM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> >> The attached, applied patch checks that the pg_upgrade user specified is
> >> a super-user. ?It also reports the error message when the post-pg_ctl
> >> connection fails.
> >>
> >> This was prompted by a private bug report from EnterpriseDB.
> >
> > It strikes me that it's fairly crazy to think you're going to be able
> > to catch all the possible errors the server might throw this way.
> > Don't we need some way of letting the actual server errors leak out?
>
> Or, hmm. Maybe you just did that. If so, never mind. :-)

What I did was to report the errors of our first database probe after we
started the server --- for some reason, that code was not reporting the
libpq error message, while all other failed connections did.

The second change was to only run pg_upgrade as a database super-user,
and hopefully that will avoid odd pg_dump error messages.

One question I have is why we even bother to allow the database username
to be specified? Shouldn't we just hard-code that to 'postgres'? Is
there any reason to allow another username to be used? You can't drop
the postgres user but you can remove super-user permissions from it so
maybe we have to continue allowing it:

postgres=> drop user postgres;
ERROR: cannot drop role postgres because it is required by the database system
postgres=> alter user postgres nosuperuser;
ALTER ROLE

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix for pg_upgrade user flag
Date: 2011-05-07 17:43:21
Message-ID: 9693.1304790201@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bruce Momjian <bruce(at)momjian(dot)us> writes:
> One question I have is why we even bother to allow the database username
> to be specified? Shouldn't we just hard-code that to 'postgres'?

Only if you want to render pg_upgrade unusable by a significant fraction
of people. "postgres" is not the hard wired name of the bootstrap
superuser.

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix for pg_upgrade user flag
Date: 2011-05-07 17:50:48
Message-ID: 201105071750.p47HomX15230@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > One question I have is why we even bother to allow the database username
> > to be specified? Shouldn't we just hard-code that to 'postgres'?
>
> Only if you want to render pg_upgrade unusable by a significant fraction
> of people. "postgres" is not the hard wired name of the bootstrap
> superuser.

I was really wondering if I should be using that hard-coded name, rather
than allowing the user to supply it. They have to compile in a
different name, and I assume that name is accessible somewhere.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix for pg_upgrade user flag
Date: 2011-05-07 20:48:14
Message-ID: 1304801294.15989.7.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On lör, 2011-05-07 at 13:50 -0400, Bruce Momjian wrote:
> I was really wondering if I should be using that hard-coded name,
> rather than allowing the user to supply it. They have to compile in a
> different name, and I assume that name is accessible somewhere.

"postgres" is not compiled in. It's whatever user you run initdb under.
In particular, in the regression tests, it is probably not "postgres".


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix for pg_upgrade user flag
Date: 2011-05-07 22:48:49
Message-ID: 201105072248.p47Mmni09724@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut wrote:
> On l?r, 2011-05-07 at 13:50 -0400, Bruce Momjian wrote:
> > I was really wondering if I should be using that hard-coded name,
> > rather than allowing the user to supply it. They have to compile in a
> > different name, and I assume that name is accessible somewhere.
>
> "postgres" is not compiled in. It's whatever user you run initdb under.
> In particular, in the regression tests, it is probably not "postgres".

Thanks. I get confused because the 'postgres' database is hardcoded in,
but not the username. Not sure why I am so easily confused.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix for pg_upgrade user flag
Date: 2011-05-07 23:03:16
Message-ID: 4DC5CFB4.9080800@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 05/07/2011 06:48 PM, Bruce Momjian wrote:
>> "postgres" is not compiled in. It's whatever user you run initdb under.
>> In particular, in the regression tests, it is probably not "postgres".
> Thanks. I get confused because the 'postgres' database is hardcoded in,
> but not the username. Not sure why I am so easily confused.

There is a requirement for a known database name, but no requirement for
a known superuser name.

cheers

andrew