Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c727f51

Browse files
committed
Refactor aclcheck functions
Instead of dozens of mostly-duplicate pg_foo_aclcheck() functions, write one common function object_aclcheck() 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 ACL column. There are a few pg_foo_aclcheck() that don't work via the generic function and have special APIs, so those stay as is. I also changed most pg_foo_aclmask() functions to static functions, since they are not used outside of aclchk.c. 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
1 parent afbfc02 commit c727f51

37 files changed

+319
-682
lines changed

contrib/dblink/dblink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2838,7 +2838,7 @@ get_connect_string(const char *servername)
28382838
fdw = GetForeignDataWrapper(fdwid);
28392839

28402840
/* Check permissions, user must have usage on the server. */
2841-
aclresult = pg_foreign_server_aclcheck(serverid, userid, ACL_USAGE);
2841+
aclresult = object_aclcheck(ForeignServerRelationId, serverid, userid, ACL_USAGE);
28422842
if (aclresult != ACLCHECK_OK)
28432843
aclcheck_error(aclresult, OBJECT_FOREIGN_SERVER, foreign_server->servername);
28442844

src/backend/access/common/tupdesc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ BuildDescForRelation(List *schema)
821821
attname = entry->colname;
822822
typenameTypeIdAndMod(NULL, entry->typeName, &atttypid, &atttypmod);
823823

824-
aclresult = pg_type_aclcheck(atttypid, GetUserId(), ACL_USAGE);
824+
aclresult = object_aclcheck(TypeRelationId, atttypid, GetUserId(), ACL_USAGE);
825825
if (aclresult != ACLCHECK_OK)
826826
aclcheck_error_type(aclresult, atttypid);
827827

0 commit comments

Comments
 (0)