Re: Delegating superuser tasks to new security roles (Was: Granting control of SUSET gucs to non-superusers)

From: Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, Jacob Champion <pchampion(at)vmware(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, "tgl(at)sss(dot)pgh(dot)pa(dot)us" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "chap(at)anastigmatix(dot)net" <chap(at)anastigmatix(dot)net>, torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>
Subject: Re: Delegating superuser tasks to new security roles (Was: Granting control of SUSET gucs to non-superusers)
Date: 2021-09-01 01:41:51
Message-ID: B0F7415A-776B-4C25-B670-B28AF433A31F@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Aug 27, 2021, at 3:47 PM, Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com> wrote:
>
> Making roles owners of roles they create, and giving them the power to manipulate objects which belong to roles they own (recursively), seems to solve most of our problems we have been discussing.

Not hearing any responses, this part is implemented in v6-0018 and v6-0019.

> The remaining problem is that roles without createrole or superuser cannot create other roles. We don't want tenants to need either of those things, at least not as they are currently defined. We could either modify the createrole privilege to be far less powerful, or create a new privilege.
>
> If role owners can alter and drop roles they own (and ones those roles own, etc.) then we could redefine CREATEROLE to really just mean the ability to create new roles. The ability to alter or drop roles would not stem from having CREATEROLE, but rather from owning the role. For setups where one admin role has CREATEROLE and creates all other roles (except the superuser which created the admin) nothing changes. In setups with multiple admins, where none own the others, each admin would have its own fiefdom, managing everything downstream from itself, but having no special privilege over the other fiefdoms. I think that setup wasn't implemented for 8.1 more for lack of time than because it was unwanted.

This really deserves more thought from the list. CREATEROLE's behavior is unchanged in this patch set.

> On Aug 23, 2021, at 11:13 AM, Stephen Frost <sfrost(at)snowman(dot)net> wrote:
>
>> Patches v5-0002 through v5-0005 create four new roles for managing host resource settings, vacuum settings, autovacuum settings, and logging settings. That last one excludes "where to log" settings, because we don't want the role to be able to write to arbitrary locations on the server. Remaining guc variables not in these four categories continue to belong to the superuser.
>
> We do have a role today who is allowed to write to arbitrary locations
> on the server, so I wonder if for those log settings we'd include a
> requirement for the user to have both of those roles instead..?

Following your advice, pg_manage_logging_settings + pg_write_server_files is made sufficient to set "where to log" settings in v6-0005.

Patches v6-0002 through v6-0005 add roles intended to allow tenants to set values for a limited number of appropriate guc variables. That seems fine for the purpose of facilitating postgres-as-a-service.

There is another reason to have roles with the power to SET or ALTER SYSTEM SET guc variables, though. For large deployments of postgres databases in the cloud, being able to log in as a non-superuser role in order to configure the database means having one fewer reasons to need to allow superuser connections to the server. That's valuable for its own sake.

Patches v6-0006 through v6-0012 add yet more roles with authority to set additional guc variables. They don't go quite so far as including all gucs, but the majority of gucs are covered, and we can add additional groupings if anybody has suggestions.

Attachment Content-Type Size
v6-0001-Allow-SET-and-ALTER-SYSTEM-SET-per-role.patch application/octet-stream 292.7 KB
v6-0002-Adding-role-pg_manage_host_resource_settings.patch application/octet-stream 227.4 KB
v6-0003-Adding-role-pg_manage_vacuum_settings.patch application/octet-stream 215.5 KB
v6-0004-Adding-role-pg_manage_autovacuum_settings.patch application/octet-stream 220.8 KB
v6-0005-Adding-role-pg_manage_logging_settings.patch application/octet-stream 218.3 KB
v6-0006-Adding-role-pg_manage_replication_settings.patch application/octet-stream 222.3 KB
v6-0007-Adding-role-pg_manage_connection_settings.patch application/octet-stream 221.5 KB
v6-0008-Adding-role-pg_manage_wal_settings.patch application/octet-stream 211.1 KB
v6-0009-Adding-role-pg_manage_query_tuning_settings.patch application/octet-stream 223.6 KB
v6-0010-Adding-role-pg_manage_stats_settings.patch application/octet-stream 227.0 KB
v6-0011-Adding-role-pg_manage_recovery_settings.patch application/octet-stream 217.9 KB
v6-0012-Adding-role-pg_manage_error_handling_settings.patch application/octet-stream 227.2 KB
v6-0013-Allow-event-trigger-ownership-by-non-superusers.patch application/octet-stream 5.1 KB
v6-0014-Condition-event-triggers-on-owning-role.patch application/octet-stream 7.0 KB
v6-0015-Handle-non-superuser-subscription-owners-sensibly.patch application/octet-stream 11.0 KB
v6-0016-Allow-subscription-ownership-by-non-superusers.patch application/octet-stream 4.9 KB
v6-0017-Respect-permissions-within-logical-replication.patch application/octet-stream 9.1 KB
v6-0018-Adding-owners-to-roles.patch application/octet-stream 11.3 KB
v6-0019-Giving-role-owners-control-over-owned-roles.patch application/octet-stream 9.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2021-09-01 01:52:17 Re: Postgres Win32 build broken?
Previous Message Michael Paquier 2021-09-01 01:33:15 Re: pgstat_send_connstats() introduces unnecessary timestamp and UDP overhead