Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 054732E2F0D for ; Tue, 11 Dec 2007 08:21:58 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 69463-08 for ; Tue, 11 Dec 2007 08:21:48 -0400 (AST) Received: from mxp.excelsarc.ro (unknown [89.38.26.199]) by postgresql.org (Postfix) with ESMTP id 83E312E2F33 for ; Tue, 11 Dec 2007 08:21:54 -0400 (AST) Received: (qmail 2210 invoked from network); 11 Dec 2007 12:21:47 -0000 Received: from localhost (127.0.0.1) by localhost with ESMTPS (DHE-RSA-AES256-SHA encrypted); 11 Dec 2007 12:21:47 -0000 From: sulfinu@gmail.com To: Oliver Jowett Subject: Re: JDBC driver patch for non-ASCII users Date: Tue, 11 Dec 2007 14:21:47 +0200 User-Agent: KMail/1.9.7 Cc: pgsql-jdbc@postgresql.org References: <200712071448.21411.sulfinu@gmail.com> <200712082027.17731.sulfinu@gmail.com> <475B047B.5020100@opencloud.com> In-Reply-To: <475B047B.5020100@opencloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200712111421.47161.sulfinu@gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/70 X-Sequence-Number: 17925 On Saturday 08 December 2007, Oliver Jowett wrote: > Can you explain what this change does, then? > > > String result = UnixCrypt.crypt(salt, password); > > - byte[] encodedResult = > > result.getBytes("US-ASCII"); + byte[] > > encodedResult = result.getBytes(Encoding.AUTHENTICATION_PHASE_ENCODING); > > AFAIK UnixCrypt.crypt() should only be returning ASCII anyway, right? Wrong, it returns a String, in other words a series of Unicode points, not necessarily ASCII characters. > > Same thing re. salt decoding, doesn't the server only ever send ASCII? The server never bothers about any encoding during the authentication phase. The server simply treats everything as byte arrays and compares what is received from the client to the result of its own byte-wise computation, based on stored user name and password. My change is an attempt to increase the chances of a successful authentication by trying to guess the encoding used at server-side for the byte representation of user name, password and database name. > If you have fixes to build.xml that are not related to your encoding > changes, please post them as a separate patch with an explanation. If > you post a number of unrelated changes as a single patch, it makes it > much harder to selectively apply them. I have no comment on whether that > correction is necessary or not -- but it's unexplained and not encoding > related, so it shouldn't be there. You have a point here. I knew I should have added a statement about that very small correction in build.xml, but the message was already long enough and I feared it might not be read patiently and in full (as it happened anyway ;) ). The Ant file is rather complicated and I thought the correction would be silently understood and included. Ironically, the correction was already made in CVS by Kris Jurka.