libpq 9.4 requires /etc/passwd?

From: Christoph Berg <cb(at)df7cb(dot)de>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: libpq 9.4 requires /etc/passwd?
Date: 2015-01-09 23:32:40
Message-ID: 20150109233240.GA30515@msg.df7cb.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I've got several reports that postfix's pgsql lookup tables are broken
with 9.4's libpq5, while 9.3's libpq5 works just fine. The error
message looks like this:

Jan 10 00:11:40 lehmann postfix/trivial-rewrite[29960]: warning: connect to pgsql server localhost:5432: out of memory?
Jan 10 00:11:40 lehmann postfix/trivial-rewrite[29960]: warning: pgsql:/etc/postfix/pgsqltest lookup error for "*"

The "out of memory?" message comes from PQsetdbLogin and
PQerrorMessage in postfix-2.11.3/src/global/dict_pgsql.c:

if ((host->db = PQsetdbLogin(host->name, host->port, NULL, NULL,
dbname, username, password)) == NULL
|| PQstatus(host->db) != CONNECTION_OK) {
msg_warn("connect to pgsql server %s: %s",
host->hostname, PQerrorMessage(host->db));

There are two ways around the problem on the postfix side: not running
the postfix service chrooted, or using a "proxy" map which effectively
does the lookup also from outside the chroot.

Debian bug https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=756627
mentions another solution: creation of an /etc/passwd file inside the
postfix chroot.

libpq wants the user home directory to find .pgpass and
.pg_service.conf files, but apparently the behavior to require the
existence of the passwd file (or nss equivalent) is new in 9.4.

I've tried to make sense of the fe-connect.c code to find the issue
but couldn't spot it. Can someone explain what's going on there? Is
this a bug in libpq? (It's certainly a regression.)

Christoph
--
cb(at)df7cb(dot)de | http://www.df7cb.de/

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-01-09 23:42:19 Re: libpq 9.4 requires /etc/passwd?
Previous Message Jim Nasby 2015-01-09 23:18:54 Re: Custom/Foreign-Join-APIs (Re: [v9.5] Custom Plan API)