Re: [PATCH] Prefer getenv("HOME") to find the UNIX home directory

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Anders Kaseorg <andersk(at)mit(dot)edu>
Cc: Christoph Moench-Tegeder <cmt(at)burggraben(dot)net>, Daniel Gustafsson <daniel(at)yesql(dot)se>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, alvherre(at)alvh(dot)no-ip(dot)org, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Prefer getenv("HOME") to find the UNIX home directory
Date: 2022-01-10 02:17:46
Message-ID: 2098948.1641781066@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> Meh. I guess there's not much point in arguing with facts on the
> ground. Anders' proposed behavior seems like the way to go then,
> at least so far as libpq is concerned.

So I pushed that, but while working on it I grew quite annoyed
at the messy API exhibited by src/port/thread.c, particularly
at how declaring its functions in port.h requires #including
<netdb.h> and <pwd.h> there. That means those headers are
read by every compile in our tree, though only a tiny number
of modules actually need either. So here are a couple of
follow-on patches to improve that situation.

For pqGethostbyname, there is no consumer other than
src/port/getaddrinfo.c, which makes it even sillier because that
file isn't even compiled on a large majority of platforms, making
pqGethostbyname dead code that we nonetheless build everywhere.
So 0001 attached just moves that function into getaddrinfo.c.

For pqGetpwuid, the best solution seemed to be to add a
less platform-dependent API layer, which I did in 0002
attached. Perhaps someone would object to the API details
I chose, but by and large this seems like an improvement
that reduces the amount of code duplication in the callers.

Thoughts?

regards, tom lane

Attachment Content-Type Size
0001-make-pqGethostbyname-static.patch text/x-diff 3.8 KB
0002-simplify-pqGetpwuid-API.patch text/x-diff 11.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhihong Yu 2022-01-10 02:45:09 Re: null iv parameter passed to combo_init()
Previous Message Thomas Munro 2022-01-10 02:00:19 Re: Why is src/test/modules/committs/t/002_standby.pl flaky?