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

From: Anders Kaseorg <andersk(at)mit(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: 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-09 20:50:54
Message-ID: fafa1aed-42f5-fecb-324c-06f5d5301f11@mit.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 1/9/22 10:59, Tom Lane wrote:
> Given the POSIX requirements, it's basically impossible to believe
> that there are interesting cases where $HOME isn't set. Thus, it
> seems to me that keeping the getpwuid calls will just mean carrying
> untestable dead code, so we should simplify matters by ripping
> those out and *only* consulting $HOME.

While POSIX requires that the login program put you in a conforming
environment, nothing stops the user from building a non-conforming
environment, such as with ‘env -i’. One could argue that such a user
deserves whatever broken behavior they might get. But to me it seems
prudent to continue working there if it worked before.

> The v1 patch also neglects the matter of documentation. I think
> the simplest and most transparent thing to do is just to explicitly
> mention $HOME everyplace we talk about files that are sought there,
> in place of our current convention to write "~". (I'm too lazy
> to go digging in the git history, but I have a feeling that this is
> undoing somebody's intentional change from a long time back.)

The reason I didn’t change the documentation is that this is already
what “~” is supposed to mean according to POSIX and common
implementations. See previous discussion:

https://www.postgresql.org/message-id/1634252654444.90107%40mit.edu
https://www.postgresql.org/message-id/d452fd57-8c34-0a94-79c1-4498eb4ffbdc%40mit.edu

I consider my patch a bug fix that implements the behavior one would
already expect from the existing documentation.

Therefore, I still prefer my v1 patch on both counts. I am willing to
be overruled if you still disagree, but I wanted to explain my reasoning.

Anders

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-01-09 21:04:07 Re: [PATCH] Prefer getenv("HOME") to find the UNIX home directory
Previous Message Zhihong Yu 2022-01-09 20:38:23 Re: null iv parameter passed to combo_init()