Thread: 7.1beta4 initdb problem

7.1beta4 initdb problem

From
"Tim Barnard"
Date:
I've installed 7.1beta4 on a system that has never had PostgreSQL installed on it. configure, gmake, and gmake install, all worked fine. However, when I su over to postgres and run "initdb -D /progs/db", I get the following message:
 
The program '/usr/local/pgsql/bin/postgres' needed by initdb does not belong to PostgreSQL version 7.1beta4. Check your installation.
 
Any ideas?
 
Tim
 

Re: 7.1beta4 initdb problem

From
Peter Eisentraut
Date:
Tim Barnard writes:

> The program '/usr/local/pgsql/bin/postgres' needed by initdb does not
> belong to PostgreSQL version 7.1beta4. Check your installation.

Can you run 'sh -x initdb ...' and show me the output?  Some platform
information would be useful as well.

--
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/


Re: 7.1beta4 initdb problem

From
"Tim Barnard"
Date:
Well, I was logged in as postgres when this occured.
I managed to resolve it by changing permissions on the /progs
directory to rwx. It had been r-x. Strange error message for a permissions
problem on a destination directory!
Thanks for the suggestion though.

Tim

----- Original Message -----
From: "Alessio Bragadini" <alessio@sevenseas.org>
To: "Tim Barnard" <tbarnard@povn.com>
Cc: <pgsql-general@postgresql.org>
Sent: Sunday, February 04, 2001 2:13 PM
Subject: Re: [GENERAL] 7.1beta4 initdb problem


>
> Yes, happened to me, too. You need not to be root, but an unprivileged
> user (i.e. postgres). That's the strangest error message in a long
> time!
>
> --
> Alessio F. Bragadini alessio@sevenseas.org
>
 

Re: 7.1beta4 initdb problem

From
Tom Lane
Date:
Peter Eisentraut <peter_e@gmx.net> writes:
> Tim Barnard writes:
>> The program '/usr/local/pgsql/bin/postgres' needed by initdb does not
>> belong to PostgreSQL version 7.1beta4. Check your installation.

> Can you run 'sh -x initdb ...' and show me the output?  Some platform
> information would be useful as well.

Ah, I see the problem:

$ bin/postgres -V
postgres (PostgreSQL) 7.1beta4
$ su
Password:
# bin/postgres -V

"root" execution of the PostgreSQL server is not permitted.

The server must be started under an unprivileged userid to prevent
a possible system security compromise. See the INSTALL file for
more information on how to properly start the server.


Probably initdb should have its own check for being run as root;
this seems cleaner than reorganizing the checks in the postgres
executable.

            regards, tom lane

Re: 7.1beta4 initdb problem

From
"Tim Barnard"
Date:
Thanks Tom, the problem wasn't that, though, since I was logged in as
postgres at the time. However, as I was trying to create the database under
/progs and it's permissions were set to r-x, changing them to rwx fixed it.
It took awhile to figure it out as the error message threw me off :-)

Regards,

Tim

----- Original Message -----
From: "Tom Lane" <tgl@sss.pgh.pa.us>
To: "Peter Eisentraut" <peter_e@gmx.net>
Cc: "Tim Barnard" <tbarnard@povn.com>; <pgsql-general@postgresql.org>
Sent: Sunday, February 04, 2001 7:54 PM
Subject: Re: [GENERAL] 7.1beta4 initdb problem


> Peter Eisentraut <peter_e@gmx.net> writes:
> > Tim Barnard writes:
> >> The program '/usr/local/pgsql/bin/postgres' needed by initdb does not
> >> belong to PostgreSQL version 7.1beta4. Check your installation.
>
> > Can you run 'sh -x initdb ...' and show me the output?  Some platform
> > information would be useful as well.
>
> Ah, I see the problem:
>
> $ bin/postgres -V
> postgres (PostgreSQL) 7.1beta4
> $ su
> Password:
> # bin/postgres -V
>
> "root" execution of the PostgreSQL server is not permitted.
>
> The server must be started under an unprivileged userid to prevent
> a possible system security compromise. See the INSTALL file for
> more information on how to properly start the server.
>
>
> Probably initdb should have its own check for being run as root;
> this seems cleaner than reorganizing the checks in the postgres
> executable.
>
> regards, tom lane
>


Re: 7.1beta4 initdb problem

From
Peter Eisentraut
Date:
Tim Barnard writes:

> Well, I was logged in as postgres when this occured.
> I managed to resolve it by changing permissions on the /progs
> directory to rwx. It had been r-x. Strange error message for a permissions
> problem on a destination directory!

I'm not sure I follow.  Given that executing a program doesn't require
write permission I assume this is your PGDATA.  But PGDATA isn't checked
until after --version/-V has been evaluated.  The easiest thing would be
to check what postgres -V would show (in the broken setup).

--
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/


Re: 7.1beta4 initdb problem

From
Peter Eisentraut
Date:
Tom Lane writes:

> Probably initdb should have its own check for being run as root;
> this seems cleaner than reorganizing the checks in the postgres
> executable.

I does have that check, but unfortunately that check requires pg_id, and
finding the right pg_id requires finding the right postgres.  The "right
pg_id" is not entirely as trivial as it sounds, because pg_id's from <=6.5
have very different behaviour.

An alternative would be to find the right pg_id first based on its (to be
implemented) --version, and then double-checking for the right postgres.

--
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/


Re: 7.1beta4 initdb problem

From
Tom Lane
Date:
Peter Eisentraut <peter_e@gmx.net> writes:
> Tom Lane writes:
>> Probably initdb should have its own check for being run as root;
>> this seems cleaner than reorganizing the checks in the postgres
>> executable.

> I does have that check, but unfortunately that check requires pg_id, and
> finding the right pg_id requires finding the right postgres.  The "right
> pg_id" is not entirely as trivial as it sounds, because pg_id's from <=6.5
> have very different behaviour.

Um.  Okay then, the alternatives are

(1) move the handling of --version out of PostgresMain and friends, and
put it into main.c before the are-we-root check;

(2) move the are-we-root check out of main.c and duplicate it in
PostgresMain and friends.

Which choice do you like best?

            regards, tom lane

Re: 7.1beta4 initdb problem

From
Peter Eisentraut
Date:
Tom Lane writes:

> Um.  Okay then, the alternatives are
>
> (1) move the handling of --version out of PostgresMain and friends, and
> put it into main.c before the are-we-root check;
>
> (2) move the are-we-root check out of main.c and duplicate it in
> PostgresMain and friends.
>
> Which choice do you like best?

Let them meet in the middle. ;-)  If the option is --version or --help,
ignore the root test.

I would have opted for (1), but it would be nice to be able to see the
help as root, too, and I don't want to move that.


diff -U2 -r1.40 main.c
--- main.c      2001/01/24 19:42:56     1.40
+++ main.c      2001/02/05 20:58:50
@@ -110,5 +110,8 @@
        */
 #ifndef __BEOS__
-       if (geteuid() == 0)
+       if (!(argc > 1
+                 && ( strcmp(argv[1], "--help")==0 || strcmp(argv[1], "-?")==0
+                          || strcmp(argv[1], "--version")==0 || strcmp(argv[1], "-V")==0 ))
+               && (geteuid() == 0) )
        {
                fprintf(stderr, "%s", NOROOTEXEC);

--
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/


Re: 7.1beta4 initdb problem

From
Alessio Bragadini
Date:
Tim Barnard:

> The program '/usr/local/pgsql/bin/postgres' needed by initdb does
  not belong to PostgreSQL version 7.1beta4. Check your installation.

> Any ideas?

Yes, happened to me, too. You need not to be root, but an unprivileged
user (i.e. postgres). That's the strangest error message in a long
time!

--
Alessio F. Bragadini        alessio@sevenseas.org