Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mnjQH-0002ot-1K for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Nov 2021 15:34:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mnjQG-0003Hu-09 for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Nov 2021 15:34:00 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mnjQF-0003Hk-7o for pgsql-hackers@lists.postgresql.org; Thu, 18 Nov 2021 15:33:59 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mnjQC-0007D3-0D for pgsql-hackers@postgresql.org; Thu, 18 Nov 2021 15:33:57 +0000 Received: by mail-pj1-x102c.google.com with SMTP id np6-20020a17090b4c4600b001a90b011e06so6017489pjb.5 for ; Thu, 18 Nov 2021 07:33:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=d3Ja93k0qcob9+U08aVP56scYr9N5sYm4THltv13RV0=; b=HBnKBeM4qpRenLZInvgMfrG0z832yw0zQvdLCjul73iM6H5codR4W9bYQ4etdOyZvZ NZ7UrQ2GhaCDeE+jnELdufzs5NU5DzQLw+C0iNTNgtlyB8w4L4VlMomjnPlDUuacacNG +rTydDx8NbxjSYPYj5oksQuLbOk7PztLakKhxCzLg2JFOHS0GBqpiAkGbPMYANGQCEQr 1h7VUvnXelYLDxvwXOh4AY9G6XAK+VgaYpO/4eTZ7JBhfEoHE5OLBOLGGQA/zdTsfWyF K/hkWHLlBp1lM0+MSuzVwTr2IILV6PBM/1Ik/pHWC7KGX9MZKZsFLTu+GaAsJt5xHQ4X N7tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=d3Ja93k0qcob9+U08aVP56scYr9N5sYm4THltv13RV0=; b=m3h5Y9g/YVzHCk7ZowntSla+q3cxlGY3QcWm+cgqpnZ085bn5ZL9jpQYkgJESNnnfb 3t9QOmHzb0Y8EgF5mnBcmHKV81XijPj2R2Qq0JXGMGDySsz1vURwhaSJBXNygN5Bx8C/ d8Db3Hll4GqpKAKFejf7yYpbEcz5Nc2QMMx6sVyJUGmManQokSek1Xp4xwPHYVECLagU pnzYGpzrIe7WfHkt3yR94cUaCc+FBB3KqSexhAkRUnjFYHHLNp3ocWsnyaSrIYjpTCJJ +A9lxmeiGCV65uanIZM7of4hiZBHsDObcFLFLoc7ZhQxZEUhD/CQFn/HXziiUwIv+YY7 OGZg== X-Gm-Message-State: AOAM531gUMlwIYRU32eT0IpMxvX+5D8Vz5VZihV6YdwLlAXedLBRXsUT Xuj2xmNBYb7QjKqj0ZaOcBge2za1LokusFozcstgVPDgFsYKFTVh3IS5YRyie47nN5Y4Q1L4CHp 8+zJDWXzntQeb+bABDFj+s2l3zX9i7W2IdkPnmUePiT50jC3muaFSLbVw+HbvoBO4DqTyXqbnjA 9G7dz7tINkj3GDMAf68BdT+J9pW9JpzXnOx8wJ X-Google-Smtp-Source: ABdhPJwcLJqkjiZqAD+pUjMulf52UQC7Ge1t4YZvyokiHcRWsG/wwsA4b2vFRl/MaIa2lcDutoKXWw== X-Received: by 2002:a17:902:ea10:b0:142:112d:c0b9 with SMTP id s16-20020a170902ea1000b00142112dc0b9mr66596334plg.35.1637249634438; Thu, 18 Nov 2021 07:33:54 -0800 (PST) Received: from laptop280-ma-us.hitronhub.home (24-113-193-150.wavecable.com. [24.113.193.150]) by smtp.gmail.com with ESMTPSA id u9sm42638pfi.23.2021.11.18.07.33.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Nov 2021 07:33:54 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: Non-superuser subscription owners From: Mark Dilger In-Reply-To: Date: Thu, 18 Nov 2021 07:33:53 -0800 Cc: Jeff Davis , Andrew Dunstan , PostgreSQL-development , Robert Haas Content-Transfer-Encoding: quoted-printable Message-Id: <1BB0A553-3FE9-4A91-A975-6F9D8C157FBD@enterprisedb.com> References: <9DFC88D3-1300-4DE8-ACBC-4CEF84399A53@enterprisedb.com> <6BB4451E-7B1B-474C-BD1F-DB7531E720C6@enterprisedb.com> <6A2B0FF6-CC86-48CE-B0D3-5401AA5CFEA9@enterprisedb.com> To: Amit Kapila X-Mailer: Apple Mail (2.3608.120.23.2.7) X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Nov 18, 2021, at 2:50 AM, Amit Kapila = wrote: >=20 >> I gave that a slight amount of thought during the design of this = patch, but didn't think we could refuse to revoke superuser on such a = basis, and didn't see what we should do with the subscription other than = have it continue to be owned by the recently-non-superuser. If you have = a better idea, we can discuss it, but to some degree I think that is = also orthogonal to the purpose of this patch. The only sense in which = this patch depends on that issue is that this patch proposes that = non-superuser subscription owners are already an issue, and therefore = that this patch isn't creating a new issue, but rather making more sane = something that already can happen. >>=20 >=20 > Don't we want to close this gap irrespective of the other part of the > feature? I mean if we take out the part of your 0003 patch that checks > whether the current user has permission to perform a particular > operation on the target table then the gap related to the owner losing > superuser privileges should be addressed. I don't think there is a gap. The patch does the right thing, causing = the subscription whose owner has had superuser revoked to itself no = longer function with superuser privileges. Whether that causes the = subscription to fail depends on whether the previously-superuser now = non-superuser owner now lacks sufficient privileges on the target = relation(s). I think removing that part of the patch would be a = regression. Let's compare two scenarios. In the first, we have a regular user = "alice" who owns a subscription which replicates into table = "accounting.receipts" for which she has been granted privileges by the = table's owner. What would you expect to happen after the table's owner = revokes privileges from alice? I would expect that the subscription can = no longer function, and periodic attempts to replicate into that table = result in permission denied errors in the logs. In the second, we have a superuser "alice" who owns a subscription that = replicates into table "accounting.receipts", and she only has sufficient = privileges to modify "accounting.receipts" by virtue of being superuser. = I would expect that when she has superuser revoked, the subscription = can likewise no longer function. =20 Now, maybe I'm wrong in both cases, and both should continue to = function. But I would find it really strange if the first situation = behaved differently from the second. I think intuitions about how subscriptions behave differ depending on = the reason you expect the subscription to be owned by a particular user. = If the reason the user owns the subscription is that the user just = happens to be the user who created it, but isn't in your mind associated = with the subscription, then having the subscription continue to function = regardless of what happens to the user, even the user being dropped, is = probably consistent with your expectations. In a sense, you think of = the user who creates the subscription as having gifted it to the = universe rather than continuing to own it. Or perhaps you think of the = creator of the subscription as a solicitor/lawyer/agent working on = behalf of client, and once that legal transaction is completed, you = don't expect the lawyer being disbarred should impact the subscription = which exists for the benefit of the client. If instead you think about the subscription owner as continuing to be = closely associated with the subscription (as I do), then you expect = changes in the owner's permissions to impact the subscription. I think the "gifted to the universe"/"lawyer" mental model is not = consistent with how the system is already designed to work. You can't = drop the subscription's owner without first running REASSIGN OWNED, or = ALTER SUBSCRIPTION..OWNER TO, or simply dropping the subscription: DROP ROLE regress_subscription_user; ERROR: role "regress_subscription_user" cannot be dropped because = some objects depend on it DETAIL: owner of subscription regress_testsub =E2=80=94 Mark Dilger EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company