Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id C01EE723ED9 for ; Sun, 20 Nov 2011 09:45:50 -0400 (AST) Received: from wwwmaster.postgresql.org ([217.196.146.204]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RS7iQ-0008Oz-1i for pgsql-bugs@postgresql.org; Sun, 20 Nov 2011 13:45:50 +0000 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id pAKDjbLT068727 for ; Sun, 20 Nov 2011 13:45:37 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id pAKDjbH5068726; Sun, 20 Nov 2011 13:45:37 GMT (envelope-from www) Date: Sun, 20 Nov 2011 13:45:37 GMT Message-Id: <201111201345.pAKDjbH5068726@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #6302: Certificate lookup fails for users with /dev/null as home directory From: "Diego Elio Pettenò" Content-Type: text/plain; charset=utf-8 X-Archive-Number: 201111/151 X-Sequence-Number: 31746 The following bug has been logged online: Bug reference: 6302 Logged by: Diego Elio Pettenò Email address: flameeyes@flameeyes.eu PostgreSQL version: 9.1.1 Operating system: Gentoo Linux Description: Certificate lookup fails for users with /dev/null as home directory Details: A common way to make sure an user has no access to a home directory on Unix is to set that directory to /dev/null. Unfortunately that causes the stat() call to return an error when you're trying to check for the certificate. From 9.1.1, src/interfaces/libpq/fe-secure.c, line 1009 and counting: else if (stat(fnbuf, &buf) != 0) { /* * If file is not present, just go on without a client cert; server * might or might not accept the connection. Any other error, * however, is grounds for complaint. */ if (errno != ENOENT) { printfPQExpBuffer(&conn->errorMessage, libpq_gettext("could not open certificate file \"%s\": %s\n"), fnbuf, pqStrerror(errno, sebuf, sizeof(sebuf))); return -1; } have_cert = false; } Interestingly enough, the .pgpass file check is not as strict; from fe-connect.c lines 4863 and counting: if (!getPgPassFilename(pgpassfile)) return NULL; /* If password file cannot be opened, ignore it. */ if (stat(pgpassfile, &stat_buf) != 0) return NULL; I suppose it might be a good idea to simply replicate the same logic for the certificate, so that it restores the chance to use SSL connections on users that have /dev/null as home directory, which right now is outright impossible.