From: | Steve Chavez <steve(at)supabase(dot)io> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Allow database owners to CREATE EVENT TRIGGER |
Date: | 2025-03-05 01:16:17 |
Message-ID: | CAGRrpzbtYDkg7_xwfzrqByYgCJQbbL38tADyuN+6tAkbA-Pnkg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello hackers,
Currently PostgreSQL only allows creating event triggers for superusers,
this prevents usage on PostgreSQL service providers, which do not grant
superuser access.
This patch allows database owners to create event triggers, while
preventing privilege escalation.
Unlike superuser event triggers, which execute functions for every role,
database owner event triggers are only executed for non-superusers.
This is necessary to prevent privesc. i.e. a superuser tripping on an event
trigger containing an `ALTER ROLE dbowner SUPERUSER`.
For skipping dbowner event triggers for superusers:
- A restriction is added for superuser event triggers, the event trigger
function must be owned by a superuser.
+ While this is a breaking change, I think it's minor as the usual flow
is to "login as superuser" -> "create an evtrig function" -> "create the
evtrig". This is also proved by the existing tests, which barely change.
- A restriction is added for dbowner event triggers, the event trigger
function must not be owned by a superuser.
This way we can filter dbowner event trigger functions inside
`EventTriggerInvoke`.
Tests are included in the patch, I've added a dedicated regression file for
easier review. Only a couple of error messages of the existing event
trigger regression tests are changed.
Any feedback is welcomed. I haven't added docs yet but I'll gladly add them
if the community thinks this patch makes sense.
(Previous thread that also discussed allowing event triggers for
non-superusers:
https://www.postgresql.org/message-id/flat/81C10FFB-5ADC-4956-9337-FA248A4CC20D%40enterprisedb.com#77738d12b82c9a403ea2c56ed09949a3
)
Best regards,
Steve Chavez
Attachment | Content-Type | Size |
---|---|---|
0001-Allow-database-owners-to-CREATE-EVENT-TRIGGER.patch | text/x-patch | 11.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2025-03-05 01:20:51 | Re: per backend WAL statistics |
Previous Message | Mahendra Singh Thalor | 2025-03-05 01:12:02 | Re: Non-text mode for pg_dumpall |