- Notifications
You must be signed in to change notification settings - Fork5k
Commit1e10d49
committed
Perform logical replication actions as the table owner.
Up until now, logical replication actions have been performed as thesubscription owner, who will generally be a superuser. Commitcec57b1 documented hazardsassociated with that situation, namely, that any user who owns atable on the subscriber side could assume the privileges of thesubscription owner by attaching a trigger, expression index, orsome other kind of executable code to it. As a remedy, it suggestednot creating configurations where users who are not fully trustedown tables on the subscriber.Although that will work, it basically precludes using logicalreplication in the way that people typically want to use it,namely, to replicate a database from one node to anotherwithout necessarily having any restrictions on which databaseusers can own tables. So, instead, change logical replication toexecute INSERT, UPDATE, DELETE, and TRUNCATE operations as thetable owner when they are replicated.Since this involves switching the active user frequently withina session that is authenticated as the subscription user, alsoimpose SECURITY_RESTRICTED_OPERATION restrictions on logicalreplication code. As an exception, if the table owner can SETROLE to the subscription owner, these restrictions have nosecurity value, so don't impose them in that case.Subscription owners are now required to have the ability toSET ROLE to every role that owns a table that the subscriptionis replicating. If they don't, replication will fail. Superusers,who normally own subscriptions, satisfy this property by default.Non-superusers users who own subscriptions will need to begranted the roles that own relevant tables.Patch by me, reviewed (but not necessarily in its entirety) byJelte Fennema, Jeff Davis, and Noah Misch.Discussion:http://postgr.es/m/CA+TgmoaSCkg9ww9oppPqqs+9RVqCexYCE6Aq=UsYPfnOoDeFkw@mail.gmail.com1 parent3077324 commit1e10d49
File tree
9 files changed
+250
-109
lines changed- doc/src/sgml
- src
- backend
- commands
- replication/logical
- utils/init
- include
- commands
- utils
- test/subscription/t
9 files changed
+250
-109
lines changedLines changed: 9 additions & 16 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1729 | 1729 |
| |
1730 | 1730 |
| |
1731 | 1731 |
| |
1732 |
| - | |
1733 |
| - | |
1734 |
| - | |
1735 |
| - | |
1736 |
| - | |
1737 |
| - | |
1738 |
| - | |
1739 |
| - | |
1740 |
| - | |
1741 |
| - | |
1742 |
| - | |
1743 |
| - | |
1744 |
| - | |
1745 | 1732 |
| |
1746 | 1733 |
| |
1747 | 1734 |
| |
| |||
1784 | 1771 |
| |
1785 | 1772 |
| |
1786 | 1773 |
| |
1787 |
| - | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
1788 | 1777 |
| |
1789 | 1778 |
| |
1790 | 1779 |
| |
1791 |
| - | |
1792 |
| - | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
1793 | 1786 |
| |
1794 | 1787 |
| |
1795 | 1788 |
| |
|
Lines changed: 18 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
103 | 103 |
| |
104 | 104 |
| |
105 | 105 |
| |
| 106 | + | |
106 | 107 |
| |
107 | 108 |
| |
108 | 109 |
| |
| |||
1762 | 1763 |
| |
1763 | 1764 |
| |
1764 | 1765 |
| |
1765 |
| - | |
| 1766 | + | |
1766 | 1767 |
| |
1767 | 1768 |
| |
1768 | 1769 |
| |
| |||
1790 | 1791 |
| |
1791 | 1792 |
| |
1792 | 1793 |
| |
1793 |
| - | |
| 1794 | + | |
| 1795 | + | |
1794 | 1796 |
| |
1795 | 1797 |
| |
1796 | 1798 |
| |
| |||
1929 | 1931 |
| |
1930 | 1932 |
| |
1931 | 1933 |
| |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
1932 | 1939 |
| |
| 1940 | + | |
| 1941 | + | |
1933 | 1942 |
| |
1934 | 1943 |
| |
1935 | 1944 |
| |
| |||
2134 | 2143 |
| |
2135 | 2144 |
| |
2136 | 2145 |
| |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
2137 | 2151 |
| |
| 2152 | + | |
| 2153 | + | |
2138 | 2154 |
| |
2139 | 2155 |
| |
2140 | 2156 |
| |
|
Lines changed: 21 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
207 | 207 |
| |
208 | 208 |
| |
209 | 209 |
| |
| 210 | + | |
210 | 211 |
| |
211 | 212 |
| |
212 | 213 |
| |
| |||
2395 | 2396 |
| |
2396 | 2397 |
| |
2397 | 2398 |
| |
| 2399 | + | |
2398 | 2400 |
| |
2399 | 2401 |
| |
2400 | 2402 |
| |
| |||
2423 | 2425 |
| |
2424 | 2426 |
| |
2425 | 2427 |
| |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
2426 | 2431 |
| |
2427 | 2432 |
| |
2428 | 2433 |
| |
| |||
2452 | 2457 |
| |
2453 | 2458 |
| |
2454 | 2459 |
| |
| 2460 | + | |
| 2461 | + | |
2455 | 2462 |
| |
2456 | 2463 |
| |
2457 | 2464 |
| |
| |||
2530 | 2537 |
| |
2531 | 2538 |
| |
2532 | 2539 |
| |
| 2540 | + | |
2533 | 2541 |
| |
2534 | 2542 |
| |
2535 | 2543 |
| |
| |||
2569 | 2577 |
| |
2570 | 2578 |
| |
2571 | 2579 |
| |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
2572 | 2583 |
| |
2573 | 2584 |
| |
2574 | 2585 |
| |
| |||
2619 | 2630 |
| |
2620 | 2631 |
| |
2621 | 2632 |
| |
| 2633 | + | |
| 2634 | + | |
2622 | 2635 |
| |
2623 | 2636 |
| |
2624 | 2637 |
| |
| |||
2702 | 2715 |
| |
2703 | 2716 |
| |
2704 | 2717 |
| |
| 2718 | + | |
2705 | 2719 |
| |
2706 | 2720 |
| |
2707 | 2721 |
| |
| |||
2736 | 2750 |
| |
2737 | 2751 |
| |
2738 | 2752 |
| |
| 2753 | + | |
| 2754 | + | |
| 2755 | + | |
2739 | 2756 |
| |
2740 | 2757 |
| |
2741 | 2758 |
| |
| |||
2761 | 2778 |
| |
2762 | 2779 |
| |
2763 | 2780 |
| |
| 2781 | + | |
| 2782 | + | |
2764 | 2783 |
| |
2765 | 2784 |
| |
2766 | 2785 |
| |
| |||
3211 | 3230 |
| |
3212 | 3231 |
| |
3213 | 3232 |
| |
3214 |
| - | |
| 3233 | + | |
| 3234 | + | |
3215 | 3235 |
| |
3216 | 3236 |
| |
3217 | 3237 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
15 | 15 |
| |
16 | 16 |
| |
17 | 17 |
| |
18 |
| - | |
| 18 | + | |
| 19 | + | |
19 | 20 |
| |
20 | 21 |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
6 |
| - | |
| 6 | + | |
| 7 | + |
Lines changed: 92 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + |
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
60 | 60 |
| |
61 | 61 |
| |
62 | 62 |
| |
63 |
| - | |
| 63 | + | |
| 64 | + | |
64 | 65 |
| |
65 | 66 |
| |
66 | 67 |
| |
|
Lines changed: 26 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + |
0 commit comments
Comments
(0)