mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Remove rolcatupdate
This role attribute is an ancient PostgreSQL feature, but could only be set by directly updating the system catalogs, and it doesn't have any clearly defined use. Author: Adam Brightwell <adam.brightwell@crunchydatasolutions.com>
This commit is contained in:
@ -3423,26 +3423,6 @@ aclcheck_error_type(AclResult aclerr, Oid typeOid)
|
||||
}
|
||||
|
||||
|
||||
/* Check if given user has rolcatupdate privilege according to pg_authid */
|
||||
static bool
|
||||
has_rolcatupdate(Oid roleid)
|
||||
{
|
||||
bool rolcatupdate;
|
||||
HeapTuple tuple;
|
||||
|
||||
tuple = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("role with OID %u does not exist", roleid)));
|
||||
|
||||
rolcatupdate = ((Form_pg_authid) GETSTRUCT(tuple))->rolcatupdate;
|
||||
|
||||
ReleaseSysCache(tuple);
|
||||
|
||||
return rolcatupdate;
|
||||
}
|
||||
|
||||
/*
|
||||
* Relay for the various pg_*_mask routines depending on object kind
|
||||
*/
|
||||
@ -3620,8 +3600,7 @@ pg_class_aclmask(Oid table_oid, Oid roleid,
|
||||
|
||||
/*
|
||||
* Deny anyone permission to update a system catalog unless
|
||||
* pg_authid.rolcatupdate is set. (This is to let superusers protect
|
||||
* themselves from themselves.) Also allow it if allowSystemTableMods.
|
||||
* pg_authid.rolsuper is set. Also allow it if allowSystemTableMods.
|
||||
*
|
||||
* As of 7.4 we have some updatable system views; those shouldn't be
|
||||
* protected in this way. Assume the view rules can take care of
|
||||
@ -3630,7 +3609,7 @@ pg_class_aclmask(Oid table_oid, Oid roleid,
|
||||
if ((mask & (ACL_INSERT | ACL_UPDATE | ACL_DELETE | ACL_TRUNCATE | ACL_USAGE)) &&
|
||||
IsSystemClass(table_oid, classForm) &&
|
||||
classForm->relkind != RELKIND_VIEW &&
|
||||
!has_rolcatupdate(roleid) &&
|
||||
!superuser_arg(roleid) &&
|
||||
!allowSystemTableMods)
|
||||
{
|
||||
#ifdef ACLDEBUG
|
||||
|
@ -13,7 +13,6 @@ CREATE VIEW pg_roles AS
|
||||
rolinherit,
|
||||
rolcreaterole,
|
||||
rolcreatedb,
|
||||
rolcatupdate,
|
||||
rolcanlogin,
|
||||
rolreplication,
|
||||
rolconnlimit,
|
||||
@ -31,7 +30,6 @@ CREATE VIEW pg_shadow AS
|
||||
pg_authid.oid AS usesysid,
|
||||
rolcreatedb AS usecreatedb,
|
||||
rolsuper AS usesuper,
|
||||
rolcatupdate AS usecatupd,
|
||||
rolreplication AS userepl,
|
||||
rolbypassrls AS usebypassrls,
|
||||
rolpassword AS passwd,
|
||||
@ -57,7 +55,6 @@ CREATE VIEW pg_user AS
|
||||
usesysid,
|
||||
usecreatedb,
|
||||
usesuper,
|
||||
usecatupd,
|
||||
userepl,
|
||||
usebypassrls,
|
||||
'********'::text as passwd,
|
||||
|
@ -368,8 +368,6 @@ CreateRole(CreateRoleStmt *stmt)
|
||||
new_record[Anum_pg_authid_rolinherit - 1] = BoolGetDatum(inherit);
|
||||
new_record[Anum_pg_authid_rolcreaterole - 1] = BoolGetDatum(createrole);
|
||||
new_record[Anum_pg_authid_rolcreatedb - 1] = BoolGetDatum(createdb);
|
||||
/* superuser gets catupdate right by default */
|
||||
new_record[Anum_pg_authid_rolcatupdate - 1] = BoolGetDatum(issuper);
|
||||
new_record[Anum_pg_authid_rolcanlogin - 1] = BoolGetDatum(canlogin);
|
||||
new_record[Anum_pg_authid_rolreplication - 1] = BoolGetDatum(isreplication);
|
||||
new_record[Anum_pg_authid_rolconnlimit - 1] = Int32GetDatum(connlimit);
|
||||
@ -734,20 +732,12 @@ AlterRole(AlterRoleStmt *stmt)
|
||||
MemSet(new_record_repl, false, sizeof(new_record_repl));
|
||||
|
||||
/*
|
||||
* issuper/createrole/catupdate/etc
|
||||
*
|
||||
* XXX It's rather unclear how to handle catupdate. It's probably best to
|
||||
* keep it equal to the superuser status, otherwise you could end up with
|
||||
* a situation where no existing superuser can alter the catalogs,
|
||||
* including pg_authid!
|
||||
* issuper/createrole/etc
|
||||
*/
|
||||
if (issuper >= 0)
|
||||
{
|
||||
new_record[Anum_pg_authid_rolsuper - 1] = BoolGetDatum(issuper > 0);
|
||||
new_record_repl[Anum_pg_authid_rolsuper - 1] = true;
|
||||
|
||||
new_record[Anum_pg_authid_rolcatupdate - 1] = BoolGetDatum(issuper > 0);
|
||||
new_record_repl[Anum_pg_authid_rolcatupdate - 1] = true;
|
||||
}
|
||||
|
||||
if (inherit >= 0)
|
||||
|
Reference in New Issue
Block a user