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 1oU4q6-0006jn-UZ for pgsql-general@arkaria.postgresql.org; Fri, 02 Sep 2022 11:27:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oU4q5-0008JR-QI for pgsql-general@arkaria.postgresql.org; Fri, 02 Sep 2022 11:27:57 +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 1oU4q5-0008JH-Fv for pgsql-general@lists.postgresql.org; Fri, 02 Sep 2022 11:27:57 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oU4q3-0002Jk-0V for pgsql-general@lists.postgresql.org; Fri, 02 Sep 2022 11:27:57 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 61B2979F9; Fri, 2 Sep 2022 13:27:54 +0200 (CEST) Date: Fri, 2 Sep 2022 13:27:54 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: How to make PostreSQL utilities honor home directories? Message-ID: <20220902112754.2e7fnrclod73d2sh@hjp.at> Mail-Followup-To: pgsql-general@lists.postgresql.org References: <780195.1662070574@sss.pgh.pa.us> <20220902002307.qrxhyeexronkdgsr@hjp.at> <810388.1662079862@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="bsq3n23ofbb2ozmn" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --bsq3n23ofbb2ozmn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2022-09-01 21:10:44 -0700, Adrian Klaver wrote: > On 9/1/22 6:31 PM, Jeffrey Walton wrote: > > On Thu, Sep 1, 2022 at 8:51 PM Tom Lane wrote: > > > 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 runni= ng > > > as the same user as the server. > >=20 > > The use case is an install of DefectDojo [2]. I _think_ they are > > taking advantage of the fact that as root, you don't need to > > authenticate because of postgresql's use of domain sockets. (Hat tip > > for that, by the way). The installer code will install packages, setup > > the database, install the DefectDojo programs, etc. >=20 > You are not running as root(Postgres won't allow you do this anyway) you = are > running as postgres system user and the authentication is handled by > pg_hba.conf. I'm also betting that if you look at pg_hba.conf it is set up > to do peer authentication and hence the need to be postgres system user. = You > can obtain a similar result in pg_hba.conf with: >=20 > TYPE DATABASE USER ADDRESS METHOD > local all postgres trust >=20 > Then you could eliminate the whole sudo dance. OTOH it allows any user on the machine to connect as postgres, which may or may not be a problem. I like to use ident for local connections: # TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all ident map= =3Dlocalusers and in pg_ident.conf: # MAPNAME SYSTEM-USERNAME PG-USERNAME localusers root postgres Then root can invoke `psql -U postgres ...`, but other users can't. hp --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --bsq3n23ofbb2ozmn Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmMR6LUACgkQ8g5IURL+ KF2jcg/9E4ipnnaZhISLnPmPO8CkNGhVf9uLP2pQ+TMgSu5AqyT3V66HtvvEsInJ a5wP2wzGQm0ASGbdlqqD2coK7nhgubuBnLFy3Zgrw44bstATSBQAMDNGAISWdjAp wJZrJuXqmBsuNOGJFY7ZspcJa5rzbVJkXYe6nb+m6LX/1K/h/7G56Lhss+v3Ct+H pH9epJUA4E5xwFgDrjfDhA5+iB4rhWLTwYFzDT+RTC707DhiZU28MEfKTkIA99Jx 9EnnGVh2osC15pru6QZ0kAdPWEPZQNdRgv1SRJKHwiNFI06dHYPkfZhDVvwTeNbs rH2P8ykJ6VG+D8esLDzY5s98hKfH4jqWvQHZt74NtFPbegeIFyt+Tnc4eVLTRXPW KgUlyfn6ER8Po+tznSUR3AchDFM+Xu86V03X9IxChChALvrzzoq5KX7EHDGoLfty Pfkc1bA39UWygL/kT7hLr5XrUMD/Y5usrDf2LnoGUTweRsBKxhKC5VQ+3P1JrYJM kBAo1RfqqnDSBZQewhzMEM11eFqEutLfPoo3O/IyXCscYNxYw7gpG3wSKnO7MVjp WXdwHzomk0kLOJEm63CFMUl6rkOeHbn7zTSO06PHqS20e27F9aNvHh9rRLyOko6Z kCAXHbObuwV7APKb/qyvlSJqfTFJ3c00o8b/yGOhehKGraYkgfY= =Q+SS -----END PGP SIGNATURE----- --bsq3n23ofbb2ozmn--