Thread: pg_dump "feature"

pg_dump "feature"

From
"Viorel Dragomir"
Date:
In 7.1.2 you can launch this command without any problems:
pg_dump -u -s database < file.txt
 
where file.txt contains 2 lines:
username
password
~
~
~
 
And you'll get the dump of the <database>.
 
In 7.1.3 this command work, the only incovenience is that pg_dump shows "User name: Password:"
but gets the password from file.
 
In 7.3.x the pg_dump accepts the password only from stdin. The user must enter his password.
It's a feature or a bug, because i can't see any logic in this behaviour.
 
I hope i'll receive an answer, or else i'll post this topic on developers list :)
 
Thanks.

Re: pg_dump "feature"

From
Tom Lane
Date:
"Viorel Dragomir" <bc@vio.ro> writes:
> In 7.3.x the pg_dump accepts the password only from stdin. The user must en=
> ter his password.
> It's a feature or a bug, because i can't see any logic in this behaviour.

It's a feature ... or at least an intentional change.

If you want to keep your password in a file, see the ~/.pgpass feature.
        regards, tom lane


Re: pg_dump "feature"

From
Dmitry Tkach
Date:
Viorel Dragomir wrote:

> In 7.1.2 you can launch this command without any problems:
> pg_dump -u -s database < file.txt
>  
> where file.txt contains 2 lines:
> username
> password
> ~
> ~
> ~
>  
> And you'll get the dump of the <database>.
>  
> In 7.1.3 this command work, the only incovenience is that pg_dump 
> shows "User name: Password:"
> but gets the password from file.
>  
> In 7.3.x the pg_dump accepts the password only from stdin. The user 
> must enter his password.
> It's a feature or a bug, because i can't see any logic in this behaviour.

It's a feature :-)
The logic is that it is insecure to keep passwords in files.
If you are not concerned about the security in this case, you can switch 
to ident or trust identification. That won't prompt you for the password.

Dima.




Re: pg_dump "feature"

From
"Viorel Dragomir"
Date:
Thanks for the answer[s].
Interesting that when i launch the command from php through exec() it works
fine even on pg_dump 7.3.x
I guess this feature works only on [shell] command line.

This is the php code:
       $tmp_fname = tempnam("/tmp", "file-");       $f = fopen($tmp_fname, "w");       fwrite($f,
"$username\n".USER_DB_PASSWORD."\n");      fclose($f);
 
       $cmd = "pg_dump $add_cmd $export $add_table < $tmp_fname";       $result = system($cmd);
unlink($tmp_fname);

----- Original Message -----
From: "Tom Lane" <tgl@sss.pgh.pa.us>
To: "Viorel Dragomir" <bc@vio.ro>
Cc: <pgsql-sql@postgresql.org>
Sent: Wednesday, July 16, 2003 5:29 PM
Subject: Re: [SQL] pg_dump "feature"


> "Viorel Dragomir" <bc@vio.ro> writes:
> > In 7.3.x the pg_dump accepts the password only from stdin. The user must
en=
> > ter his password.
> > It's a feature or a bug, because i can't see any logic in this
behaviour.
>
> It's a feature ... or at least an intentional change.
>
> If you want to keep your password in a file, see the ~/.pgpass feature.
>
> 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