weird initdb output

Started by Geoffreyalmost 16 years ago4 messagesgeneral
Jump to latest
#1Geoffrey
lists@serioustechnology.com

I wrote a script that creates a new database from an existing backup.
Works great on my machine. Another user tries to use it and sees the
following output from initdb:

could not change directory to "/root"
The files belonging to this database system will be owned by user
"postgres".
This user must also own the server process.
.
.

Why is it trying to change directory to /root??? Running as the
postgres user.

Any assistance would be appreciated.
--
Until later, Geoffrey

"I predict future happiness for America if they can prevent
the government from wasting the labors of the people under
the pretense of taking care of them."
- Thomas Jefferson

#2John R Pierce
pierce@hogranch.com
In reply to: Geoffrey (#1)
Re: weird initdb output

On 06/28/10 11:41 AM, Geoffrey wrote:

I wrote a script that creates a new database from an existing backup.
Works great on my machine. Another user tries to use it and sees the
following output from initdb:

could not change directory to "/root"
The files belonging to this database system will be owned by user
"postgres".
This user must also own the server process.
.
.

Why is it trying to change directory to /root??? Running as the
postgres user.

Any assistance would be appreciated.

maybe he did an "su postgres" and not a "su - postgres" ? the latter
does the equiv of a login, while the first only changes hte effective user.

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Geoffrey (#1)
Re: weird initdb output

Geoffrey <lists@serioustechnology.com> writes:

I wrote a script that creates a new database from an existing backup.
Works great on my machine. Another user tries to use it and sees the
following output from initdb:

could not change directory to "/root"
The files belonging to this database system will be owned by user
"postgres".
This user must also own the server process.
.
.

Why is it trying to change directory to /root???

IIRC, part of the startup process involves chdir'ing to where the initdb
executable is and then chdir'ing back to whatever directory had been
current when you called initdb. I speculate the other guy was root and
did "su postgres" not "su - postgres", so his cwd was still root's home
directory.

This might be harmless as long as you gave an absolute path for PGDATA
to initdb, but I'd still recommend using su - not just su.

regards, tom lane

#4Geoffrey
lists@serioustechnology.com
In reply to: Tom Lane (#3)
Re: weird initdb output

Tom Lane wrote:

Geoffrey <lists@serioustechnology.com> writes:

I wrote a script that creates a new database from an existing backup.
Works great on my machine. Another user tries to use it and sees the
following output from initdb:

could not change directory to "/root"
The files belonging to this database system will be owned by user
"postgres".
This user must also own the server process.
.
.

Why is it trying to change directory to /root???

IIRC, part of the startup process involves chdir'ing to where the initdb
executable is and then chdir'ing back to whatever directory had been
current when you called initdb. I speculate the other guy was root and
did "su postgres" not "su - postgres", so his cwd was still root's home
directory.

This might be harmless as long as you gave an absolute path for PGDATA
to initdb, but I'd still recommend using su - not just su.

Appears this was exactly the case. I do specify absolute path for
PGDATA, thanks.

--
Until later, Geoffrey

"I predict future happiness for America if they can prevent
the government from wasting the labors of the people under
the pretense of taking care of them."
- Thomas Jefferson