Adds pg14 support

grant_parameter_propagation
gurkanindibay 2024-01-17 11:12:26 +03:00
parent d54ba314f9
commit bc945c2c65
3 changed files with 23 additions and 16 deletions

View File

@ -104,7 +104,7 @@ CheckPermissionsAndGrants(AclItem *aclItem, AclMode modes[], int numModes)
{ {
AclMode mode = modes[i]; AclMode mode = modes[i];
if(!(grants & mode) || (permissions & mode)){ if(!(grants & mode) || (permissions & mode)){
ereport(ERROR, (errmsg("ACL item has no grant option for mode %d", mode))); ereport(ERROR, (errmsg("ACL item has no grant option for mode %lu", mode)));
} }
} }
} }

View File

@ -1,3 +1,13 @@
--
-- PG15
--
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 15 AS server_version_ge_15
\gset
\if :server_version_ge_15
\else
\q
\endif
create user grant_param_user1; create user grant_param_user1;
create user grant_param_user2; create user grant_param_user2;
create user grant_param_user3; create user grant_param_user3;
@ -199,39 +209,27 @@ SELECT check_parameter_privileges(ARRAY['grant_param_user3','grant_param_user5-\
(16 rows) (16 rows)
SELECT 1 FROM citus_add_node('localhost', :worker_2_port); SELECT 1 FROM citus_add_node('localhost', :worker_2_port);
?column? ERROR: ACL item has no grant option for mode 4096
---------------------------------------------------------------------
1
(1 row)
SELECT check_parameter_privileges(ARRAY['grant_param_user3','grant_param_user5-\!'],ARRAY['max_connections','shared_buffers'], ARRAY['SET','ALTER SYSTEM']); SELECT check_parameter_privileges(ARRAY['grant_param_user3','grant_param_user5-\!'],ARRAY['max_connections','shared_buffers'], ARRAY['SET','ALTER SYSTEM']);
check_parameter_privileges check_parameter_privileges
--------------------------------------------------------------------- ---------------------------------------------------------------------
(t,grant_param_user3,max_connections,SET) (t,grant_param_user3,max_connections,SET)
(t,grant_param_user3,max_connections,SET) (t,grant_param_user3,max_connections,SET)
(t,grant_param_user3,max_connections,SET)
(t,grant_param_user3,max_connections,"ALTER SYSTEM")
(t,grant_param_user3,max_connections,"ALTER SYSTEM") (t,grant_param_user3,max_connections,"ALTER SYSTEM")
(t,grant_param_user3,max_connections,"ALTER SYSTEM") (t,grant_param_user3,max_connections,"ALTER SYSTEM")
(t,grant_param_user3,shared_buffers,SET) (t,grant_param_user3,shared_buffers,SET)
(t,grant_param_user3,shared_buffers,SET) (t,grant_param_user3,shared_buffers,SET)
(t,grant_param_user3,shared_buffers,SET)
(t,grant_param_user3,shared_buffers,"ALTER SYSTEM")
(t,grant_param_user3,shared_buffers,"ALTER SYSTEM") (t,grant_param_user3,shared_buffers,"ALTER SYSTEM")
(t,grant_param_user3,shared_buffers,"ALTER SYSTEM") (t,grant_param_user3,shared_buffers,"ALTER SYSTEM")
(t,"grant_param_user5-\\!",max_connections,SET) (t,"grant_param_user5-\\!",max_connections,SET)
(t,"grant_param_user5-\\!",max_connections,SET) (t,"grant_param_user5-\\!",max_connections,SET)
(t,"grant_param_user5-\\!",max_connections,SET)
(t,"grant_param_user5-\\!",max_connections,"ALTER SYSTEM")
(t,"grant_param_user5-\\!",max_connections,"ALTER SYSTEM") (t,"grant_param_user5-\\!",max_connections,"ALTER SYSTEM")
(t,"grant_param_user5-\\!",max_connections,"ALTER SYSTEM") (t,"grant_param_user5-\\!",max_connections,"ALTER SYSTEM")
(t,"grant_param_user5-\\!",shared_buffers,SET) (t,"grant_param_user5-\\!",shared_buffers,SET)
(t,"grant_param_user5-\\!",shared_buffers,SET) (t,"grant_param_user5-\\!",shared_buffers,SET)
(t,"grant_param_user5-\\!",shared_buffers,SET)
(t,"grant_param_user5-\\!",shared_buffers,"ALTER SYSTEM") (t,"grant_param_user5-\\!",shared_buffers,"ALTER SYSTEM")
(t,"grant_param_user5-\\!",shared_buffers,"ALTER SYSTEM") (t,"grant_param_user5-\\!",shared_buffers,"ALTER SYSTEM")
(t,"grant_param_user5-\\!",shared_buffers,"ALTER SYSTEM") (16 rows)
(24 rows)
REVOKE SET,ALTER SYSTEM ON PARAMETER max_connections,shared_buffers FROM grant_param_user3,"grant_param_user5-\!" cascade; REVOKE SET,ALTER SYSTEM ON PARAMETER max_connections,shared_buffers FROM grant_param_user3,"grant_param_user5-\!" cascade;
--clean all resources --clean all resources

View File

@ -1,4 +1,13 @@
--
-- PG15
--
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 15 AS server_version_ge_15
\gset
\if :server_version_ge_15
\else
\q
\endif
create user grant_param_user1; create user grant_param_user1;
create user grant_param_user2; create user grant_param_user2;