Re: [PATCH] Prefer getenv("HOME") to find the UNIX home directory
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Anders Kaseorg <andersk@mit.edu>
Cc: Christoph Moench-Tegeder <cmt@burggraben.net>,
Daniel Gustafsson <daniel@yesql.se>,
Kyotaro Horiguchi <horikyota.ntt@gmail.com>, alvherre@alvh.no-ip.org,
pgsql-hackers@lists.postgresql.org
Date: 2022-01-10T02:17:46Z
Lists: pgsql-hackers
Attachments
- 0001-make-pqGethostbyname-static.patch (text/x-diff) patch 0001
- 0002-simplify-pqGetpwuid-API.patch (text/x-diff) patch 0002
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
Commits
-
Clean up messy API for src/port/thread.c.
- 98e93a1fc93e 15.0 landed
-
Prefer $HOME when looking up the current user's home directory.
- 376ce3e404b7 15.0 landed