Skip to content

Allow neon_superuser to create event triggers #475

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

Open
wants to merge 1 commit into
base: REL_16_STABLE_neon
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/backend/commands/event_trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ CreateEventTrigger(CreateEventTrigStmt *stmt)
* this, but there are obvious privilege escalation risks which would have
* to somehow be plugged first.
*/
if (!superuser())
if (!superuser() && !is_neon_superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("permission denied to create event trigger \"%s\"",
Expand Down
7 changes: 0 additions & 7 deletions src/backend/commands/publicationcmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,13 +728,6 @@ CheckPubRelationColumnList(char *pubname, List *tables,
}
}

static bool
is_neon_superuser(void)
{
Oid neon_superuser_oid = get_role_oid("neon_superuser", true /*missing_ok*/);
return neon_superuser_oid != InvalidOid && has_privs_of_role(GetUserId(), neon_superuser_oid);
}

/*
* Create new publication.
*/
Expand Down
13 changes: 13 additions & 0 deletions src/backend/utils/adt/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ static AclResult pg_role_aclcheck(Oid role_oid, Oid roleid, AclMode mode);

static void RoleMembershipCacheCallback(Datum arg, int cacheid, uint32 hashvalue);

bool
is_neon_superuser(void)
{
return is_neon_superuser_arg(GetUserId());
}

bool
is_neon_superuser_arg(Oid roleid)
{
Oid neon_superuser_oid = get_role_oid("neon_superuser", true /*missing_ok*/);
return neon_superuser_oid != InvalidOid && has_privs_of_role(roleid, neon_superuser_oid);
}


/*
* getid
Expand Down
3 changes: 3 additions & 0 deletions src/include/miscadmin.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@ extern const char *GetSystemUser(void);
extern bool superuser(void); /* current user is superuser */
extern bool superuser_arg(Oid roleid); /* given user is superuser */

/* in utils/adt/acl.c */
extern bool is_neon_superuser(void); /* current user is neon_superuser */
extern bool is_neon_superuser_arg(Oid roleid); /* given user is neon_superuser */

/*****************************************************************************
* pmod.h -- *
Expand Down