mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-17 03:47:01 +08:00
Reintroduce MAINTAIN privilege and pg_maintain predefined role.
Roles with MAINTAIN on a relation may run VACUUM, ANALYZE, REINDEX, REFRESH MATERIALIZE VIEW, CLUSTER, and LOCK TABLE on the relation. Roles with privileges of pg_maintain may run those same commands on all relations. This was previously committed for v16, but it was reverted in commit 151c22deee due to concerns about search_path tricks that could be used to escalate privileges to the table owner. Commits 2af07e2f74, 59825d1639, and c7ea3f4229 resolved these concerns by restricting search_path when running maintenance commands. Bumps catversion. Reviewed-by: Jeff Davis Discussion: https://postgr.es/m/20240305161235.GA3478007%40nathanxps13
This commit is contained in:
@ -57,6 +57,6 @@
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 202403091
|
||||
#define CATALOG_VERSION_NO 202403131
|
||||
|
||||
#endif
|
||||
|
||||
@ -84,6 +84,11 @@
|
||||
rolcreaterole => 'f', rolcreatedb => 'f', rolcanlogin => 'f',
|
||||
rolreplication => 'f', rolbypassrls => 'f', rolconnlimit => '-1',
|
||||
rolpassword => '_null_', rolvaliduntil => '_null_' },
|
||||
{ oid => '9256', oid_symbol => 'ROLE_PG_MAINTAIN',
|
||||
rolname => 'pg_maintain', rolsuper => 'f', rolinherit => 't',
|
||||
rolcreaterole => 'f', rolcreatedb => 'f', rolcanlogin => 'f',
|
||||
rolreplication => 'f', rolbypassrls => 'f', rolconnlimit => '-1',
|
||||
rolpassword => '_null_', rolvaliduntil => '_null_' },
|
||||
{ oid => '4550', oid_symbol => 'ROLE_PG_USE_RESERVED_CONNECTIONS',
|
||||
rolname => 'pg_use_reserved_connections', rolsuper => 'f', rolinherit => 't',
|
||||
rolcreaterole => 'f', rolcreatedb => 'f', rolcanlogin => 'f',
|
||||
|
||||
@ -98,8 +98,9 @@ extern void AtEOSubXact_on_commit_actions(bool isCommit,
|
||||
SubTransactionId mySubid,
|
||||
SubTransactionId parentSubid);
|
||||
|
||||
extern void RangeVarCallbackOwnsTable(const RangeVar *relation,
|
||||
Oid relId, Oid oldRelId, void *arg);
|
||||
extern void RangeVarCallbackMaintainsTable(const RangeVar *relation,
|
||||
Oid relId, Oid oldRelId,
|
||||
void *arg);
|
||||
|
||||
extern void RangeVarCallbackOwnsRelation(const RangeVar *relation,
|
||||
Oid relId, Oid oldRelId, void *arg);
|
||||
|
||||
@ -228,6 +228,7 @@ typedef struct VacuumParams
|
||||
* default */
|
||||
VacOptValue index_cleanup; /* Do index vacuum and cleanup */
|
||||
VacOptValue truncate; /* Truncate empty pages at the end */
|
||||
Oid toast_parent; /* for privilege checks when recursing */
|
||||
|
||||
/*
|
||||
* The number of parallel vacuum workers. 0 by default which means choose
|
||||
@ -343,8 +344,8 @@ extern bool vacuum_get_cutoffs(Relation rel, const VacuumParams *params,
|
||||
extern bool vacuum_xid_failsafe_check(const struct VacuumCutoffs *cutoffs);
|
||||
extern void vac_update_datfrozenxid(void);
|
||||
extern void vacuum_delay_point(void);
|
||||
extern bool vacuum_is_relation_owner(Oid relid, Form_pg_class reltuple,
|
||||
bits32 options);
|
||||
extern bool vacuum_is_permitted_for_relation(Oid relid, Form_pg_class reltuple,
|
||||
bits32 options);
|
||||
extern Relation vacuum_open_relation(Oid relid, RangeVar *relation,
|
||||
bits32 options, bool verbose,
|
||||
LOCKMODE lmode);
|
||||
|
||||
@ -87,7 +87,8 @@ typedef uint64 AclMode; /* a bitmask of privilege bits */
|
||||
#define ACL_CONNECT (1<<11) /* for databases */
|
||||
#define ACL_SET (1<<12) /* for configuration parameters */
|
||||
#define ACL_ALTER_SYSTEM (1<<13) /* for configuration parameters */
|
||||
#define N_ACL_RIGHTS 14 /* 1 plus the last 1<<x */
|
||||
#define ACL_MAINTAIN (1<<14) /* for relations */
|
||||
#define N_ACL_RIGHTS 15 /* 1 plus the last 1<<x */
|
||||
#define ACL_NO_RIGHTS 0
|
||||
/* Currently, SELECT ... FOR [KEY] UPDATE/SHARE requires UPDATE privileges */
|
||||
#define ACL_SELECT_FOR_UPDATE ACL_UPDATE
|
||||
|
||||
@ -148,15 +148,16 @@ typedef struct ArrayType Acl;
|
||||
#define ACL_CONNECT_CHR 'c'
|
||||
#define ACL_SET_CHR 's'
|
||||
#define ACL_ALTER_SYSTEM_CHR 'A'
|
||||
#define ACL_MAINTAIN_CHR 'm'
|
||||
|
||||
/* string holding all privilege code chars, in order by bitmask position */
|
||||
#define ACL_ALL_RIGHTS_STR "arwdDxtXUCTcsA"
|
||||
#define ACL_ALL_RIGHTS_STR "arwdDxtXUCTcsAm"
|
||||
|
||||
/*
|
||||
* Bitmasks defining "all rights" for each supported object type
|
||||
*/
|
||||
#define ACL_ALL_RIGHTS_COLUMN (ACL_INSERT|ACL_SELECT|ACL_UPDATE|ACL_REFERENCES)
|
||||
#define ACL_ALL_RIGHTS_RELATION (ACL_INSERT|ACL_SELECT|ACL_UPDATE|ACL_DELETE|ACL_TRUNCATE|ACL_REFERENCES|ACL_TRIGGER)
|
||||
#define ACL_ALL_RIGHTS_RELATION (ACL_INSERT|ACL_SELECT|ACL_UPDATE|ACL_DELETE|ACL_TRUNCATE|ACL_REFERENCES|ACL_TRIGGER|ACL_MAINTAIN)
|
||||
#define ACL_ALL_RIGHTS_SEQUENCE (ACL_USAGE|ACL_SELECT|ACL_UPDATE)
|
||||
#define ACL_ALL_RIGHTS_DATABASE (ACL_CREATE|ACL_CREATE_TEMP|ACL_CONNECT)
|
||||
#define ACL_ALL_RIGHTS_FDW (ACL_USAGE)
|
||||
|
||||
Reference in New Issue
Block a user