pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #9923: "reassign owned" does not change permissions grantor
10+ messages / 5 participants
[nested] [flat]

Commits from this thread:
  2015-12-21 ab14c13838 2c8ae6442f 62e6eba8d2 7af3dd540e  adjust ACL owners for REASSIGN and ALTER OWNER TO
* BUG #9923: "reassign owned" does not change permissions grantor
@ 2014-04-09 05:12  bashtanov@imap.cc
  0 siblings, 0 replies; 10+ messages in thread

From: bashtanov@imap.cc @ 2014-04-09 05:12 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      9923
Logged by:          Alexey Bashtanov
Email address:      bashtanov@imap.cc
PostgreSQL version: 9.3.1
Operating system:   CentOS 6.4
Description:        

Hello!

"Alter ... owner to ..." statement changes the permissions grantor but
"reassign owned ..." does not.

[ACTIONS]
1. create a type, give it some permissions. Get something like this:

test_bash_20140408=# select (select rolname from pg_roles where oid =
typowner), typacl from pg_type where oid = 'foo'::regtype;
 rolname | typacl  
---------+---------
 ro      | {=U/ro}
(1 row)

2. reassign owned by its owner to some other user:
test_bash_20140408=# reassign owned by ro to test_ui;
REASSIGN OWNED

[EXPECTED]
new permissions grantor is the new owner:

test_bash_20140408=# select (select rolname from pg_roles where oid =
typowner), typacl from pg_type where oid = 'foo'::regtype;
 rolname | typacl  
---------+---------
 test_ui | {=U/test_ui}
(1 row)

[RECIEVED]
permissions grantor was left the same:

test_bash_20140408=# select (select rolname from pg_roles where oid =
typowner), typacl from pg_type where oid = 'foo'::regtype;
 rolname | typacl  
---------+---------
 test_ui | {=U/ro}
(1 row)

Additionally, these ACLs cannot be pg_restored after pg_dumped

BTW is the expected behavior documented? I could not find this in docs.

Regards, 
  Alexey Bashtanov


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: BUG #9923: "reassign owned" does not change permissions grantor
@ 2014-04-09 07:35  Alexey Bashtanov <bashtanov@imap.cc>
  0 siblings, 1 reply; 10+ messages in thread

From: Alexey Bashtanov @ 2014-04-09 07:35 UTC (permalink / raw)
  To: pgsql-bugs

after a series of tests and source code reading I realized that
1) the bug is not fixed in last git repository version
2) the bug could be reproduced on types and foreign servers, maybe also 
on foreign data wrappers, triggers, but not on any other objects
3) it does not matter if we assign owner using "reassign owned" or using 
"alter .. owner to ..."
4) there is a problem on revoking such incorrect grants: a workaround is 
to reassign back to old owner, then revoke, than reassign once again
5) to fix the bug we need to perform aclnewowner call in 
AlterForeignServerOwner_internal and AlterTypeOwner (including the 
typtype == TYPTYPE_COMPOSITE case, cause we pass recursing=true to 
ATExecChangeOwner)
and maybe in AlterForeignDataWrapperOwner_internal and 
AlterEventTriggerOwner_internal

sorry I do not provide the exact patch

Regards,
   Alexey Bashtanov


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: BUG #9923: "reassign owned" does not change permissions grantor
@ 2015-01-09 18:19  Bruce Momjian <bruce@momjian.us>
  parent: Alexey Bashtanov <bashtanov@imap.cc>
  0 siblings, 1 reply; 10+ messages in thread

From: Bruce Momjian @ 2015-01-09 18:19 UTC (permalink / raw)
  To: Alexey Bashtanov <bashtanov@imap.cc>; +Cc: pgsql-bugs

On Wed, Apr  9, 2014 at 11:35:09AM +0400, Alexey Bashtanov wrote:
> after a series of tests and source code reading I realized that
> 1) the bug is not fixed in last git repository version

Confirmed.

> 2) the bug could be reproduced on types and foreign servers, maybe
> also on foreign data wrappers, triggers, but not on any other
> objects

Triggers don't have acl lists, but all the others are accurate.

> 3) it does not matter if we assign owner using "reassign owned" or
> using "alter .. owner to ..."

Confirmed.

> 4) there is a problem on revoking such incorrect grants: a
> workaround is to reassign back to old owner, then revoke, than
> reassign once again
> 5) to fix the bug we need to perform aclnewowner call in
> AlterForeignServerOwner_internal and AlterTypeOwner (including the
> typtype == TYPTYPE_COMPOSITE case, cause we pass recursing=true to
> ATExecChangeOwner)
> and maybe in AlterForeignDataWrapperOwner_internal and
> AlterEventTriggerOwner_internal

I can confirm this bug report from April, and your analysis of the fixes
--- we were missing calls to aclnewowner() for types, foreign servers,
and foreign data wrappers, for both REASSIGN and ALTER OWNER TO.

With the attached SQL script you can see the ACL fields properly
changing to match the object owner (attached).  Without the patch, only
the table's ACL changes.

The patch also changes the regression output --- I think that is because
the object ownership changes remove certain duplicates from the ACL
list.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Attachments:

acl.sql (text/plain, 2.2K) download -- make -C /pgtop/contrib/isn install; make -C /pgtop/contrib/postgres_fdw install DROP EXTENSION isn CASCADE; DROP EXTENSION postgres_fdw CASCADE; DROP SERVER pgtest; DROP FOREIGN DATA WRAPPER pgtest2; DROP USER ro; CREATE USER ro SUPERUSER; DROP USER test_ui; CREATE USER test_ui SUPERUSER; \c test ro CREATE TABLE test (x INT); CREATE EXTENSION isn; CREATE EXTENSION postgres_fdw; CREATE SERVER pgtest TYPE 'postgres_fdw' FOREIGN DATA WRAPPER postgres_fdw; CREATE FOREIGN DATA WRAPPER pgtest2; \c test postgres GRANT SELECT ON TABLE test TO ro; GRANT USAGE ON TYPE isbn TO ro; GRANT USAGE ON FOREIGN SERVER pgtest TO ro; GRANT USAGE ON FOREIGN DATA WRAPPER pgtest2 TO ro; -- SELECT (SELECT rolname FROM pg_roles WHERE oid = relowner), relacl FROM pg_class WHERE oid = 'test'::regclass; SELECT (SELECT rolname FROM pg_roles WHERE oid = typowner), typacl FROM pg_type WHERE oid = 'isbn'::regtype; SELECT (SELECT rolname FROM pg_roles WHERE oid = srvowner), srvacl FROM pg_foreign_server WHERE srvname = 'pgtest'; SELECT (SELECT rolname FROM pg_roles WHERE oid = fdwowner), fdwacl FROM pg_foreign_data_wrapper WHERE fdwname = 'pgtest2'; REASSIGN OWNED BY ro TO test_ui; SELECT (SELECT rolname FROM pg_roles WHERE oid = relowner), relacl FROM pg_class WHERE oid = 'test'::regclass; SELECT (SELECT rolname FROM pg_roles WHERE oid = typowner), typacl FROM pg_type WHERE oid = 'isbn'::regtype; SELECT (SELECT rolname FROM pg_roles WHERE oid = srvowner), srvacl FROM pg_foreign_server WHERE srvname = 'pgtest'; SELECT (SELECT rolname FROM pg_roles WHERE oid = fdwowner), fdwacl FROM pg_foreign_data_wrapper WHERE fdwname = 'pgtest2'; ALTER TABLE test OWNER TO ro; ALTER TYPE isbn OWNER TO ro; ALTER SERVER pgtest OWNER TO ro; ALTER FOREIGN DATA WRAPPER pgtest2 OWNER TO ro; SELECT (SELECT rolname FROM pg_roles WHERE oid = relowner), relacl FROM pg_class WHERE oid = 'test'::regclass; SELECT (SELECT rolname FROM pg_roles WHERE oid = typowner), typacl FROM pg_type WHERE oid = 'isbn'::regtype; SELECT (SELECT rolname FROM pg_roles WHERE oid = srvowner), srvacl FROM pg_foreign_server WHERE srvname = 'pgtest'; SELECT (SELECT rolname FROM pg_roles WHERE oid = fdwowner), fdwacl FROM pg_foreign_data_wrapper WHERE fdwname = 'pgtest2';
new (text/plain, 1.5K) download DROP EXTENSION DROP EXTENSION DROP FOREIGN DATA WRAPPER DROP ROLE CREATE ROLE You are now connected to database "test" as user "ro". CREATE EXTENSION CREATE EXTENSION CREATE SERVER CREATE FOREIGN DATA WRAPPER You are now connected to database "test" as user "postgres". GRANT GRANT GRANT GRANT rolname | relacl ---------+----------------- ro | {ro=arwdDxt/ro} (1 row) rolname | typacl ---------+----------------- ro | {=U/ro,ro=U/ro} (1 row) rolname | srvacl ---------+----------- ro | {ro=U/ro} (1 row) rolname | fdwacl ---------+----------- ro | {ro=U/ro} (1 row) REASSIGN OWNED rolname | relacl ---------+--------------------------- test_ui | {test_ui=arwdDxt/test_ui} (1 row) rolname | typacl ---------+-------------------------------- test_ui | {=U/test_ui,test_ui=U/test_ui} (1 row) rolname | srvacl ---------+--------------------- test_ui | {test_ui=U/test_ui} (1 row) rolname | fdwacl ---------+--------------------- test_ui | {test_ui=U/test_ui} (1 row) ALTER TABLE ALTER TYPE ALTER SERVER ALTER FOREIGN DATA WRAPPER rolname | relacl ---------+----------------- ro | {ro=arwdDxt/ro} (1 row) rolname | typacl ---------+----------------- ro | {=U/ro,ro=U/ro} (1 row) rolname | srvacl ---------+----------- ro | {ro=U/ro} (1 row) rolname | fdwacl ---------+----------- ro | {ro=U/ro} (1 row)
acl.diff (text/x-diff, 23.9K) download diff --git a/src/backend/commands/foreigncmds.c b/src/backend/commands/foreigncmds.c new file mode 100644 index a3aeabb..9f7adbf *** a/src/backend/commands/foreigncmds.c --- b/src/backend/commands/foreigncmds.c *************** static void *** 225,230 **** --- 225,236 ---- AlterForeignDataWrapperOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId) { Form_pg_foreign_data_wrapper form; + Datum repl_val[Natts_pg_foreign_data_wrapper]; + bool repl_null[Natts_pg_foreign_data_wrapper]; + bool repl_repl[Natts_pg_foreign_data_wrapper]; + Acl *newAcl; + Datum aclDatum; + bool isNull; form = (Form_pg_foreign_data_wrapper) GETSTRUCT(tup); *************** AlterForeignDataWrapperOwner_internal(Re *** 246,252 **** if (form->fdwowner != newOwnerId) { ! form->fdwowner = newOwnerId; simple_heap_update(rel, &tup->t_self, tup); CatalogUpdateIndexes(rel, tup); --- 252,278 ---- if (form->fdwowner != newOwnerId) { ! memset(repl_null, false, sizeof(repl_null)); ! memset(repl_repl, false, sizeof(repl_repl)); ! ! repl_repl[Anum_pg_foreign_data_wrapper_fdwowner - 1] = true; ! repl_val[Anum_pg_foreign_data_wrapper_fdwowner - 1] = ObjectIdGetDatum(newOwnerId); ! ! aclDatum = heap_getattr(tup, ! Anum_pg_foreign_data_wrapper_fdwacl, ! RelationGetDescr(rel), ! &isNull); ! /* Null ACLs do not require changes */ ! if (!isNull) ! { ! newAcl = aclnewowner(DatumGetAclP(aclDatum), ! form->fdwowner, newOwnerId); ! repl_repl[Anum_pg_foreign_data_wrapper_fdwacl - 1] = true; ! repl_val[Anum_pg_foreign_data_wrapper_fdwacl - 1] = PointerGetDatum(newAcl); ! } ! ! tup = heap_modify_tuple(tup, RelationGetDescr(rel), repl_val, repl_null, ! repl_repl); simple_heap_update(rel, &tup->t_self, tup); CatalogUpdateIndexes(rel, tup); *************** static void *** 327,332 **** --- 353,364 ---- AlterForeignServerOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId) { Form_pg_foreign_server form; + Datum repl_val[Natts_pg_foreign_server]; + bool repl_null[Natts_pg_foreign_server]; + bool repl_repl[Natts_pg_foreign_server]; + Acl *newAcl; + Datum aclDatum; + bool isNull; form = (Form_pg_foreign_server) GETSTRUCT(tup); *************** AlterForeignServerOwner_internal(Relatio *** 358,364 **** } } ! form->srvowner = newOwnerId; simple_heap_update(rel, &tup->t_self, tup); CatalogUpdateIndexes(rel, tup); --- 390,416 ---- } } ! memset(repl_null, false, sizeof(repl_null)); ! memset(repl_repl, false, sizeof(repl_repl)); ! ! repl_repl[Anum_pg_foreign_server_srvowner - 1] = true; ! repl_val[Anum_pg_foreign_server_srvowner - 1] = ObjectIdGetDatum(newOwnerId); ! ! aclDatum = heap_getattr(tup, ! Anum_pg_foreign_server_srvacl, ! RelationGetDescr(rel), ! &isNull); ! /* Null ACLs do not require changes */ ! if (!isNull) ! { ! newAcl = aclnewowner(DatumGetAclP(aclDatum), ! form->srvowner, newOwnerId); ! repl_repl[Anum_pg_foreign_server_srvacl - 1] = true; ! repl_val[Anum_pg_foreign_server_srvacl - 1] = PointerGetDatum(newAcl); ! } ! ! tup = heap_modify_tuple(tup, RelationGetDescr(rel), repl_val, repl_null, ! repl_repl); simple_heap_update(rel, &tup->t_self, tup); CatalogUpdateIndexes(rel, tup); diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c new file mode 100644 index 322a3c7..b77e1b4 *** a/src/backend/commands/typecmds.c --- b/src/backend/commands/typecmds.c *************** AlterTypeOwner(List *names, Oid newOwner *** 3376,3387 **** ATExecChangeOwner(typTup->typrelid, newOwnerId, true, AccessExclusiveLock); else { ! /* ! * We can just apply the modification directly. ! * ! * okay to scribble on typTup because it's a copy ! */ ! typTup->typowner = newOwnerId; simple_heap_update(rel, &tup->t_self, tup); --- 3376,3409 ---- ATExecChangeOwner(typTup->typrelid, newOwnerId, true, AccessExclusiveLock); else { ! Datum repl_val[Natts_pg_type]; ! bool repl_null[Natts_pg_type]; ! bool repl_repl[Natts_pg_type]; ! Acl *newAcl; ! Datum aclDatum; ! bool isNull; ! ! memset(repl_null, false, sizeof(repl_null)); ! memset(repl_repl, false, sizeof(repl_repl)); ! ! repl_repl[Anum_pg_type_typowner - 1] = true; ! repl_val[Anum_pg_type_typowner - 1] = ObjectIdGetDatum(newOwnerId); ! ! aclDatum = heap_getattr(tup, ! Anum_pg_type_typacl, ! RelationGetDescr(rel), ! &isNull); ! /* Null ACLs do not require changes */ ! if (!isNull) ! { ! newAcl = aclnewowner(DatumGetAclP(aclDatum), ! typTup->typowner, newOwnerId); ! repl_repl[Anum_pg_type_typacl - 1] = true; ! repl_val[Anum_pg_type_typacl - 1] = PointerGetDatum(newAcl); ! } ! ! tup = heap_modify_tuple(tup, RelationGetDescr(rel), repl_val, repl_null, ! repl_repl); simple_heap_update(rel, &tup->t_self, tup); *************** AlterTypeOwnerInternal(Oid typeOid, Oid *** 3424,3429 **** --- 3446,3457 ---- Relation rel; HeapTuple tup; Form_pg_type typTup; + Datum repl_val[Natts_pg_type]; + bool repl_null[Natts_pg_type]; + bool repl_repl[Natts_pg_type]; + Acl *newAcl; + Datum aclDatum; + bool isNull; rel = heap_open(TypeRelationId, RowExclusiveLock); *************** AlterTypeOwnerInternal(Oid typeOid, Oid *** 3432,3441 **** elog(ERROR, "cache lookup failed for type %u", typeOid); typTup = (Form_pg_type) GETSTRUCT(tup); ! /* ! * Modify the owner --- okay to scribble on typTup because it's a copy ! */ ! typTup->typowner = newOwnerId; simple_heap_update(rel, &tup->t_self, tup); --- 3460,3486 ---- elog(ERROR, "cache lookup failed for type %u", typeOid); typTup = (Form_pg_type) GETSTRUCT(tup); ! memset(repl_null, false, sizeof(repl_null)); ! memset(repl_repl, false, sizeof(repl_repl)); ! ! repl_repl[Anum_pg_type_typowner - 1] = true; ! repl_val[Anum_pg_type_typowner - 1] = ObjectIdGetDatum(newOwnerId); ! ! aclDatum = heap_getattr(tup, ! Anum_pg_type_typacl, ! RelationGetDescr(rel), ! &isNull); ! /* Null ACLs do not require changes */ ! if (!isNull) ! { ! newAcl = aclnewowner(DatumGetAclP(aclDatum), ! typTup->typowner, newOwnerId); ! repl_repl[Anum_pg_type_typacl - 1] = true; ! repl_val[Anum_pg_type_typacl - 1] = PointerGetDatum(newAcl); ! } ! ! tup = heap_modify_tuple(tup, RelationGetDescr(rel), repl_val, repl_null, ! repl_repl); simple_heap_update(rel, &tup->t_self, tup); diff --git a/src/test/regress/expected/foreign_data.out b/src/test/regress/expected/foreign_data.out new file mode 100644 index 9bca440..4795c83 *** a/src/test/regress/expected/foreign_data.out --- b/src/test/regress/expected/foreign_data.out *************** ERROR: role "regress_test_indirect" can *** 422,461 **** DETAIL: owner of server s1 privileges for foreign-data wrapper foo \des+ ! List of foreign servers ! Name | Owner | Foreign-data wrapper | Access privileges | Type | Version | FDW Options | Description ! ------+-----------------------+----------------------+-----------------------------------------+--------+---------+--------------------------------------+------------- ! s1 | regress_test_indirect | foo | foreign_data_user=U/foreign_data_user +| | 1.1 | (servername 's1') | ! | | | regress_test_role=U/foreign_data_user | | | | ! s2 | foreign_data_user | foo | | | 1.1 | (host 'a', dbname 'b') | ! s3 | foreign_data_user | foo | | oracle | | ("tns name" 'orcl', port '1521') | ! s4 | foreign_data_user | foo | | oracle | | (host 'a', dbname 'b') | ! s5 | foreign_data_user | foo | | | 15.0 | | ! s6 | foreign_data_user | foo | foreign_data_user=U/foreign_data_user +| | 16.0 | (host 'a', dbname 'b') | ! | | | regress_test_role2=U*/foreign_data_user | | | | ! s7 | foreign_data_user | foo | | oracle | 17.0 | (host 'a', dbname 'b') | ! s8 | foreign_data_user | postgresql | | | | (dbname 'db1', connect_timeout '30') | ! t1 | regress_test_role | foo | | | | | ! t2 | regress_test_role | foo | | | | | (10 rows) ALTER SERVER s8 RENAME to s8new; \des+ ! List of foreign servers ! Name | Owner | Foreign-data wrapper | Access privileges | Type | Version | FDW Options | Description ! -------+-----------------------+----------------------+-----------------------------------------+--------+---------+--------------------------------------+------------- ! s1 | regress_test_indirect | foo | foreign_data_user=U/foreign_data_user +| | 1.1 | (servername 's1') | ! | | | regress_test_role=U/foreign_data_user | | | | ! s2 | foreign_data_user | foo | | | 1.1 | (host 'a', dbname 'b') | ! s3 | foreign_data_user | foo | | oracle | | ("tns name" 'orcl', port '1521') | ! s4 | foreign_data_user | foo | | oracle | | (host 'a', dbname 'b') | ! s5 | foreign_data_user | foo | | | 15.0 | | ! s6 | foreign_data_user | foo | foreign_data_user=U/foreign_data_user +| | 16.0 | (host 'a', dbname 'b') | ! | | | regress_test_role2=U*/foreign_data_user | | | | ! s7 | foreign_data_user | foo | | oracle | 17.0 | (host 'a', dbname 'b') | ! s8new | foreign_data_user | postgresql | | | | (dbname 'db1', connect_timeout '30') | ! t1 | regress_test_role | foo | | | | | ! t2 | regress_test_role | foo | | | | | (10 rows) ALTER SERVER s8new RENAME to s8; --- 422,459 ---- DETAIL: owner of server s1 privileges for foreign-data wrapper foo \des+ ! List of foreign servers ! Name | Owner | Foreign-data wrapper | Access privileges | Type | Version | FDW Options | Description ! ------+-----------------------+----------------------+-----------------------------------------------+--------+---------+--------------------------------------+------------- ! s1 | regress_test_indirect | foo | regress_test_indirect=U/regress_test_indirect | | 1.1 | (servername 's1') | ! s2 | foreign_data_user | foo | | | 1.1 | (host 'a', dbname 'b') | ! s3 | foreign_data_user | foo | | oracle | | ("tns name" 'orcl', port '1521') | ! s4 | foreign_data_user | foo | | oracle | | (host 'a', dbname 'b') | ! s5 | foreign_data_user | foo | | | 15.0 | | ! s6 | foreign_data_user | foo | foreign_data_user=U/foreign_data_user +| | 16.0 | (host 'a', dbname 'b') | ! | | | regress_test_role2=U*/foreign_data_user | | | | ! s7 | foreign_data_user | foo | | oracle | 17.0 | (host 'a', dbname 'b') | ! s8 | foreign_data_user | postgresql | | | | (dbname 'db1', connect_timeout '30') | ! t1 | regress_test_role | foo | | | | | ! t2 | regress_test_role | foo | | | | | (10 rows) ALTER SERVER s8 RENAME to s8new; \des+ ! List of foreign servers ! Name | Owner | Foreign-data wrapper | Access privileges | Type | Version | FDW Options | Description ! -------+-----------------------+----------------------+-----------------------------------------------+--------+---------+--------------------------------------+------------- ! s1 | regress_test_indirect | foo | regress_test_indirect=U/regress_test_indirect | | 1.1 | (servername 's1') | ! s2 | foreign_data_user | foo | | | 1.1 | (host 'a', dbname 'b') | ! s3 | foreign_data_user | foo | | oracle | | ("tns name" 'orcl', port '1521') | ! s4 | foreign_data_user | foo | | oracle | | (host 'a', dbname 'b') | ! s5 | foreign_data_user | foo | | | 15.0 | | ! s6 | foreign_data_user | foo | foreign_data_user=U/foreign_data_user +| | 16.0 | (host 'a', dbname 'b') | ! | | | regress_test_role2=U*/foreign_data_user | | | | ! s7 | foreign_data_user | foo | | oracle | 17.0 | (host 'a', dbname 'b') | ! s8new | foreign_data_user | postgresql | | | | (dbname 'db1', connect_timeout '30') | ! t1 | regress_test_role | foo | | | | | ! t2 | regress_test_role | foo | | | | | (10 rows) ALTER SERVER s8new RENAME to s8; *************** SELECT * FROM information_schema.user_ma *** 937,957 **** (7 rows) SELECT * FROM information_schema.usage_privileges WHERE object_type LIKE 'FOREIGN%' AND object_name IN ('s6', 'foo') ORDER BY 1, 2, 3, 4, 5; ! grantor | grantee | object_catalog | object_schema | object_name | object_type | privilege_type | is_grantable ! -------------------+-----------------------+----------------+---------------+-------------+----------------------+----------------+-------------- ! foreign_data_user | foreign_data_user | regression | | foo | FOREIGN DATA WRAPPER | USAGE | YES ! foreign_data_user | foreign_data_user | regression | | s6 | FOREIGN SERVER | USAGE | YES ! foreign_data_user | regress_test_indirect | regression | | foo | FOREIGN DATA WRAPPER | USAGE | NO ! foreign_data_user | regress_test_role2 | regression | | s6 | FOREIGN SERVER | USAGE | YES (4 rows) SELECT * FROM information_schema.role_usage_grants WHERE object_type LIKE 'FOREIGN%' AND object_name IN ('s6', 'foo') ORDER BY 1, 2, 3, 4, 5; ! grantor | grantee | object_catalog | object_schema | object_name | object_type | privilege_type | is_grantable ! -------------------+-----------------------+----------------+---------------+-------------+----------------------+----------------+-------------- ! foreign_data_user | foreign_data_user | regression | | foo | FOREIGN DATA WRAPPER | USAGE | YES ! foreign_data_user | foreign_data_user | regression | | s6 | FOREIGN SERVER | USAGE | YES ! foreign_data_user | regress_test_indirect | regression | | foo | FOREIGN DATA WRAPPER | USAGE | NO ! foreign_data_user | regress_test_role2 | regression | | s6 | FOREIGN SERVER | USAGE | YES (4 rows) SELECT * FROM information_schema.foreign_tables ORDER BY 1, 2, 3; --- 935,955 ---- (7 rows) SELECT * FROM information_schema.usage_privileges WHERE object_type LIKE 'FOREIGN%' AND object_name IN ('s6', 'foo') ORDER BY 1, 2, 3, 4, 5; ! grantor | grantee | object_catalog | object_schema | object_name | object_type | privilege_type | is_grantable ! -----------------------+-----------------------+----------------+---------------+-------------+----------------------+----------------+-------------- ! foreign_data_user | foreign_data_user | regression | | foo | FOREIGN DATA WRAPPER | USAGE | YES ! foreign_data_user | regress_test_indirect | regression | | foo | FOREIGN DATA WRAPPER | USAGE | NO ! regress_test_indirect | regress_test_indirect | regression | | s6 | FOREIGN SERVER | USAGE | YES ! regress_test_indirect | regress_test_role2 | regression | | s6 | FOREIGN SERVER | USAGE | YES (4 rows) SELECT * FROM information_schema.role_usage_grants WHERE object_type LIKE 'FOREIGN%' AND object_name IN ('s6', 'foo') ORDER BY 1, 2, 3, 4, 5; ! grantor | grantee | object_catalog | object_schema | object_name | object_type | privilege_type | is_grantable ! -----------------------+-----------------------+----------------+---------------+-------------+----------------------+----------------+-------------- ! foreign_data_user | foreign_data_user | regression | | foo | FOREIGN DATA WRAPPER | USAGE | YES ! foreign_data_user | regress_test_indirect | regression | | foo | FOREIGN DATA WRAPPER | USAGE | NO ! regress_test_indirect | regress_test_indirect | regression | | s6 | FOREIGN SERVER | USAGE | YES ! regress_test_indirect | regress_test_role2 | regression | | s6 | FOREIGN SERVER | USAGE | YES (4 rows) SELECT * FROM information_schema.foreign_tables ORDER BY 1, 2, 3; *************** SELECT * FROM information_schema.user_ma *** 980,997 **** (5 rows) SELECT * FROM information_schema.usage_privileges WHERE object_type LIKE 'FOREIGN%' AND object_name IN ('s6', 'foo') ORDER BY 1, 2, 3, 4, 5; ! grantor | grantee | object_catalog | object_schema | object_name | object_type | privilege_type | is_grantable ! -------------------+-----------------------+----------------+---------------+-------------+----------------------+----------------+-------------- ! foreign_data_user | regress_test_indirect | regression | | foo | FOREIGN DATA WRAPPER | USAGE | NO ! foreign_data_user | regress_test_role2 | regression | | s6 | FOREIGN SERVER | USAGE | YES ! (2 rows) SELECT * FROM information_schema.role_usage_grants WHERE object_type LIKE 'FOREIGN%' AND object_name IN ('s6', 'foo') ORDER BY 1, 2, 3, 4, 5; ! grantor | grantee | object_catalog | object_schema | object_name | object_type | privilege_type | is_grantable ! -------------------+-----------------------+----------------+---------------+-------------+----------------------+----------------+-------------- ! foreign_data_user | regress_test_indirect | regression | | foo | FOREIGN DATA WRAPPER | USAGE | NO ! foreign_data_user | regress_test_role2 | regression | | s6 | FOREIGN SERVER | USAGE | YES ! (2 rows) DROP USER MAPPING FOR current_user SERVER t1; SET ROLE regress_test_role2; --- 978,997 ---- (5 rows) SELECT * FROM information_schema.usage_privileges WHERE object_type LIKE 'FOREIGN%' AND object_name IN ('s6', 'foo') ORDER BY 1, 2, 3, 4, 5; ! grantor | grantee | object_catalog | object_schema | object_name | object_type | privilege_type | is_grantable ! -----------------------+-----------------------+----------------+---------------+-------------+----------------------+----------------+-------------- ! foreign_data_user | regress_test_indirect | regression | | foo | FOREIGN DATA WRAPPER | USAGE | NO ! regress_test_indirect | regress_test_indirect | regression | | s6 | FOREIGN SERVER | USAGE | YES ! regress_test_indirect | regress_test_role2 | regression | | s6 | FOREIGN SERVER | USAGE | YES ! (3 rows) SELECT * FROM information_schema.role_usage_grants WHERE object_type LIKE 'FOREIGN%' AND object_name IN ('s6', 'foo') ORDER BY 1, 2, 3, 4, 5; ! grantor | grantee | object_catalog | object_schema | object_name | object_type | privilege_type | is_grantable ! -----------------------+-----------------------+----------------+---------------+-------------+----------------------+----------------+-------------- ! foreign_data_user | regress_test_indirect | regression | | foo | FOREIGN DATA WRAPPER | USAGE | NO ! regress_test_indirect | regress_test_indirect | regression | | s6 | FOREIGN SERVER | USAGE | YES ! regress_test_indirect | regress_test_role2 | regression | | s6 | FOREIGN SERVER | USAGE | YES ! (3 rows) DROP USER MAPPING FOR current_user SERVER t1; SET ROLE regress_test_role2;
^ permalink raw reply [nested|flat] 10+ messages in thread

* Re: BUG #9923: "reassign owned" does not change permissions grantor
@ 2015-01-22 17:37  Bruce Momjian <bruce@momjian.us>
  parent: Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 10+ messages in thread

From: Bruce Momjian @ 2015-01-22 17:37 UTC (permalink / raw)
  To: Alexey Bashtanov <bashtanov@imap.cc>; +Cc: pgsql-bugs

On Fri, Jan  9, 2015 at 01:19:48PM -0500, Bruce Momjian wrote:
> I can confirm this bug report from April, and your analysis of the fixes
> --- we were missing calls to aclnewowner() for types, foreign servers,
> and foreign data wrappers, for both REASSIGN and ALTER OWNER TO.
> 
> With the attached SQL script you can see the ACL fields properly
> changing to match the object owner (attached).  Without the patch, only
> the table's ACL changes.
> 
> The patch also changes the regression output --- I think that is because
> the object ownership changes remove certain duplicates from the ACL
> list.

Patch applied.  Thank you for the excellent bug report.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: BUG #9923: "reassign owned" does not change permissions grantor
@ 2015-12-16 22:40  Alvaro Herrera <alvherre@2ndquadrant.com>
  parent: Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 10+ messages in thread

From: Alvaro Herrera @ 2015-12-16 22:40 UTC (permalink / raw)
  To: Bruce Momjian <bruce@momjian.us>; +Cc: Alexey Bashtanov <bashtanov@imap.cc>; pgsql-bugs

Bruce Momjian wrote:
> On Fri, Jan  9, 2015 at 01:19:48PM -0500, Bruce Momjian wrote:
> > I can confirm this bug report from April, and your analysis of the fixes
> > --- we were missing calls to aclnewowner() for types, foreign servers,
> > and foreign data wrappers, for both REASSIGN and ALTER OWNER TO.
> > 
> > With the attached SQL script you can see the ACL fields properly
> > changing to match the object owner (attached).  Without the patch, only
> > the table's ACL changes.
> > 
> > The patch also changes the regression output --- I think that is because
> > the object ownership changes remove certain duplicates from the ACL
> > list.
> 
> Patch applied.  Thank you for the excellent bug report.

I just realized that you didn't backpatch this bug fix, and therefore my
fix for bug #13666 fails to cherry-pick sanely on 9.4 and earlier.

I think this should be back-patched.

This is the changelog entry:

Author: Bruce Momjian <bruce@momjian.us>
Branch: master Release: REL9_5_BR [59367fdf9] 2015-01-22 12:36:55 -0500

    adjust ACL owners for REASSIGN and ALTER OWNER TO
    
    When REASSIGN and ALTER OWNER TO are used, both the object owner and ACL
    list should be changed from the old owner to the new owner. This patch
    fixes types, foreign data wrappers, and foreign servers to change their
    ACL list properly;  they already changed owners properly.
    
    BACKWARD INCOMPATIBILITY?
    
    Report by Alexey Bashtanov

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: BUG #9923: "reassign owned" does not change permissions grantor
@ 2015-12-17 20:14  Bruce Momjian <bruce@momjian.us>
  parent: Alvaro Herrera <alvherre@2ndquadrant.com>
  0 siblings, 1 reply; 10+ messages in thread

From: Bruce Momjian @ 2015-12-17 20:14 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Alexey Bashtanov <bashtanov@imap.cc>; pgsql-bugs

On Wed, Dec 16, 2015 at 07:40:05PM -0300, Alvaro Herrera wrote:
> Bruce Momjian wrote:
> > On Fri, Jan  9, 2015 at 01:19:48PM -0500, Bruce Momjian wrote:
> > > I can confirm this bug report from April, and your analysis of the fixes
> > > --- we were missing calls to aclnewowner() for types, foreign servers,
> > > and foreign data wrappers, for both REASSIGN and ALTER OWNER TO.
> > > 
> > > With the attached SQL script you can see the ACL fields properly
> > > changing to match the object owner (attached).  Without the patch, only
> > > the table's ACL changes.
> > > 
> > > The patch also changes the regression output --- I think that is because
> > > the object ownership changes remove certain duplicates from the ACL
> > > list.
> > 
> > Patch applied.  Thank you for the excellent bug report.
> 
> I just realized that you didn't backpatch this bug fix, and therefore my
> fix for bug #13666 fails to cherry-pick sanely on 9.4 and earlier.
> 
> I think this should be back-patched.
> 
> This is the changelog entry:
> 
> Author: Bruce Momjian <bruce@momjian.us>
> Branch: master Release: REL9_5_BR [59367fdf9] 2015-01-22 12:36:55 -0500
> 
>     adjust ACL owners for REASSIGN and ALTER OWNER TO
>     
>     When REASSIGN and ALTER OWNER TO are used, both the object owner and ACL
>     list should be changed from the old owner to the new owner. This patch
>     fixes types, foreign data wrappers, and foreign servers to change their
>     ACL list properly;  they already changed owners properly.
>     
>     BACKWARD INCOMPATIBILITY?

Backpatching seems fine to me.  I was just concerned if anyone was
relying on the existing buggy behavior.  We do list this item as a 9.5
incompatibility, so the question is whether we can add an
incompatibility to back branches:

      Fix <link linkend="SQL-REASSIGN-OWNED"><command>REASSIGN OWNED</></>
      and <link linkend="SQL-ALTERTYPE"><command>ALTER OWNER TO</></>
      to properly update permissions lists (ACLs) when changing ownership of
      types, foreign data wrappers, and foreign servers (Bruce Momjian)

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I. As I am, so you will be. +
+ Roman grave inscription                             +


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: BUG #9923: "reassign owned" does not change permissions grantor
@ 2015-12-17 20:21  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 10+ messages in thread

From: Tom Lane @ 2015-12-17 20:21 UTC (permalink / raw)
  To: Bruce Momjian <bruce@momjian.us>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Alexey Bashtanov <bashtanov@imap.cc>; pgsql-bugs

Bruce Momjian <bruce@momjian.us> writes:
> Backpatching seems fine to me.  I was just concerned if anyone was
> relying on the existing buggy behavior.

Seems unlikely.  Even if they are, the potential for catalog corruption
later seems to trump that argument.

> We do list this item as a 9.5
> incompatibility, so the question is whether we can add an
> incompatibility to back branches:

>       Fix <link linkend="SQL-REASSIGN-OWNED"><command>REASSIGN OWNED</></>
>       and <link linkend="SQL-ALTERTYPE"><command>ALTER OWNER TO</></>
>       to properly update permissions lists (ACLs) when changing ownership of
>       types, foreign data wrappers, and foreign servers (Bruce Momjian)

Actually, I guess we should take out that 9.5 release note item altogether
if we back-patch this.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: BUG #9923: "reassign owned" does not change permissions grantor
@ 2015-12-17 20:23  Bruce Momjian <bruce@momjian.us>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 10+ messages in thread

From: Bruce Momjian @ 2015-12-17 20:23 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Alexey Bashtanov <bashtanov@imap.cc>; pgsql-bugs

On Thu, Dec 17, 2015 at 03:21:46PM -0500, Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > Backpatching seems fine to me.  I was just concerned if anyone was
> > relying on the existing buggy behavior.
> 
> Seems unlikely.  Even if they are, the potential for catalog corruption
> later seems to trump that argument.
> 
> > We do list this item as a 9.5
> > incompatibility, so the question is whether we can add an
> > incompatibility to back branches:
> 
> >       Fix <link linkend="SQL-REASSIGN-OWNED"><command>REASSIGN OWNED</></>
> >       and <link linkend="SQL-ALTERTYPE"><command>ALTER OWNER TO</></>
> >       to properly update permissions lists (ACLs) when changing ownership of
> >       types, foreign data wrappers, and foreign servers (Bruce Momjian)
> 
> Actually, I guess we should take out that 9.5 release note item altogether
> if we back-patch this.

Yes, that was one of my points.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I. As I am, so you will be. +
+ Roman grave inscription                             +


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: BUG #9923: "reassign owned" does not change permissions grantor
@ 2015-12-21 22:54  Alvaro Herrera <alvherre@2ndquadrant.com>
  parent: Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 10+ messages in thread

From: Alvaro Herrera @ 2015-12-21 22:54 UTC (permalink / raw)
  To: Bruce Momjian <bruce@momjian.us>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Alexey Bashtanov <bashtanov@imap.cc>; pgsql-bugs

Bruce Momjian wrote:
> On Thu, Dec 17, 2015 at 03:21:46PM -0500, Tom Lane wrote:
> > Bruce Momjian <bruce@momjian.us> writes:
> > > Backpatching seems fine to me.  I was just concerned if anyone was
> > > relying on the existing buggy behavior.
> > 
> > Seems unlikely.  Even if they are, the potential for catalog corruption
> > later seems to trump that argument.
> > 
> > > We do list this item as a 9.5
> > > incompatibility, so the question is whether we can add an
> > > incompatibility to back branches:
> > 
> > >       Fix <link linkend="SQL-REASSIGN-OWNED"><command>REASSIGN OWNED</></>
> > >       and <link linkend="SQL-ALTERTYPE"><command>ALTER OWNER TO</></>
> > >       to properly update permissions lists (ACLs) when changing ownership of
> > >       types, foreign data wrappers, and foreign servers (Bruce Momjian)
> > 
> > Actually, I guess we should take out that 9.5 release note item altogether
> > if we back-patch this.
> 
> Yes, that was one of my points.

Backpatched all the way back to 9.1.  Are you, Bruce, on the hook for
removing the 9.5 release note entry, or should I do that?

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: BUG #9923: "reassign owned" does not change permissions grantor
@ 2015-12-21 23:46  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Alvaro Herrera <alvherre@2ndquadrant.com>
  0 siblings, 0 replies; 10+ messages in thread

From: Tom Lane @ 2015-12-21 23:46 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Bruce Momjian <bruce@momjian.us>; Alexey Bashtanov <bashtanov@imap.cc>; pgsql-bugs

Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> Backpatched all the way back to 9.1.  Are you, Bruce, on the hook for
> removing the 9.5 release note entry, or should I do that?

You can remove it if you feel like, but either Bruce or I will be doing
another pass over the release notes before 9.5.0, and we should catch
it then.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread


end of thread, other threads:[~2015-12-21 23:46 UTC | newest]

Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-04-09 05:12 BUG #9923: "reassign owned" does not change permissions grantor bashtanov@imap.cc
2014-04-09 07:35 Re: BUG #9923: "reassign owned" does not change permissions grantor Alexey Bashtanov <bashtanov@imap.cc>
2015-01-09 18:19 ` Bruce Momjian <bruce@momjian.us>
2015-01-22 17:37   ` Bruce Momjian <bruce@momjian.us>
2015-12-16 22:40     ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-12-17 20:14       ` Bruce Momjian <bruce@momjian.us>
2015-12-17 20:21         ` Tom Lane <tgl@sss.pgh.pa.us>
2015-12-17 20:23           ` Bruce Momjian <bruce@momjian.us>
2015-12-21 22:54             ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-12-21 23:46               ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox