From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Bryn Llewellyn <bryn@yugabyte.com>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-general list <pgsql-general@lists.postgresql.org>
Subject: Re: Seeking practice recommendation: is there ever a use case to have two or more superusers?
Date: Mon, 21 Nov 2022 16:30:36 -0800
Message-ID: <f15f95a2-e29d-80ac-0e8b-e7097ae84a87@aklaver.com> (raw)
In-Reply-To: <C731B85D-8E5E-485D-9D4E-84C2563102D6@yugabyte.com>
References: <290EF7B8-D150-4AE1-8FFE-A38912CD1A8B@yugabyte.com>
<20221118200835.sgva7b6wgg4w7py7@hjp.at>
<0B653B38-2D7D-45D6-B87F-DD07200EA676@yugabyte.com>
<20221118221305.ku2ibj2bowahzn2y@hjp.at>
<11d24370-18c6-f736-85db-e9ae1814bb64@gmail.com>
<20221119085225.uivmxue2gef5utv2@hjp.at>
<40623F5C-5B99-4AFD-9AA6-ABFFE6B17606@yugabyte.com>
<6f5bb172-eea8-3456-60ab-0dd332b89d56@aklaver.com>
<Y3tQE9zy4IZU5KEZ@hermes.hilbert.loc>
<4380c01d-a182-8c13-f4e2-278ba8a3cf01@aklaver.com>
<9B82247D-3F56-47C1-A918-18E2E8DEDFAB@yugabyte.com>
<d51cebb0-d12a-7238-bad8-d31bdc60e84e@aklaver.com>
<487898A1-46F5-4351-9BEA-D7170BDBC9D5@yugabyte.com>
<db7dc42f-e91b-e7f6-f2e2-eddb58d200e9@aklaver.com>
<C731B85D-8E5E-485D-9D4E-84C2563102D6@yugabyte.com>
On 11/21/22 15:05, Bryn Llewellyn wrote:
>> adrian.klaver@aklaver.com wrote:
>> ...why the "Nobody supports it!" statement for a recommendation that only appeared at the same time? I for one have a poor record of mind reading and/or predicting the future:)
>
> Here’s what I wrote in the post that started this thread, archived at this URL:
>
> https://www.postgresql.org/message-id/290EF7B8-D150-4AE1-8FFE-A38912CD1A8B@yugabyte.com
>
>> The implication is clear: you should allow a cluster to have just a single superuser, the inevitable bootstrap superuser, and you should think very carefully indeed before ever starting a session as this role because of the risks that doing so brings. Rather, you should realize that there are hardly any tasks that cannot be carried out by an appropriately configured role with "nosuperuser”.
>
>
> The essential content of each (what I wrote in my opening post and what stands between « ... » above) is the same: allow maximum one superuser. Each is a strawman. And, as such, carries its own implicit invitation for challenge or support. The outcome was all challenge and no support. I don’t know why observing that this was the outcome has, itself, become controversial.
You must be reading a different thread. What I saw in the replies was
people answering '...is there ever a use case to have two or more
superusers?' with, maybe but in the end it is up to you to decide what
works in your case.
>
> In fact, David Johnston did unequivocally challenge my strawman a couple of turns back, thus:
>
>> no one is supposed to login to the database cluster using the postgres role. Period. Upon initialization whomever is responsible for creating the cluster gets their personal user credentials installed into the cluster as superuser and from that point on never uses postgres.
You left out the preface to the above, 'My policy would be that ...`
And the equivocal additions later in the post:
"I suppose the suggestion I would be willing to consider is: only have
the postgres superuser, never grant superuser to login roles explicitly,
instead if those persons require superuser grant them membership in the
postgres role."
and
"
So yes I, like everyone else, is going to end up forming their own
generalities. Ideas that I cannot wholly discredit as bad, but that
don't fit into my generality, get the "if the specific circumstances
warrant it" treatment. My own presuppositions ultimately should get the
same treatment by whomever is implementing such policies."
>
>
> That’s actionable advice. I mentioned that I had implemented that scheme and then, later, abandoned it. I can easily re-implement it.
>
> Because PG allows a cluster to have as many superusers as you please, and because any one of these can create or drop another, any convention in this space needs some extra mechanisms to enforce it..
>
> I believe that the fact that a superuser's ability to start a session can be limited by what the "hba_file" says is critical here—together with the fact that the ability to edit this file is governed by the regime of O/S users and file privileges. Maybe this is the key to the effectively tamper-proof implementation of the scheme that David recommends. (Having said this, there's always the "set role" backdoor.)
>
> There's also the caveat that a "drop" attempt by a superuser for a single object owned by the bootstrap superuser (say, the "pg_catalog.pg_terminate_backend()" function) in some database causes an error with the message "cannot drop function... because it is required by the database system". (At least, this is what my tests have shown with a smallish sample of drop targets.) This seems to be a Very Good Thing. But the fact that this is the behavior makes me wonder what harm can be done by a session that authorizes as the bootstrap superuser that cannot be done by a session that authorizes as a regular superuser. I'll try to find out.
Superuser is superuser, there is no magic associated with the bootstrap
superuser.
FYI, the answer is won't make a difference.
--
Adrian Klaver
adrian.klaver@aklaver.com
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: adrian.klaver@aklaver.com, bryn@yugabyte.com, david.g.johnston@gmail.com
Subject: Re: Seeking practice recommendation: is there ever a use case to have two or more superusers?
In-Reply-To: <f15f95a2-e29d-80ac-0e8b-e7097ae84a87@aklaver.com>
References: <290EF7B8-D150-4AE1-8FFE-A38912CD1A8B@yugabyte.com> <20221118200835.sgva7b6wgg4w7py7@hjp.at> <0B653B38-2D7D-45D6-B87F-DD07200EA676@yugabyte.com> <20221118221305.ku2ibj2bowahzn2y@hjp.at> <11d24370-18c6-f736-85db-e9ae1814bb64@gmail.com> <20221119085225.uivmxue2gef5utv2@hjp.at> <40623F5C-5B99-4AFD-9AA6-ABFFE6B17606@yugabyte.com> <6f5bb172-eea8-3456-60ab-0dd332b89d56@aklaver.com> <Y3tQE9zy4IZU5KEZ@hermes.hilbert.loc> <4380c01d-a182-8c13-f4e2-278ba8a3cf01@aklaver.com> <9B82247D-3F56-47C1-A918-18E2E8DEDFAB@yugabyte.com> <d51cebb0-d12a-7238-bad8-d31bdc60e84e@aklaver.com> <487898A1-46F5-4351-9BEA-D7170BDBC9D5@yugabyte.com> <db7dc42f-e91b-e7f6-f2e2-eddb58d200e9@aklaver.com> <C731B85D-8E5E-485D-9D4E-84C2563102D6@yugabyte.com> <f15f95a2-e29d-80ac-0e8b-e7097ae84a87@aklaver.com>
* 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