Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using event triggers without SUPERUSER #67

Open
steve-chavez opened this issue Dec 7, 2023 · 4 comments
Open

Allow using event triggers without SUPERUSER #67

steve-chavez opened this issue Dec 7, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@steve-chavez
Copy link
Member

steve-chavez commented Dec 7, 2023

Problem

Currently there's no way to use event triggers. RDS allows it though, see https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/PostgreSQL.Concepts.General.FeatureSupport.EventTriggers.html. Caveat: the user must delete event triggers when migrating to a new major postgres version.

References:

Solution

Allow event triggers for non superusers.

@steve-chavez steve-chavez added the enhancement New feature or request label Dec 7, 2023
@steve-chavez steve-chavez self-assigned this Dec 7, 2023
@steve-chavez steve-chavez removed their assignment May 16, 2024
@steve-chavez
Copy link
Member Author

I gave this a shot but I was surprised to find privileged_role is not used for creating privileged extensions. There's a privileged_extensions_superuser that's used for switching to superuser.

@soedirgo Which role should we switch to create the event trigger? Why privileged_role wasn't used for extensions?

@steve-chavez
Copy link
Member Author

Here it says privileged_role but privileged_extensions_superuser is used for the switch:

supautils/src/supautils.c

Lines 284 to 286 in fa39431

// Allow `privileged_role` (in addition to superusers) to
// set bypassrls & replication attributes.
switch_to_superuser(privileged_extensions_superuser, &already_switched_to_superuser);

@soedirgo What's the relationship between these 2 roles?

@soedirgo
Copy link
Member

privileged_role is named as such because from the user's perspective it's the role that can do certain superuser-only actions (hence "privileged"). But under the hood some of it is achieved by switching to a superuser when performing the action.

Agree that privileged_extensions_superuser is confusing though - we should rename them to supautils.superuser in the future, since it's not only used for creating privileged_extensions.

@soedirgo
Copy link
Member

Before you go ahead with the implementation, keep in mind that simply switching to a superuser to perform the CREATE EVENT TRIGGER, similar to how we do it for FDWs etc., wouldn't work since it opens a door for privilege escalation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants