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 1oTutw-0002Q1-Uv for pgsql-general@arkaria.postgresql.org; Fri, 02 Sep 2022 00:51:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oTutv-0004J8-NV for pgsql-general@arkaria.postgresql.org; Fri, 02 Sep 2022 00:51:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oTutv-0004Iy-DH for pgsql-general@lists.postgresql.org; Fri, 02 Sep 2022 00:51:15 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oTuts-0005RZ-SW for pgsql-general@lists.postgresql.org; Fri, 02 Sep 2022 00:51:14 +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 2820p2nM810389; Thu, 1 Sep 2022 20:51:02 -0400 From: Tom Lane To: "Peter J. Holzer" cc: pgsql-general@lists.postgresql.org Subject: Re: How to make PostreSQL utilities honor home directories? In-reply-to: <20220902002307.qrxhyeexronkdgsr@hjp.at> References: <780195.1662070574@sss.pgh.pa.us> <20220902002307.qrxhyeexronkdgsr@hjp.at> Comments: In-reply-to "Peter J. Holzer" message dated "Fri, 02 Sep 2022 02:23:07 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <810387.1662079862.1@sss.pgh.pa.us> Date: Thu, 01 Sep 2022 20:51:02 -0400 Message-ID: <810388.1662079862@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "Peter J. Holzer" writes: > However, the symlink doesn't seem to be the culprit. If I run > % sudo -u postgres -H /usr/lib/postgresql/13/bin/psql > (which is not a symlink) > I get the same behaviour. So it seems that psql changes to its basedir > and then can't change back again. Ah --- looking closer at that code, it will chdir *before* checking whether the target file is a symlink, which is probably unnecessarily stupid. I'm wondering whether we could drop that logic altogether [1], but that won't help you today. I concur with the other person asking why you want to sudo to postgres at all, though. It's generally safest if the client side isn't running as the same user as the server. regards, tom lane [1] https://www.postgresql.org/message-id/797232.1662075573%40sss.pgh.pa.us