Re: BUG #5304: psql using conninfo fails in connecting to the server - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #5304: psql using conninfo fails in connecting to the server
Date
Msg-id 14396.1265163057@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #5304: psql using conninfo fails in connecting to the server  (Fujii Masao <masao.fujii@gmail.com>)
Responses Re: BUG #5304: psql using conninfo fails in connecting to the server
List pgsql-bugs
Fujii Masao <masao.fujii@gmail.com> writes:
> On Wed, Feb 3, 2010 at 10:05 AM, Joe Conway <mail@joeconway.com> wrote:
>> Objections?

> I think that PQconnectdbParams() rather than psql should handle the
> dbname containing "=". Otherwise whenever we use PQconnectdbParams(),
> we would have to check for the content of the dbname before calling
> it in the future application. Which looks very messy for me.

Yeah, I just complained about the same thing.  However I don't think
we should make PQconnectdbParams do that unconditionally.  In a lot of
applications, it is a key advantage of PQconnectdbParams that there's
no possibility of funny characters in the arguments resulting in "SQL
injection", ie, somebody being able to set connection parameters they
weren't supposed to.  Even without any malicious intent, having to
think about quoting and so forth destroys a lot of the value.

Since we haven't yet released PQconnectdbParams, it's not too late
to twiddle its API.  What I'm thinking about is an additional
boolean parameter "expand_dbname", which only if true would enable
treating an equal-sign-containing dbname like a conninfo string.
Passing true would be okay for command-line apps where the user is
supposed to control all the conn parameters anyway, but apps that
want more security would pass false.

We should also give more than zero thought to how values coming from the
expanded dbname should interact with values from other arguments to
PQconnectdbParams --- which should override which?  And should there be
an order dependency?

            regards, tom lane

pgsql-bugs by date:

Previous
From: Joe Conway
Date:
Subject: Re: BUG #5304: psql using conninfo fails in connecting to the server
Next
From: Joe Conway
Date:
Subject: Re: BUG #5304: psql using conninfo fails in connecting to the server