Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7562103

Browse files
committed
The no-updates-to-system-catalogs-unless-usecatupd restriction should
not apply to system views. It never mattered before 7.4, but it does now.
1 parent303a257 commit7562103

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

‎src/backend/catalog/aclchk.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.96 2003/12/19 14:21:56 petere Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.97 2004/01/14 03:44:53 tgl Exp $
1212
*
1313
* NOTES
1414
* See acl.h.
@@ -1015,6 +1015,7 @@ pg_class_aclcheck(Oid table_oid, AclId userid, AclMode mode)
10151015
boolusesuper,
10161016
usecatupd;
10171017
HeapTupletuple;
1018+
Form_pg_classclassForm;
10181019
DatumaclDatum;
10191020
boolisNull;
10201021
Acl*acl;
@@ -1046,16 +1047,22 @@ pg_class_aclcheck(Oid table_oid, AclId userid, AclMode mode)
10461047
ereport(ERROR,
10471048
(errcode(ERRCODE_UNDEFINED_TABLE),
10481049
errmsg("relation with OID %u does not exist",table_oid)));
1050+
classForm= (Form_pg_class)GETSTRUCT(tuple);
10491051

10501052
/*
10511053
* Deny anyone permission to update a system catalog unless
10521054
* pg_shadow.usecatupd is set.(This is to let superusers protect
1053-
* themselves from themselves.)
1055+
* themselves from themselves.) Also allow it if allowSystemTableMods.
1056+
*
1057+
* As of 7.4 we have some updatable system views; those shouldn't
1058+
* be protected in this way. Assume the view rules can take care
1059+
* of themselves.
10541060
*/
10551061
if ((mode& (ACL_INSERT |ACL_UPDATE |ACL_DELETE))&&
1056-
!allowSystemTableMods&&
1057-
IsSystemClass((Form_pg_class)GETSTRUCT(tuple))&&
1058-
!usecatupd)
1062+
IsSystemClass(classForm)&&
1063+
classForm->relkind!=RELKIND_VIEW&&
1064+
!usecatupd&&
1065+
!allowSystemTableMods)
10591066
{
10601067
#ifdefACLDEBUG
10611068
elog(DEBUG2,"permission denied for system catalog update");
@@ -1084,9 +1091,8 @@ pg_class_aclcheck(Oid table_oid, AclId userid, AclMode mode)
10841091
if (isNull)
10851092
{
10861093
/* No ACL, so build default ACL */
1087-
AclIdownerId;
1094+
AclIdownerId=classForm->relowner;
10881095

1089-
ownerId= ((Form_pg_class)GETSTRUCT(tuple))->relowner;
10901096
acl=acldefault(ACL_OBJECT_RELATION,ownerId);
10911097
aclDatum= (Datum)0;
10921098
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp