Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U3s7w-0007lE-1n for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Feb 2013 17:52:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U3s7v-0003gI-3x for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Feb 2013 17:52:43 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U3s7t-0003fB-Em for pgsql-hackers@postgresql.org; Fri, 08 Feb 2013 17:52:41 +0000 Received: from ie-in-x0229.1e100.net ([2607:f8b0:4001:c03::229] helo=mail-ie0-x229.google.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U3s7q-0003P7-Qc for pgsql-hackers@postgresql.org; Fri, 08 Feb 2013 17:52:41 +0000 Received: by mail-ie0-f169.google.com with SMTP id 13so5375785iea.14 for ; Fri, 08 Feb 2013 09:52:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=uJCP9Kzus/eginhIINUngSq2mFK/BDK8pe65rovFSsQ=; b=VDXfZRTtB/QmER/yi83M38dtSFXqxdM9ZbfYgqEQiN5zJXoghNL7l/rCDoIw/qrdEp fT5VL/F49ST2ZurDQfAS32bIjywfCKeHFf5XBeI8InfDLASeaF4wkj/VqzlDobTbqZC5 g7WBty4boLpV8VE8v9VkB+005ekEP86QzlTEtQnec4ldOnQF02BffuE6Hd2/CDuC3Oag hg1KilsySlnGb6Rw223VWJ4lk/1JO4RYGCVg05mu9ylhsZy74208ck1EuXhqbEgMirwV axMNcxDVRUJPiSxNYfK0/U2sEvKKi3AMDLy9WAjE8B7BZv+c59piRtha/cPEzU6f/z6Z +V0Q== X-Received: by 10.50.135.8 with SMTP id po8mr4099678igb.23.1360345957203; Fri, 08 Feb 2013 09:52:37 -0800 (PST) Received: from [192.168.0.136] (c-24-17-179-185.hsd1.wa.comcast.net. [24.17.179.185]) by mx.google.com with ESMTPS id eg7sm15035304igc.7.2013.02.08.09.52.34 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Feb 2013 09:52:35 -0800 (PST) Message-ID: <51153B61.5010207@gmail.com> Date: Fri, 08 Feb 2013 09:52:33 -0800 From: Adrian Klaver User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 MIME-Version: 1.0 To: Tom Lane CC: Andreas Kretschmer , Alvaro Herrera , pgsql-hackers@postgreSQL.org Subject: Re: DROP OWNED BY fails to drop privileges granted by non-owners (was Re: [GENERAL] Bug, Feature, or what else?) References: <119745304.24731.1360333559327.JavaMail.open-xchange@ox.ims-firmen.de> <51151128.8040807@gmail.com> <1568445490.24920.1360335539088.JavaMail.open-xchange@ox.ims-firmen.de> <51151764.4090405@gmail.com> <609013460.25018.1360337038276.JavaMail.open-xchange@ox.ims-firmen.de> <17143.1360340065@sss.pgh.pa.us> <51152A28.4060303@gmail.com> <19080.1360343369@sss.pgh.pa.us> In-Reply-To: <19080.1360343369@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 02/08/2013 09:09 AM, Tom Lane wrote: > Adrian Klaver writes: >> On 02/08/2013 08:14 AM, Tom Lane wrote: >>> Of course, postgres has other options besides that, of which "DROP OWNED >>> BY ak02" is probably the most appropriate here. Or if you really want >>> to get rid of just that grant, SET ROLE TO akretschmer01 and revoke. > >> The DROP OWNED was tried further up the thread and did not seem to work: > > Huh. You're right, here is a complete test case: > > regression=# create schema s1; > cCREATE SCHEMA > regression=# create user u1; > CREATE ROLE > regression=# create user u2; > CREATE ROLE > regression=# grant all on schema s1 to u1 with grant option; > GRANT > regression=# \c - u1 > You are now connected to database "regression" as user "u1". > regression=> grant all on schema s1 to u2; > GRANT > regression=> \c - postgres > You are now connected to database "regression" as user "postgres". > regression=# \dn+ s1 > List of schemas > Name | Owner | Access privileges | Description > ------+----------+----------------------+------------- > s1 | postgres | postgres=UC/postgres+| > | | u1=U*C*/postgres +| > | | u2=UC/u1 | > (1 row) > > regression=# drop user u2; -- expect failure here > ERROR: role "u2" cannot be dropped because some objects depend on it > DETAIL: privileges for schema s1 > regression=# drop owned by u2; > DROP OWNED > regression=# drop user u2; -- failure here is wrong > ERROR: role "u2" cannot be dropped because some objects depend on it > DETAIL: privileges for schema s1 > regression=# \dn+ s1 > List of schemas > Name | Owner | Access privileges | Description > ------+----------+----------------------+------------- > s1 | postgres | postgres=UC/postgres+| > | | u1=U*C*/postgres +| > | | u2=UC/u1 | > (1 row) > > I believe the problem is that DROP OWNED for privileges is implemented > by calling REVOKE. As noted upthread, when a superuser does REVOKE, > it's executed as though the object owner did the REVOKE, so only > privileges granted directly by the object owner go away. In this > particular example, "DROP OWNED BY u1" makes the grant to u1 go away, > and then the grant to u2 goes away via cascade ... but "DROP OWNED BY > u2" fails to accomplish anything at all, because postgres never granted > anything directly to u2. > > We haven't seen this reported before, probably because the use of > GRANT OPTIONS isn't very common, but AFAICS it's been wrong since > the invention of DROP OWNED. > > It looks to me like DropOwnedObjects doesn't actually insist on > superuserness to do DROP OWNED, only ability to become the role, > which means that DROP OWNED BY is completely broken for privileges > if executed by a non-superuser; the only privileges it would remove > would be those granted by the current user to the target user. > I'm not really sure what the desirable behavior would be in such a > case though. Ordinary users can't revoke privileges granted *to* > them, only privileges granted *by* them. So it's not necessarily > the case that a non-superuser should be able to make all privileges > granted to a target role go away, even if he's allowed to become > the target role and thereby drop objects that it owns. I wonder > how sensible it is really to allow DROP OWNED to non-superusers. I am not sure I am following. Are we talking two different cases here? 1) As mentioned in the first paragraph the case where running DROP OWNED as a supersuser does not work. 2) A non-superuser running DROP OWNED and not having the necessary privileges. > > regards, tom lane > -- Adrian Klaver adrian.klaver@gmail.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers