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 1jKPxb-000814-E1 for pgsql-general@arkaria.postgresql.org; Fri, 03 Apr 2020 17:18:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jKPxa-0006OT-BX for pgsql-general@arkaria.postgresql.org; Fri, 03 Apr 2020 17:18:26 +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 1jKPxa-0006OM-3l for pgsql-general@lists.postgresql.org; Fri, 03 Apr 2020 17:18:26 +0000 Received: from [64.147.123.21] (helo=wout5-smtp.messagingengine.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jKPxX-00051i-19 for pgsql-general@lists.postgresql.org; Fri, 03 Apr 2020 17:18:24 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 77747209; Fri, 3 Apr 2020 13:18:11 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 03 Apr 2020 13:18:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=2 K1X5gJlqcDYy8i0mDfm5U/fGd9R8iO4F0lxyusIf5s=; b=ptxx6dzCr15icXAlX 5qo+AIKsYuHR6qWVLEgbh1L5ZPirr/qSQ7a9MaFuNu7kRe6mMV3r6ScIn1csO5E/ hQ9pMjOpx5TjADTiATBtXsNN5soN+ne2exQebMgKoA56nzXoxuk403w/GQw6WThE VQ/wYK+z7dV9I0LJd5HrLgRnL8AEFX+tb1n1omvG+1AKA2Cj/2G7NqvX3VX2qoha IbXhWA37k4ktokf194ch+Nad0dZ4o4ZwEBCSwuuD3Io70h3ddCDvH+hebC2Z0qSi nOvGNZsSQtSG4criNxQaY68ebyujmkPE3lkWmNv/uZkqccxxj6w45QEoLe7KpZsi FVaog== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=2K1X5gJlqcDYy8i0mDfm5U/fGd9R8iO4F0lxyusIf 5s=; b=XKuPqIWie8lkzEtBjAkhwK4GFc5XlwQJjJ3BiaqbF35Zb9VQXxxrnhsLH 1pJSCWAyECYw3ym0GIC1oTeDQ11ikSqeHBgiRuWnrAzoZoQHyiBiftsh0bbSaTzg y+EGb3L1t5j8eevaRzlQZ30GBMSNknk1qE0NTGOGi6TV81mQrc3wkF4UUkgbNDwj z4JpI7ltQ0hXAYVKO6gt69wKBjEZ6oS4Udn8GXpBS1lemeBMFwenAMzn0TAJ0WX7 ViTGH26dqDZLbReBqPsXQYNlX3Gr3JtwBKygXwyMM+niuWysJIxK6uwAjgiEl08y DIo5eOgmhQ4zkJY+WXiEpqSm0XsUQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrtdeigdduuddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvfhfhffkffgfgggjtgfgsehtje ertddtfeejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhk lhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuffhomhgrihhnpehpohhsthhgrhgvsh hqlhdrohhrghenucfkphepjeehrddujedvrdeltddrledvnecuvehluhhsthgvrhfuihii vgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrg hklhgrvhgvrhdrtghomh X-ME-Proxy: Received: from [192.168.1.10] (75-172-90-92.tukw.qwest.net [75.172.90.92]) by mail.messagingengine.com (Postfix) with ESMTPA id 21B2F306CF82; Fri, 3 Apr 2020 13:18:10 -0400 (EDT) Subject: Re: Backing out of privilege grants rabbit hole To: AC Gomez , raf Cc: pgsql-general@lists.postgresql.org References: <20200403045739.ej4qsc6cx4nk4yb4@raf.org> From: Adrian Klaver Message-ID: Date: Fri, 3 Apr 2020 10:18:09 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 64.147.123.21 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 4/2/20 9:59 PM, AC Gomez wrote: > Granted. But we are where we are, so I'm assuming this is going to be > hand to hand combat. Well you could even the odds somewhat by using the below as a starting point: SELECT relname, pg_roles.rolname, acl.* FROM pg_class, aclexplode(relacl) AS acl JOIN pg_roles ON acl.grantee = pg_roles.oid WHERE pg_roles.oid = 'some_role'::regrole; > > On Fri, Apr 3, 2020, 12:57 AM raf > wrote: > > It's probably more sensible to grant permissions to roles that > represent groups, and have roles for individual users that > inherit the permissions of the group roles. Then you don't > need to revoke the permissions just because an individiual > has left. > > cheers, > raf > > AC Gomez wrote: > > > Thanks for the quick response. The problem is, in most cases the > owner is > > not the grantee. So if a role, let's say a temp employee, gets > grants, then > > leaves, I can't do a drop owned because that temp never owned those > > objects, he just was granted access. Is there a "drop granted" > kind of > > thing? > > > > On Thu, Apr 2, 2020, 11:37 PM Guyren Howe > wrote: > > > > > https://www.postgresql.org/docs/12/sql-drop-owned.html > > > > > > On Apr 2, 2020, at 20:34 , AC Gomez > wrote: > > > > > > Do I understand correctly that if a role was assigned countless > object > > > privileges and you want to delete that role you have to sift > through a > > > myriad of privilege grants in what amounts to a time consuming > trial and > > > error exercise until you've got them all? > > > > > > Or is there a single command that with just delete the role and > do a > > > blanket grant removal at the same time? > > -- Adrian Klaver adrian.klaver@aklaver.com