Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id D89F21337B3E for ; Thu, 3 Mar 2011 23:43:12 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 31328-04 for ; Fri, 4 Mar 2011 03:43:05 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.kvr.at (kvr.at [83.65.151.178]) by mail.postgresql.org (Postfix) with ESMTP id C53EA133655C for ; Thu, 3 Mar 2011 23:43:04 -0400 (AST) Received: from 83-65-151-182.work.xdsl-line.inode.at ([83.65.151.182]:51046 helo=[10.7.77.20]) by mail.kvr.at with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1PvLur-0007j3-TY; Fri, 04 Mar 2011 04:42:58 +0100 Message-ID: <4D705FC3.6050008@kvr.at> Date: Fri, 04 Mar 2011 04:42:59 +0100 From: Christian Kastner User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20101226 Iceowl/1.0b1 Icedove/3.0.11 MIME-Version: 1.0 To: Tom Lane CC: pgsql-bugs@postgresql.org Subject: Re: Possible regression: libpq + SSL aborts when user has no home directory References: <4D6FF05E.1050201@kvr.at> <8295.1299189555@sss.pgh.pa.us> <10824.1299196694@sss.pgh.pa.us> In-Reply-To: <10824.1299196694@sss.pgh.pa.us> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.975 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FB_GET_MEDS=0.935, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201103/91 X-Sequence-Number: 29601 On 03/04/2011 12:58 AM, Tom Lane wrote: > I wrote: >> Christian Kastner writes: >>> Using libpq 9.0.3, when an SSL connection is attempted from a client >>> whose EUID is not in a password database, the connection fails because >>> the home directory cannot be determined. With libpq 8.4.7, everything is >>> fine. > >> Hmm. Offhand I agree that that seems like an unnecessary regression. >> It should act just the same as if it could not find any of those files. >> A quick look with git blame suggests that this got broken in my >> commit 4ed4b6c54e5fab24ab2624d80e26f7546edc88ad, and I don't think >> that it was intentional. > >> One small problem is that if the sslmode is "verify-ca" or >> "verify-full", failure to find the root cert file is an error, >> and that error message normally includes the pathname at which >> the cert file was sought. What shall we print if we couldn't >> identify the home directory? > > Attached is an untested patch which I'd appreciate if you (or somebody > else who uses SSL connections more than I do) could test. I can confirm that this fixes the issue for me. I tested this with psql and PGSSLMODE={disable,prefer,verify-ca}, with various (or no) PGSSLROOTCERTs in the case of verify-ca. In all cases, the result was the expected one. > I resolved the last mentioned problem by printing > "~/.postgresql/root.crt", which is a bit of a Unix-ism but doesn't > seem too unreasonable, and anyway we weren't printing anything > terribly useful before either. We could change that message though if > we wanted, since AFAICS the only way to get there is > pqGetHomeDirectory failure. So we could just print the "could not get > home directory" message instead. Thoughts? IMO your solution is fine. It clearly states that the certificate file (at the default path) does not exist; whether this is because the file itself or the home directory is missing appears to me as a trivial detail. Thanks for the quick help! Christian