dbTalk Databases Forums  

[BUGS] BUG #1580: pg_dumpall aborts when cwd is unreadable

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] BUG #1580: pg_dumpall aborts when cwd is unreadable in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
David Elliott
 
Posts: n/a

Default [BUGS] BUG #1580: pg_dumpall aborts when cwd is unreadable - 04-10-2005 , 02:23 PM







The following bug has been logged online:

Bug reference: 1580
Logged by: David Elliott
Email address: elliott (AT) stcnet (DOT) com
PostgreSQL version: 8.0.1
Operating system: Mac OS X 10.3.8
Description: pg_dumpall aborts when cwd is unreadable
Details:

After setting up a cron job to backup the database nightly I noticed it
wasn't running. The log contained the following messages:

could not identify current directory: Permission denied
could not identify current directory: Permission denied
could not identify current directory: Permission denied
The program "pg_dump" is needed by pg_dumpall but was not found in the
same directory as "pg_dumpall".
Check your installation.

It can be reproduced quite simply on the command-line. As root and with
CWD= root's home directory (not readable by anyone but root) do this:
# sudo -u postgres /usr/local/pgsql/bin/pg_dumpall

Changing to a path readable by the postgres user before running the command
fixes the issue.

When an absolute path is given I see no reason to read the current directory
before trying the absolute path.

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Reply With Quote
  #2  
Old   
Bruce Momjian
 
Posts: n/a

Default Re: [BUGS] BUG #1580: pg_dumpall aborts when cwd is unreadable - 04-10-2005 , 08:06 PM






David Elliott wrote:
Quote:
The following bug has been logged online:

Bug reference: 1580
Logged by: David Elliott
Email address: elliott (AT) stcnet (DOT) com
PostgreSQL version: 8.0.1
Operating system: Mac OS X 10.3.8
Description: pg_dumpall aborts when cwd is unreadable
Details:

After setting up a cron job to backup the database nightly I noticed it
wasn't running. The log contained the following messages:

could not identify current directory: Permission denied
could not identify current directory: Permission denied
could not identify current directory: Permission denied
The program "pg_dump" is needed by pg_dumpall but was not found in the
same directory as "pg_dumpall".
Check your installation.

It can be reproduced quite simply on the command-line. As root and with
CWD= root's home directory (not readable by anyone but root) do this:
# sudo -u postgres /usr/local/pgsql/bin/pg_dumpall

Changing to a path readable by the postgres user before running the command
fixes the issue.

When an absolute path is given I see no reason to read the current directory
before trying the absolute path.
The reason this happens is because pg_dumpall has to be sure it can find
pg_dump, and that pg_dump is the same PostgreSQL version as pg_dumpall.

While we could do this without knowing the current directory, the code
is easier if we know it. If you look in find_my_exec() in
src/port/exec.c you can see what we use 'cwd' for. It is used if the
PATH contains the current directory, and on Win32 which checks the
current directory first.

The code right now tests for 'cwd' first and just errors out if it can't
find it. Is it worth refactoring it so you can run pg_dumpall from a
directory you can't view? Instead of checking 'cwd' right at the start
we would have to find it only when we need it, and in several places or
in a function call. It doesn't seem worth it to me.

--
Bruce Momjian | http://candle.pha.pa.us
pgman (AT) candle (DOT) pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match


Reply With Quote
  #3  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] BUG #1580: pg_dumpall aborts when cwd is unreadable - 04-11-2005 , 01:10 AM



Bruce Momjian <pgman (AT) candle (DOT) pha.pa.us> writes:
Quote:
The code right now tests for 'cwd' first and just errors out if it can't
find it. Is it worth refactoring it so you can run pg_dumpall from a
directory you can't view? Instead of checking 'cwd' right at the start
we would have to find it only when we need it, and in several places or
in a function call. It doesn't seem worth it to me.
.... and it would *still* fail if you tried to call pg_dumpall via a
symlink or relative path. Unless someone knows a portable way to
resolve symlinks without doing a chdir first, I think there's no
way to avoid the surprise factor.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.