Skip to content

Commit

Permalink
Phase 3 of addressing style review comments
Browse files Browse the repository at this point in the history
Fix permissions for yb_super_admin
Fix errmsg for drop profile perms test
  • Loading branch information
vrajat authored and timothy-e committed Dec 13, 2022
1 parent 8bbe726 commit 59d7fbb
Show file tree
Hide file tree
Showing 11 changed files with 199 additions and 177 deletions.
11 changes: 10 additions & 1 deletion src/postgres/src/backend/catalog/objectaddress.c
Original file line number Diff line number Diff line change
Expand Up @@ -2469,7 +2469,6 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
case OBJECT_TSPARSER:
case OBJECT_TSTEMPLATE:
case OBJECT_ACCESS_METHOD:
case OBJECT_PROFILE:
/* We treat these object types as being owned by superusers */
if (!superuser_arg(roleid))
ereport(ERROR,
Expand All @@ -2480,6 +2479,16 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
if (!pg_statistics_object_ownercheck(address.objectId, roleid))
aclcheck_error_type(ACLCHECK_NOT_OWNER, address.objectId);
break;
case OBJECT_PROFILE:
/* A profile can be dropped by the super user or yb_db_admin */
if (!superuser() && !IsYbDbAdminUser(GetUserId()))
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("permission denied to drop profile"),
errhint("Must be superuser or "
"a member of the yb_db_admin")));
break;

default:
elog(ERROR, "unrecognized object type: %d",
(int) objtype);
Expand Down
4 changes: 2 additions & 2 deletions src/postgres/src/backend/commands/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ OBJS = amcmds.o aggregatecmds.o alter.o analyze.o async.o cluster.o comment.o \
dbcommands.o define.o discard.o dropcmds.o \
event_trigger.o explain.o extension.o foreigncmds.o functioncmds.o \
indexcmds.o lockcmds.o matview.o operatorcmds.o opclasscmds.o \
policy.o portalcmds.o prepare.o proclang.o profile.o publicationcmds.o \
policy.o portalcmds.o prepare.o proclang.o publicationcmds.o \
schemacmds.o seclabel.o sequence.o statscmds.o subscriptioncmds.o \
tablecmds.o tablespace.o tablegroup.o trigger.o tsearchcmds.o typecmds.o user.o \
vacuum.o vacuumlazy.o variable.o view.o ybccmds.o ybc_builtin.o
vacuum.o vacuumlazy.o variable.o view.o ybccmds.o ybc_builtin.o ybc_profile.o

include $(top_srcdir)/src/backend/common.mk
Loading

0 comments on commit 59d7fbb

Please sign in to comment.