Обсуждение: password handling change between 2.4.2 and 2.4.3

Поиск
Список
Период
Сортировка

password handling change between 2.4.2 and 2.4.3

От
Jerry Schneider
Дата:
I am using a library for testing that uses psycopg2 to connect to
PostgreSQL databases.  I recently had to install new machines and have
found that if I use anything newer than 2.4.2 I get OperationalError:
FATAL:  password authentication failed for user "blah"  Can anyone tell
me what changed so that I can get the testing library updated to that
change please?

Thanks ahead of time!
jer

--
Linux registered user #475536
Ubuntu registered user #28583



Re: password handling change between 2.4.2 and 2.4.3

От
Daniele Varrazzo
Дата:
On Fri, Sep 5, 2014 at 7:47 PM, Jerry Schneider <jerry57@gmail.com> wrote:
> I am using a library for testing that uses psycopg2 to connect to PostgreSQL
> databases.  I recently had to install new machines and have found that if I
> use anything newer than 2.4.2 I get OperationalError: FATAL:  password
> authentication failed for user "blah"  Can anyone tell me what changed so
> that I can get the testing library updated to that change please?

Does your password contain (or may contain) "strange" characters?
Before 2.4.3 they were not correctly escaped when passed to the
PQconnectdb connection string. So e.g. if you have a space in the
password and you try passing it as argument as in
`connect(password=PASS)` on psycopg 2.4.2 the connection fails. This
was fixed in 2.4.3 (in this commit:
https://github.com/psycopg/psycopg2/commit/625cc1b402b33799757fb9b8fe421a2ea63e1236).
If you (or someone else before you) found this problem and decided to
manually escape the password before passing it to psycopg, from 2.4.3
it gets double-escaped.

There were other changes between these two versions but this is the
one I'd blame.

As a workaround you may pass the entire connection string to psycopg,
so if you already have QPASS with the password quoted and escaped,
something like `connect("password=%s" % QPASS)` will work the same way
in every psycopg version (the string is passed unchanged to the
database connection function).

-- Daniele


Re: password handling change between 2.4.2 and 2.4.3

От
Jerry Schneider
Дата:
Thanks I now know how to fix this at least for our usage and maybe for
everyones.  THANKS!

jer

On 9/5/14 12:13 PM, Daniele Varrazzo wrote:
> On Fri, Sep 5, 2014 at 7:47 PM, Jerry Schneider <jerry57@gmail.com> wrote:
>> I am using a library for testing that uses psycopg2 to connect to PostgreSQL
>> databases.  I recently had to install new machines and have found that if I
>> use anything newer than 2.4.2 I get OperationalError: FATAL:  password
>> authentication failed for user "blah"  Can anyone tell me what changed so
>> that I can get the testing library updated to that change please?
> Does your password contain (or may contain) "strange" characters?
> Before 2.4.3 they were not correctly escaped when passed to the
> PQconnectdb connection string. So e.g. if you have a space in the
> password and you try passing it as argument as in
> `connect(password=PASS)` on psycopg 2.4.2 the connection fails. This
> was fixed in 2.4.3 (in this commit:
> https://github.com/psycopg/psycopg2/commit/625cc1b402b33799757fb9b8fe421a2ea63e1236).
> If you (or someone else before you) found this problem and decided to
> manually escape the password before passing it to psycopg, from 2.4.3
> it gets double-escaped.
>
> There were other changes between these two versions but this is the
> one I'd blame.
>
> As a workaround you may pass the entire connection string to psycopg,
> so if you already have QPASS with the password quoted and escaped,
> something like `connect("password=%s" % QPASS)` will work the same way
> in every psycopg version (the string is passed unchanged to the
> database connection function).
>
> -- Daniele

--
Linux registered user #475536
Ubuntu registered user #28583



Re: password handling change between 2.4.2 and 2.4.3

От
Daniele Varrazzo
Дата:
On Fri, Sep 5, 2014 at 8:29 PM, Jerry Schneider <jerry57@gmail.com> wrote:
> Thanks I now know how to fix this at least for our usage and maybe for
> everyones.  THANKS!

Is yours a public project?

-- Daniele


Re: password handling change between 2.4.2 and 2.4.3

От
Jerry Schneider
Дата:
Not my project, but one that I help out on.

https://github.com/franz-see/Robotframework-Database-Library/

Thanks again!

jer

On 9/5/14 12:54 PM, Daniele Varrazzo wrote:
> On Fri, Sep 5, 2014 at 8:29 PM, Jerry Schneider <jerry57@gmail.com> wrote:
>> Thanks I now know how to fix this at least for our usage and maybe for
>> everyones.  THANKS!
> Is yours a public project?
>
> -- Daniele

--
Linux registered user #475536
Ubuntu registered user #28583