Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n6fMP-0005lV-2J for pgsql-hackers@arkaria.postgresql.org; Sun, 09 Jan 2022 21:04:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n6fMN-0001i0-QM for pgsql-hackers@arkaria.postgresql.org; Sun, 09 Jan 2022 21:04:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n6fMN-0001hp-Gn for pgsql-hackers@lists.postgresql.org; Sun, 09 Jan 2022 21:04:15 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n6fML-0007Vr-35 for pgsql-hackers@lists.postgresql.org; Sun, 09 Jan 2022 21:04:15 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 209L476F1796240; Sun, 9 Jan 2022 16:04:07 -0500 From: Tom Lane To: Anders Kaseorg cc: Daniel Gustafsson , Kyotaro Horiguchi , alvherre@alvh.no-ip.org, pgsql-hackers@lists.postgresql.org Subject: Re: [PATCH] Prefer getenv("HOME") to find the UNIX home directory In-reply-to: References: <202110182223.zeze33l55qa5@alvherre.pgsql> <20211019.173422.706584612464055211.horikyota.ntt@gmail.com> <5d675cbe-7837-e9ae-961d-be7d03201f3b@mit.edu> <20211020.144014.580443822870543857.horikyota.ntt@gmail.com> <07CA67A0-A46C-4ED5-99C6-24D41BDDC8CA@yesql.se> <1769427.1641754742@sss.pgh.pa.us> Comments: In-reply-to Anders Kaseorg message dated "Sun, 09 Jan 2022 12:50:54 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <1796238.1641762247.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Sun, 09 Jan 2022 16:04:07 -0500 Message-ID: <1796239.1641762247@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Anders Kaseorg writes: > 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 only case that the v1 patch helps such a user for is if they unset HOME or set it precisely to ''. If they set it to anything else, it's still broken from their perspective. So I do not find that that argument holds water. Moreover, ISTM that the only plausible use-case for unsetting HOME is to prevent programs from finding stuff in your home directory. What would be the point otherwise? So it's pretty hard to envision a case where somebody is actually using, and happy with, the behavior you argue we ought to keep. >> The v1 patch also neglects the matter of documentation. > The reason I didn’t change the documentation is that this is already > what “~” is supposed to mean according to POSIX and common > implementations. The point here is precisely that we're changing what *we* think ~ means. I don't think we can just leave the docs unchanged. regards, tom lane