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 1oTsU5-0007ym-IY for pgsql-general@arkaria.postgresql.org; Thu, 01 Sep 2022 22:16:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oTsU3-0002tI-Ju for pgsql-general@arkaria.postgresql.org; Thu, 01 Sep 2022 22:16:23 +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 1oTsU3-0002t8-91 for pgsql-general@lists.postgresql.org; Thu, 01 Sep 2022 22:16:23 +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 1oTsTw-0004Cv-QY for pgsql-general@lists.postgresql.org; Thu, 01 Sep 2022 22:16:22 +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 281MGEEp780196; Thu, 1 Sep 2022 18:16:14 -0400 From: Tom Lane To: noloader@gmail.com cc: pgsql-general@lists.postgresql.org Subject: Re: How to make PostreSQL utilities honor home directories? In-reply-to: References: Comments: In-reply-to Jeffrey Walton message dated "Thu, 01 Sep 2022 18:01:02 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <780194.1662070574.1@sss.pgh.pa.us> Date: Thu, 01 Sep 2022 18:16:14 -0400 Message-ID: <780195.1662070574@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Jeffrey Walton writes: > We are having a heck of a time getting PostreSQL utilities to honor > home directories. For example, when I execute this script: > sudo -H -u postgres PGPASSWORD=${password} \ > psql -h "${hostname}" -U "${username}" -d "${database}" \ > --command="..." > It produces failures: > could not change directory to "/home/jwalton/godojo": Permission denied You've left out quite a lot of information here ... like what connection that directory has to do with anything. Is it your current directory when you invoke this command? If so, a plausible explanation is that psql is trying to chase a symlink to somewhere, which involves some chdir's so it can resolve the symlink correctly, and afterwards it has to change back to where it started --- which would fail if it can't look up that directory. Why it's trying to resolve a symlink isn't apparent though. Is the "psql" you're invoking a symlink to somewhere? regards, tom lane