mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +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/utils/adt/acl.c,v 1.134 2006/07/14 14:52:23 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/acl.c,v 1.135 2006/09/05 21:08:36 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -265,9 +265,6 @@ aclparse(const char *s, AclItem *aip)
|
||||
case ACL_DELETE_CHR:
|
||||
read = ACL_DELETE;
|
||||
break;
|
||||
case ACL_RULE_CHR:
|
||||
read = ACL_RULE;
|
||||
break;
|
||||
case ACL_REFERENCES_CHR:
|
||||
read = ACL_REFERENCES;
|
||||
break;
|
||||
@ -289,6 +286,9 @@ aclparse(const char *s, AclItem *aip)
|
||||
case ACL_CONNECT_CHR:
|
||||
read = ACL_CONNECT;
|
||||
break;
|
||||
case 'R': /* ignore old RULE privileges */
|
||||
read = 0;
|
||||
break;
|
||||
default:
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
@ -1325,8 +1325,6 @@ convert_priv_string(text *priv_type_text)
|
||||
return ACL_UPDATE;
|
||||
if (pg_strcasecmp(priv_type, "DELETE") == 0)
|
||||
return ACL_DELETE;
|
||||
if (pg_strcasecmp(priv_type, "RULE") == 0)
|
||||
return ACL_RULE;
|
||||
if (pg_strcasecmp(priv_type, "REFERENCES") == 0)
|
||||
return ACL_REFERENCES;
|
||||
if (pg_strcasecmp(priv_type, "TRIGGER") == 0)
|
||||
@ -1343,6 +1341,8 @@ convert_priv_string(text *priv_type_text)
|
||||
return ACL_CREATE_TEMP;
|
||||
if (pg_strcasecmp(priv_type, "CONNECT") == 0)
|
||||
return ACL_CONNECT;
|
||||
if (pg_strcasecmp(priv_type, "RULE") == 0)
|
||||
return 0; /* ignore old RULE privileges */
|
||||
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
@ -1553,11 +1553,6 @@ convert_table_priv_string(text *priv_type_text)
|
||||
if (pg_strcasecmp(priv_type, "DELETE WITH GRANT OPTION") == 0)
|
||||
return ACL_GRANT_OPTION_FOR(ACL_DELETE);
|
||||
|
||||
if (pg_strcasecmp(priv_type, "RULE") == 0)
|
||||
return ACL_RULE;
|
||||
if (pg_strcasecmp(priv_type, "RULE WITH GRANT OPTION") == 0)
|
||||
return ACL_GRANT_OPTION_FOR(ACL_RULE);
|
||||
|
||||
if (pg_strcasecmp(priv_type, "REFERENCES") == 0)
|
||||
return ACL_REFERENCES;
|
||||
if (pg_strcasecmp(priv_type, "REFERENCES WITH GRANT OPTION") == 0)
|
||||
@ -1568,6 +1563,11 @@ convert_table_priv_string(text *priv_type_text)
|
||||
if (pg_strcasecmp(priv_type, "TRIGGER WITH GRANT OPTION") == 0)
|
||||
return ACL_GRANT_OPTION_FOR(ACL_TRIGGER);
|
||||
|
||||
if (pg_strcasecmp(priv_type, "RULE") == 0)
|
||||
return 0; /* ignore old RULE privileges */
|
||||
if (pg_strcasecmp(priv_type, "RULE WITH GRANT OPTION") == 0)
|
||||
return 0;
|
||||
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("unrecognized privilege type: \"%s\"", priv_type)));
|
||||
|
Reference in New Issue
Block a user