Thread: BUG #4619: pg_ctl reports strange error message when be executed on non executable directory

The following bug has been logged online:

Bug reference:      4619
Logged by:          Hiroshi Saito
Email address:      hiroshi3110@gmail.com
PostgreSQL version: 8.3.5
Operating system:   Mac OS X 10.5.6
Description:        pg_ctl reports strange error message when be executed on
non executable directory
Details:

$ sudo -u postgres ls
ls: .: Permission denied
$ sudo -u postgres /opt/local/lib/postgresql83/bin/pg_ctl -D
/opt/local/var/db/postgresql83/defaultdb start
could not identify current directory: Permission denied
could not identify current directory: Permission denied
could not identify current directory: Permission denied
The program "postgres" is needed by pg_ctl but was not found in the
same directory as "pg_ctl".
Check your installation.

$ cd /tmp
$ sudo -u postgres /opt/local/lib/postgresql83/bin/pg_ctl -D
/opt/local/var/db/postgresql83/defaultdb start
LOG:  database system was shut down at 2009-01-16 10:48:59 JST
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started

I think changing current directory before executing pg_ctl is VERY BAD KNOW
HOW. I think this is going to prevent novice to use PostgreSQL.
Or something I missed? Bad configuration?

Many users seem to be tumbled upon this issue:
http://www.google.com/search?hl=en&q=pg_ctl+%22could+not+identify+current+di
rectory%3A+Permission+denied%22&btnG=Google+Search&aq=f&oq=
"Hiroshi Saito" <hiroshi3110@gmail.com> writes:
> Operating system:   Mac OS X 10.5.6
> Description:        pg_ctl reports strange error message when be executed on
> non executable directory

It works all right (with some bleating) on Linux, so this seems to be
basically a deficiency of Apple's getcwd().  I really don't see any
reason for us to worry about it though, because the only way to be in
a directory that you don't have read permission for is to chmod it
that way after you cd into it --- the shell won't let you cd into
a directory if it can't read it:

pro:~ tgl$ mkdir bogus
pro:~ tgl$ chmod 000 bogus
pro:~ tgl$ cd bogus
bash: cd: bogus: Permission denied

(above test is on OSX 10.5.6).  So I hardly find this to be something
the average user is going to have a problem with; anyone who manages
to get into the situation will know exactly why it's failing, and there
isn't any good reason why it should need to work.

            regards, tom lane