Re: Patch for checking file parameters to psql before password prompt

From: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
To: Alastair Turner <bell(at)ctrlf5(dot)co(dot)za>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Patch for checking file parameters to psql before password prompt
Date: 2012-12-19 01:44:15
Message-ID: CAK3UJRHQ3QkjJbNH56kbV71f-kQBCoEJVEu-V6An8RV8nbD5sw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Dec 2, 2012 at 4:37 AM, Alastair Turner <bell(at)ctrlf5(dot)co(dot)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 psql prompt 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2012-12-19 02:02:20 Re: Makefiles don't seem to remember to rebuild everything anymore
Previous Message Andres Freund 2012-12-19 01:18:14 Re: PATCH: optimized DROP of multiple tables within a transaction