pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Diego Elio Pettenò <flameeyes@flameeyes.eu>
To: pgsql-bugs@postgresql.org
Subject: BUG #6302: Certificate lookup fails for users with /dev/null as home directory
Date: Sun, 20 Nov 2011 13:45:37 GMT
Message-ID: <201111201345.pAKDjbH5068726@wwwmaster.postgresql.org> (raw)


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.



view thread (6+ messages)  latest in thread

Message-ID: <201111201345.pAKDjbH5068726@wwwmaster.postgresql.org>
Permalink:  ../201111201345.pAKDjbH5068726@wwwmaster.postgresql.org/
Also on:    postgresql.org/message-id/201111201345.pAKDjbH5068726@wwwmaster.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: flameeyes@flameeyes.eu
  Subject: Re: BUG #6302: Certificate lookup fails for users with /dev/null as home directory
  In-Reply-To: <201111201345.pAKDjbH5068726@wwwmaster.postgresql.org>
  References: <201111201345.pAKDjbH5068726@wwwmaster.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox