Обсуждение: pgsql user change to postgres

Поиск
Список
Период
Сортировка

pgsql user change to postgres

От
Joe
Дата:
Hi,

I started using PostgreSQL (8.0) about a year ago on Windows.  Following
the installation instructions, I created a 'postgres' user (BTW, this
was based on the Short Version instructions for UNIX, i.e., "adduser
postgres" --I'm not sure it this is made explicit elsewhere, even for UNIX).

I'm now migrating to FreeBSD and was surprised to find that the port
used 'pgsql' as the user.  The maintainer said that was done to ensure
backward compatibility because that *was* the original name.  Since I
didn't need to be backward compatible (and my Windows dbs already used
'postgres'), I tried to bypass that (sort of) requirement by renaming
'pgsql' to 'postgres' (in the passwd file) and changing the
postgresql_user variable used in the rc startup file.  That was OK until
I tried to build 8.1.4_1.  I figured out how to tweak the build files to
stick with 'postgres' but then I realized I'd have to patch them every
time I'd fetch a new build, so I went back to 'pgsql'.

I'm curious about a few things.  How long ago was the 'pgsql' to
'postgres' change (and maybe it would be helpful to know the rationale
for the backward incompatible decision--I tried searching in the
archives but 'pgsql' and 'postgres' are all too common)?  Is there any
problem with using 'pgsql' vs. 'postgres' (and are there any plans to
deprecate or disallow the former at some point)?  Are other UNIX/Linux
ports in the same boat, or does any Linux port offer users a choice in
this matter?  Would any change to the build/install procs have to be
done through the current port maintainer or are they somewhere in the
PostgreSQL source tree (and subject to standard submission/review
procedures)?

Joe

Re: pgsql user change to postgres

От
"chris smith"
Дата:
On 7/2/06, Joe <dev@freedomcircle.net> wrote:
> Hi,
>
> I started using PostgreSQL (8.0) about a year ago on Windows.  Following
> the installation instructions, I created a 'postgres' user (BTW, this
> was based on the Short Version instructions for UNIX, i.e., "adduser
> postgres" --I'm not sure it this is made explicit elsewhere, even for UNIX).
>
> I'm now migrating to FreeBSD and was surprised to find that the port
> used 'pgsql' as the user.  The maintainer said that was done to ensure
> backward compatibility because that *was* the original name.  Since I
> didn't need to be backward compatible (and my Windows dbs already used
> 'postgres'), I tried to bypass that (sort of) requirement by renaming
> 'pgsql' to 'postgres' (in the passwd file) and changing the
> postgresql_user variable used in the rc startup file.  That was OK until
> I tried to build 8.1.4_1.  I figured out how to tweak the build files to
> stick with 'postgres' but then I realized I'd have to patch them every
> time I'd fetch a new build, so I went back to 'pgsql'.
>
> I'm curious about a few things.  How long ago was the 'pgsql' to
> 'postgres' change (and maybe it would be helpful to know the rationale
> for the backward incompatible decision--I tried searching in the
> archives but 'pgsql' and 'postgres' are all too common)?  Is there any
> problem with using 'pgsql' vs. 'postgres' (and are there any plans to
> deprecate or disallow the former at some point)?  Are other UNIX/Linux
> ports in the same boat, or does any Linux port offer users a choice in
> this matter?  Would any change to the build/install procs have to be
> done through the current port maintainer or are they somewhere in the
> PostgreSQL source tree (and subject to standard submission/review
> procedures)?

I *think* that's a bsd decision to change the name. All of the linux
systems I have used for the last 5-6 years have used 'postgres' as the
user.

--
Postgresql & php tutorials
http://www.designmagick.com/

Re: pgsql user change to postgres

От
Tom Lane
Дата:
Joe <dev@freedomcircle.net> writes:
> I'm now migrating to FreeBSD and was surprised to find that the port
> used 'pgsql' as the user.  The maintainer said that was done to ensure
> backward compatibility because that *was* the original name.

It's always been "postgres", at least as far as the standard name of the
initial database superuser goes.  I see no recommendation of "pgsql" in
Postgres 4.2 for instance:

$ gzcat postgres-v4r2.tar.gz | grep -i pgsql | wc
0 0 0
$

Various ports have used "pgsql" in their preferred installation paths,
eg the Linux RPMs use /var/lib/pgsql/data as the preferred $PGDATA,
but this should generally be transparent to users of the database.
Changing the superuser name isn't transparent, though.

FreeBSD is out in left field here.  However, I don't see why you need to
alter the build to change this.  Just create a new user postgres and run
the initdb step as that user.  initdb uses the OS user name it's run as
to determine the initial superuser name.

            regards, tom lane

Re: pgsql user change to postgres

От
Joe
Дата:
Tom Lane wrote:
> FreeBSD is out in left field here.  However, I don't see why you need to
> alter the build to change this.  Just create a new user postgres and run
> the initdb step as that user.  initdb uses the OS user name it's run as
> to determine the initial superuser name.

That's exactly what I did first, and as you say, it worked fine (at
least I was able to create another user and another database).

It was when I tried starting PostgreSQL from boot, which requires adding
"postgresql_enable" in /etc/rc.conf, that it didn't work.  I tracked
that down to /usr/local/etc/rc.d/010.pgsql.sh which uses a
"postgresql_user" variable defined as "pgsql" by the port.  And this in
turn is driven by the Makefile and other files provided by the FreeBSD
port.  As I mentioned, I could fix those references to 'pgsql' but then
I'd have to patch them any time I fetched a port update.

So I guess the port procedures are not controlled by the Development Group?

Joe



Re: pgsql user change to postgres

От
Tom Lane
Дата:
Joe <dev@freedomcircle.net> writes:
> It was when I tried starting PostgreSQL from boot, which requires adding
> "postgresql_enable" in /etc/rc.conf, that it didn't work.  I tracked
> that down to /usr/local/etc/rc.d/010.pgsql.sh which uses a
> "postgresql_user" variable defined as "pgsql" by the port.  And this in
> turn is driven by the Makefile and other files provided by the FreeBSD
> port.  As I mentioned, I could fix those references to 'pgsql' but then
> I'd have to patch them any time I fetched a port update.

> So I guess the port procedures are not controlled by the Development Group?

We can't dictate the contents of port-supplied files, if that's what you
mean.

Plan B is to leave the pgsql user alone and add another superuser named
postgres.  You can have more than one superuser ...

            regards, tom lane

Re: pgsql user change to postgres

От
Joe
Дата:
Tom Lane wrote:
> Plan B is to leave the pgsql user alone and add another superuser named
> postgres.  You can have more than one superuser ...

Yes, that's what my hosting provider (hub.org, which also hosts
postgresql.org) seems to have done.  This also avoids another minor
problem:  initdb on UNIX appears to create a 'postgres' database
regardless of who runs the procedure (aside from template0 and
template1;  I don't have a 'postgres' database on Windows and since it's
been a year I don't recall what the Windows initdb did).  So when the
'pgsql' user invokes psql without specifying a database, there's no
'pgsql' database to be found.

Joe

Re: pgsql user change to postgres

От
Vivek Khera
Дата:
On Jul 2, 2006, at 9:55 AM, Joe wrote:

> I'm now migrating to FreeBSD and was surprised to find that the
> port used 'pgsql' as the user.  The maintainer said that was done
> to ensure backward compatibility because that *was* the original
> name.  Since I didn't need to be backward compatible (and my
> Windows dbs already used 'postgres'), I tried to bypass that (sort
> of) requirement by renaming 'pgsql' to 'postgres' (in the passwd
> file) and changing the postgresql_user variable used in the rc
> startup file.  That was OK until I tried to build 8.1.4_1.  I
> figured out how to tweak the build files to stick with 'postgres'
> but then I realized I'd have to patch them every time I'd fetch a
> new build, so I went back to 'pgsql'.

if you want to use the freebsd ports system (which is advisable)
don't fight against it.  use the recommended/defaults where you can.

What I do, though, is set the PostgreSQL super user to be 'postgres'
and let the unix system user remain 'pgsql' since the latter doesn't
matter one bit.  This is trivially done by altering the
~pgsql/.profile file and adding PGUSER=postgres and exporting that
variable. Do this *before* you init the DB, then run initdb with this
comand:

  su - pgsql -c 'initdb -U postgres'

 From now on, any upgrades you do will no longer be so painful.



Re: pgsql user change to postgres

От
Joe
Дата:
Vivek Khera wrote:
> if you want to use the freebsd ports system (which is advisable) don't
> fight against it.  use the recommended/defaults where you can.

I wasn't trying to fight it.  It's just that the port disagrees with the
PG documentation and apparently most other ports.  The maintainer said
it was for backward compatibility but it's apparently only a FreeBSD
"phenomenom" :-)

> What I do, though, is set the PostgreSQL super user to be 'postgres' and
> let the unix system user remain 'pgsql' since the latter doesn't matter
> one bit.  This is trivially done by altering the ~pgsql/.profile file
> and adding PGUSER=postgres and exporting that variable. Do this *before*
> you init the DB, then run initdb with this comand:
>
>  su - pgsql -c 'initdb -U postgres'
>
>  From now on, any upgrades you do will no longer be so painful.

That sounds reasonable.  I'll give it a try.  Thanks.

Joe

Re: pgsql user change to postgres

От
"Ian Harding"
Дата:
> I wasn't trying to fight it.  It's just that the port disagrees with the
> PG documentation and apparently most other ports.  The maintainer said
> it was for backward compatibility but it's apparently only a FreeBSD
> "phenomenom" :-)
>
It may be a *BSD pheonomenon, since I know it applies in NetBSD as
well.  I think they all borrow from each other's ports collections....