Re: Patch for checking file parameters to psql before password prompt - Mailing list pgsql-hackers

From Josh Kupershmidt
Subject Re: Patch for checking file parameters to psql before password prompt
Date
Msg-id CAK3UJRHQ3QkjJbNH56kbV71f-kQBCoEJVEu-V6An8RV8nbD5sw@mail.gmail.com
Whole thread Raw
In response to Patch for checking file parameters to psql before password prompt  (Alastair Turner <bell@ctrlf5.co.za>)
Responses Re: Patch for checking file parameters to psql before password prompt
List pgsql-hackers
On Sun, Dec 2, 2012 at 4:37 AM, Alastair Turner <bell@ctrlf5.co.za> wrote:
> Patch for the changes discussed in
> http://archives.postgresql.org/pgsql-hackers/2010-10/msg00919.php
> attached (eventually ...)
>
> In summary: If the input file (-f) doesn't exist or the ouput or log
> files (-o and -l) can't be created psql exits before prompting for a
> password.

I assume you meant "-L" instead of "-l" here for specifying psql's log
file. I don't think that the inability to write to psql's log file
should be treated as a fatal error, especially since it is not treated
as such by the current code:
 $ psql test -L /tmp/not_allowed psql: could not open log file "/tmp/not_allowed": Permission denied [... proceeds to
psqlprompt from here ...]
 

and the user (or script) may still usefully perform his work. Whereas
with your patch:
 $ psql test -L /tmp/not_allowed psql: could not open log file "/tmp/not_allowed": Permission denied $

And IMO the same concern applies to the query results file, "-o".
Although +1 for the part about having psql exit early if the input
filename does not exist, since psql already bails out in this case,
and there is nothing else to be done in such case.

Josh



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: PATCH: optimized DROP of multiple tables within a transaction
Next
From: Robert Haas
Date:
Subject: Re: Makefiles don't seem to remember to rebuild everything anymore