From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: How to make PostreSQL utilities honor home directories?
Date: Fri, 2 Sep 2022 13:27:54 +0200
Message-ID: <20220902112754.2e7fnrclod73d2sh@hjp.at> (raw)
In-Reply-To: <ea685213-835c-8ffe-c806-69e2062ffdbe@aklaver.com>
References: <CAH8yC8kOj0pmHF1RbK2Gb2t4YCcNG-5h0TwZ7yxk3Hzw6C0Otg@mail.gmail.com>
<780195.1662070574@sss.pgh.pa.us>
<20220902002307.qrxhyeexronkdgsr@hjp.at>
<810388.1662079862@sss.pgh.pa.us>
<CAH8yC8=Y6wgEj47_n--eCKbEYMFP7H7LKACofVAQfM1JjTX3oQ@mail.gmail.com>
<ea685213-835c-8ffe-c806-69e2062ffdbe@aklaver.com>
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 <tgl@sss.pgh.pa.us> 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 running
> > > as the same user as the server.
> >
> > 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.
>
> 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:
>
> TYPE DATABASE USER ADDRESS METHOD
> local all postgres trust
>
> 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=localusers
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
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
Attachments:
signature.asc (application/pgp-signature, 832B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: hjp-pgsql@hjp.at
Subject: Re: How to make PostreSQL utilities honor home directories?
In-Reply-To: <20220902112754.2e7fnrclod73d2sh@hjp.at>
References: <CAH8yC8kOj0pmHF1RbK2Gb2t4YCcNG-5h0TwZ7yxk3Hzw6C0Otg@mail.gmail.com> <780195.1662070574@sss.pgh.pa.us> <20220902002307.qrxhyeexronkdgsr@hjp.at> <810388.1662079862@sss.pgh.pa.us> <CAH8yC8=Y6wgEj47_n--eCKbEYMFP7H7LKACofVAQfM1JjTX3oQ@mail.gmail.com> <ea685213-835c-8ffe-c806-69e2062ffdbe@aklaver.com> <20220902112754.2e7fnrclod73d2sh@hjp.at>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox