![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I'm running Debian unstable, and I keep getting a message from a cron job that wants to do.maintenance about no password being supplied. Now, I gather in the past a person had to explicitly put a password in the cron job, but we are now supposed to use a file called ~/.pgpass (~ being /var/lib/postgres). |
#3
| |||
| |||
|
|
ghaverla (AT) freenet (DOT) edmonton.ab.ca> writes: I'm running Debian unstable, and I keep getting a message from a cron job that wants to do.maintenance about no password being supplied. Now, I gather in the past a person had to explicitly put a password in the cron job, but we are now supposed to use a file called ~/.pgpass (~ being /var/lib/postgres). That is the recommended solution, but I'll bet that the cron job is not running with the same value of $HOME that you think it is, and so it is failing to find the file. You might want to explicitly set $HOME in the script. |
|
Also, test the .pgpass file by manually running psql with it; if there is something wrong with the file contents you'll be able to prove it... |
#4
| |||
| |||
|
|
the message from cron indicates that home is /var/lib/postgres and the user is postgres when the script runs. X-Cron-Env: <SHELL=/bin/sh X-Cron-Env: <HOME=/var/lib/postgres X-Cron-Env: <PATH=/usr/bin:/bin X-Cron-Env: <LOGNAME=postgres |
#5
| |||
| |||
|
|
On Thu, 1 Jul 2004, Tom Lane wrote: ghaverla (AT) freenet (DOT) edmonton.ab.ca> writes: I'm running Debian unstable, and I keep getting a message from a cron job that wants to do.maintenance about no password being supplied. Well, if I 'su - postgres' from root, and then run 'psql template1' everything works fine. I suppose I could edit the .pgpass to contain a bad password, and see if psql fails. If I put a bad password in .pgpass, the attempt to try psql fails. So, psql is using .pgpass. |
#6
| |||
| |||
|
|
ghaverla (AT) freenet (DOT) edmonton.ab.ca> writes: I'm running Debian unstable, and I keep getting a message from a cron job that wants to do.maintenance about no password being supplied. I suggest you edit /usr/lib/postgresql/bin/do.maintenance and add a line set -x at line 2. Then you will be able to see exactly what command it is trying to run. |
#7
| |||
| |||
|
|
+ /usr/bin/psql -d template1 -t -q -X Password: psql: fe_sendauth: no password supplied My guess is it is that -X (disallow reading of a .psqlrc file) is somehow turning off the reading of any .pgpass file. |
#8
| |||
| |||
|
|
On Sun, 2004-07-04 at 20:41, ghaverla (AT) freenet (DOT) edmonton.ab.ca wrote: + /usr/bin/psql -d template1 -t -q -X Password: psql: fe_sendauth: no password supplied My guess is it is that -X (disallow reading of a .psqlrc file) is somehow turning off the reading of any .pgpass file. I can't see how that could be. -X is a psql option, but .pgpass is read by the libpq library, which has no knowledge of the psql options. |
|
Can you check that do.maintenance is being run by the correct user? (Put the line "user identity = `id`" somewhere near the top.) Also, see if do.maintenance works when run directly rather than through cron. |
#9
| |||
| |||
|
|
On Sun, 2004-07-04 at 20:41, ghaverla (AT) freenet (DOT) edmonton.ab.ca wrote: My guess is it is that -X (disallow reading of a .psqlrc file) is somehow turning off the reading of any .pgpass file. I can't see how that could be. |
#10
| |||
| |||
|
|
Oliver Elphick <olly (AT) lfix (DOT) co.uk> writes: On Sun, 2004-07-04 at 20:41, ghaverla (AT) freenet (DOT) edmonton.ab.ca wrote: My guess is it is that -X (disallow reading of a .psqlrc file) is somehow turning off the reading of any .pgpass file. I can't see how that could be. I don't believe it either --- libpq will always look for a $HOME/.pgpass file. A couple of possibilities that I don't think have been considered yet: 1. Old libpq? .pgpass is only supported in 7.3 and later. Even if your psql is 7.3, I think it might be possible for the dynamic linker to bind a 7.2 libpq.so to it, if your ldconfig search path is such that the older libpq.so is found first. |
|
2. Bad permissions on .pgpass? libpq will silently ignore a .pgpass file it cannot open for reading.. It will not-so-silently ignore a .pgpass file that has any group or world permissions. I'm not sure if you are capturing stderr from the psql run; if not, it's possible the latter case is occurring and we're just not seeing the bleat... |
![]() |
| Thread Tools | |
| Display Modes | |
| |