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 1oTtJc-0003KR-UP for pgsql-general@arkaria.postgresql.org; Thu, 01 Sep 2022 23:09:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oTtJb-00087i-O3 for pgsql-general@arkaria.postgresql.org; Thu, 01 Sep 2022 23:09:39 +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 1oTtJb-00087X-DX for pgsql-general@lists.postgresql.org; Thu, 01 Sep 2022 23:09:39 +0000 Received: from uucp.dinoex.org ([2a0b:f840::12]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oTtJY-0004hJ-Do for pgsql-general@lists.postgresql.org; Thu, 01 Sep 2022 23:09:38 +0000 Received: from uucp.dinoex.org (uucp.dinoex.org [IPv6:2a0b:f840:0:0:0:0:0:12]) by uucp.dinoex.org (8.17.1/8.17.1) with ESMTPS id 281N99iZ050785 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 2 Sep 2022 01:09:09 +0200 (CEST) (envelope-from pmc@citylink.dinoex.sub.org) Received: (from uucp@localhost) by uucp.dinoex.org (8.17.1/8.17.1/Submit) with UUCP id 281N998h050784; Fri, 2 Sep 2022 01:09:09 +0200 (CEST) (envelope-from pmc@citylink.dinoex.sub.org) Received: from disp.intra.daemon.contact (disp-e.intra.daemon.contact [IPv6:fd00:0:0:0:0:0:0:112]) by admn.intra.daemon.contact (8.16.1/8.16.1) with ESMTPS id 281N6C9R059635 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=OK); Fri, 2 Sep 2022 01:06:13 +0200 (CEST) (envelope-from pmc@citylink.dinoex.sub.org) Received: from disp.intra.daemon.contact (localhost [127.0.0.1]) by disp.intra.daemon.contact (8.16.1/8.16.1) with ESMTPS id 281N4Cnu013352 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 2 Sep 2022 01:04:15 +0200 (CEST) (envelope-from pmc@citylink.dinoex.sub.org) Received: (from pmc@localhost) by disp.intra.daemon.contact (8.16.1/8.16.1/Submit) id 281N4CZV013351; Fri, 2 Sep 2022 01:04:12 +0200 (CEST) (envelope-from pmc@citylink.dinoex.sub.org) X-Authentication-Warning: disp.intra.daemon.contact: pmc set sender to pmc@citylink.dinoex.sub.org using -f Date: Fri, 2 Sep 2022 01:04:12 +0200 From: Peter To: Jeffrey Walton Cc: pgsql-general@lists.postgresql.org Subject: Re: How to make PostreSQL utilities honor home directories? Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Milter: Spamilter (Reciever: uucp.dinoex.org; Sender-ip: 0:0:2a0b:f840::; Sender-helo: uucp.dinoex.org;) X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (uucp.dinoex.org [IPv6:2a0b:f840:0:0:0:0:0:12]); Fri, 02 Sep 2022 01:09:11 +0200 (CEST) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Well, like others mentioned before, it is not getting fully clear what You are trying to achieve. But, in any case, if this is Your problem .... On Thu, Sep 01, 2022 at 06:01:02PM -0400, Jeffrey Walton wrote: ! Hi Everyone, ! ! 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 ... this appears to me as rather a sudo issue. Because certainly psql cannot execute /as user postgres/ in a directory where user postgres is not allowed to enter. So sudo should fix that, and in my sudo installation I find either a "-D directory" option for sudo (that should change the directory accordingly) or a "--login" option (that would run a full login shell for the user postgres, which, alongside going to the postgres homedir, does a lot of other things which may or may not be desireable in your installation).