mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Refactor ownercheck functions
Instead of dozens of mostly-duplicate pg_foo_ownercheck() functions, write one common function object_ownercheck() that can handle almost all of them. We already have all the information we need, such as which system catalog corresponds to which catalog table and which column is the owner column. Reviewed-by: Corey Huinker <corey.huinker@gmail.com> Reviewed-by: Antonin Houska <ah@cybertec.at> Discussion: https://www.postgresql.org/message-id/flat/95c30f96-4060-2f48-98b5-a4392d3b6066@enterprisedb.com
This commit is contained in:
@ -956,7 +956,7 @@ AlterRoleSet(AlterRoleSetStmt *stmt)
|
||||
* If no role is specified, then this is effectively the same as
|
||||
* ALTER DATABASE ... SET, so use the same permission check.
|
||||
*/
|
||||
if (!pg_database_ownercheck(databaseid, GetUserId()))
|
||||
if (!object_ownercheck(DatabaseRelationId, databaseid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_DATABASE,
|
||||
stmt->database);
|
||||
}
|
||||
@ -1586,7 +1586,7 @@ AddRoleMems(const char *rolename, Oid roleid,
|
||||
* The charter of pg_database_owner is to have exactly one, implicit,
|
||||
* situation-dependent member. There's no technical need for this
|
||||
* restriction. (One could lift it and take the further step of making
|
||||
* pg_database_ownercheck() equivalent to has_privs_of_role(roleid,
|
||||
* object_ownercheck(DatabaseRelationId, ...) equivalent to has_privs_of_role(roleid,
|
||||
* ROLE_PG_DATABASE_OWNER), in which case explicit, situation-independent
|
||||
* members could act as the owner of any database.)
|
||||
*/
|
||||
|
Reference in New Issue
Block a user