mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Get rid of the separate RULE privilege for tables: now only a table's owner
can create or modify rules for the table. Do setRuleCheckAsUser() while loading rules into the relcache, rather than when defining a rule. This ensures that permission checks for tables referenced in a rule are done with respect to the current owner of the rule's table, whereas formerly ALTER TABLE OWNER would fail to update the permission checking for associated rules. Removal of separate RULE privilege is needed to prevent various scenarios in which a grantee of RULE privilege could effectively have any privilege of the table owner. For backwards compatibility, GRANT/REVOKE RULE is still accepted, but it doesn't do anything. Per discussion here: http://archives.postgresql.org/pgsql-hackers/2006-04/msg01138.php
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.130 2006/07/14 14:52:17 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.131 2006/09/05 21:08:35 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* See acl.h.
|
||||
@@ -1328,8 +1328,6 @@ string_to_privilege(const char *privname)
|
||||
return ACL_UPDATE;
|
||||
if (strcmp(privname, "delete") == 0)
|
||||
return ACL_DELETE;
|
||||
if (strcmp(privname, "rule") == 0)
|
||||
return ACL_RULE;
|
||||
if (strcmp(privname, "references") == 0)
|
||||
return ACL_REFERENCES;
|
||||
if (strcmp(privname, "trigger") == 0)
|
||||
@@ -1346,6 +1344,8 @@ string_to_privilege(const char *privname)
|
||||
return ACL_CREATE_TEMP;
|
||||
if (strcmp(privname, "connect") == 0)
|
||||
return ACL_CONNECT;
|
||||
if (strcmp(privname, "rule") == 0)
|
||||
return 0; /* ignore old RULE privileges */
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("unrecognized privilege type \"%s\"", privname)));
|
||||
@@ -1365,8 +1365,6 @@ privilege_to_string(AclMode privilege)
|
||||
return "UPDATE";
|
||||
case ACL_DELETE:
|
||||
return "DELETE";
|
||||
case ACL_RULE:
|
||||
return "RULE";
|
||||
case ACL_REFERENCES:
|
||||
return "REFERENCES";
|
||||
case ACL_TRIGGER:
|
||||
|
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* Copyright (c) 2003-2006, PostgreSQL Global Development Group
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/catalog/information_schema.sql,v 1.35 2006/09/04 23:13:01 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/catalog/information_schema.sql,v 1.36 2006/09/05 21:08:35 tgl Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -1194,7 +1194,6 @@ CREATE VIEW role_table_grants AS
|
||||
SELECT 'INSERT' UNION ALL
|
||||
SELECT 'UPDATE' UNION ALL
|
||||
SELECT 'REFERENCES' UNION ALL
|
||||
SELECT 'RULE' UNION ALL
|
||||
SELECT 'TRIGGER') AS pr (type)
|
||||
|
||||
WHERE c.relnamespace = nc.oid
|
||||
@@ -1705,7 +1704,6 @@ CREATE VIEW table_constraints AS
|
||||
OR has_table_privilege(r.oid, 'INSERT')
|
||||
OR has_table_privilege(r.oid, 'UPDATE')
|
||||
OR has_table_privilege(r.oid, 'DELETE')
|
||||
OR has_table_privilege(r.oid, 'RULE')
|
||||
OR has_table_privilege(r.oid, 'REFERENCES')
|
||||
OR has_table_privilege(r.oid, 'TRIGGER') )
|
||||
|
||||
@@ -1739,7 +1737,6 @@ CREATE VIEW table_constraints AS
|
||||
OR has_table_privilege(r.oid, 'INSERT')
|
||||
OR has_table_privilege(r.oid, 'UPDATE')
|
||||
OR has_table_privilege(r.oid, 'DELETE')
|
||||
OR has_table_privilege(r.oid, 'RULE')
|
||||
OR has_table_privilege(r.oid, 'REFERENCES')
|
||||
OR has_table_privilege(r.oid, 'TRIGGER') );
|
||||
|
||||
@@ -1785,7 +1782,6 @@ CREATE VIEW table_privileges AS
|
||||
SELECT 'INSERT' UNION ALL
|
||||
SELECT 'UPDATE' UNION ALL
|
||||
SELECT 'REFERENCES' UNION ALL
|
||||
SELECT 'RULE' UNION ALL
|
||||
SELECT 'TRIGGER') AS pr (type)
|
||||
|
||||
WHERE c.relnamespace = nc.oid
|
||||
@@ -1841,7 +1837,6 @@ CREATE VIEW tables AS
|
||||
OR has_table_privilege(c.oid, 'INSERT')
|
||||
OR has_table_privilege(c.oid, 'UPDATE')
|
||||
OR has_table_privilege(c.oid, 'DELETE')
|
||||
OR has_table_privilege(c.oid, 'RULE')
|
||||
OR has_table_privilege(c.oid, 'REFERENCES')
|
||||
OR has_table_privilege(c.oid, 'TRIGGER') );
|
||||
|
||||
@@ -1963,7 +1958,6 @@ CREATE VIEW triggers AS
|
||||
OR has_table_privilege(c.oid, 'INSERT')
|
||||
OR has_table_privilege(c.oid, 'UPDATE')
|
||||
OR has_table_privilege(c.oid, 'DELETE')
|
||||
OR has_table_privilege(c.oid, 'RULE')
|
||||
OR has_table_privilege(c.oid, 'REFERENCES')
|
||||
OR has_table_privilege(c.oid, 'TRIGGER') );
|
||||
|
||||
@@ -2162,7 +2156,6 @@ CREATE VIEW views AS
|
||||
OR has_table_privilege(c.oid, 'INSERT')
|
||||
OR has_table_privilege(c.oid, 'UPDATE')
|
||||
OR has_table_privilege(c.oid, 'DELETE')
|
||||
OR has_table_privilege(c.oid, 'RULE')
|
||||
OR has_table_privilege(c.oid, 'REFERENCES')
|
||||
OR has_table_privilege(c.oid, 'TRIGGER') );
|
||||
|
||||
|
Reference in New Issue
Block a user