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

Christoph Moench-Tegeder <cmt@burggraben.net>

From: Christoph Moench-Tegeder <cmt@burggraben.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Anders Kaseorg <andersk@mit.edu>, Daniel Gustafsson <daniel@yesql.se>, Kyotaro Horiguchi <horikyota.ntt@gmail.com>, alvherre@alvh.no-ip.org, pgsql-hackers@lists.postgresql.org
Date: 2022-01-09T23:11:59Z
Lists: pgsql-hackers
## Tom Lane (tgl@sss.pgh.pa.us):

> Isn't that a flat out violation of POSIX 8.3 Other Environment Variables?
> 
>     HOME
>         The system shall initialize this variable at the time of login to
>         be a pathname of the user's home directory. See <pwd.h>.
> 
> To claim it's not, you have to claim these programs aren't logged in,
> in which case where did they get any privileges from?

After poking around across some Linuxes, it looks like people silently
agreed that "services" are not logged-in users: among the daemons,
having HOME set (as observed in /proc/*/environ) is an exception,
not the norm. I'm not sure if that's a "new" thing with systemd,
I don't have a linux with pure SysV-init available (but I guess those
are rare animals anyways).

Regards,
Christoph

-- 
Spare Space



Commits

  1. Clean up messy API for src/port/thread.c.

  2. Prefer $HOME when looking up the current user's home directory.