Re: BUG #15827: Unable to connect on Windows using pg_services.conf using Python psycopg2
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Jorge Gustavo Rocha <jgr@geomaster.pt>, pgsql-bugs@lists.postgresql.org
Date: 2019-06-20T03:12:18Z
Lists: pgsql-bugs
On Wed, Jun 19, 2019 at 04:44:58PM -0400, Tom Lane wrote: > Ah-hah! That explains much. So a non-invasive fix would be to force > parseServiceFile to open the file in text mode; I think this would > work for that: > > - f = fopen(serviceFile, "r"); > + f = fopen(serviceFile, "rt"); > > I don't think that that's really a good solution, because it does little > to prevent the same problem from reappearing elsewhere. But if we wanted > the smallest possible fix that might do. Actually I think that something like 40cfe86 may be a solution to look at (combined with 0ba06e0 except for the portions enforcing the text flags like in initdb). This stuff found its way only in 12~, but having us switching to the concurrent-safe version for fopen() that we bundle in port/ has the advantage to take care of this issue, because on HEAD, if 'b' or 't' are not defined, then we enforce to text mode. Still back-patching that is sensitive and we have known that hard last year.. The discussion here is on 10, and the password file has does not enforce the flag either because it filters '\r' by itself. So another solution may be to do the same thing as what's done in passwordFromFile()? -- Michael
Commits
-
Fix failures to ignore \r when reading Windows-style newlines.
- 8c52b77ddea7 9.4.24 landed
- 6266654db7fa 9.5.19 landed
- ba27151d1eb0 9.6.15 landed
- cb65b454f87b 10.10 landed
- 11a0a4db3cdb 11.5 landed
- c58cf97f2fc4 12.0 landed
- b654714f9bcf 13.0 landed