Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y4mRO-0007aJ-9X for pgsql-hackers@arkaria.postgresql.org; Sat, 27 Dec 2014 08:09:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y4mRN-0007gW-P9 for pgsql-hackers@arkaria.postgresql.org; Sat, 27 Dec 2014 08:09:37 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y4mRL-0007cy-Gy for pgsql-hackers@postgresql.org; Sat, 27 Dec 2014 08:09:35 +0000 Received: from mail-pa0-x22d.google.com ([2607:f8b0:400e:c03::22d]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1Y4mRH-000838-WD for pgsql-hackers@postgresql.org; Sat, 27 Dec 2014 08:09:33 +0000 Received: by mail-pa0-f45.google.com with SMTP id lf10so14269713pab.18 for ; Sat, 27 Dec 2014 00:09:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=lVx0Rs/JEToRl17B9WA9swk0rFECHIdK6YS7IlPuaYE=; b=Mx5P/e38EhEMQzW7VMBVEmrNU7o+OtI+VZ6G294lZjLuckQ+6OxG0eWHlx47fY1IM0 Dsah/s+IfbAocq8Fyv7ndl995+aYjmbvrz847/I3KQR+48xiw/amasKtoJtw25KBcB3S LQeEB2733teGUl3CKxyhZzEuUafoxyULkMzUE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=lVx0Rs/JEToRl17B9WA9swk0rFECHIdK6YS7IlPuaYE=; b=MLtIVY8Dn3o0Oo70GeTOqoyk2nDgbY0icxYtip2TN1EIKE5tvuOXcIiuga8buxfzZU rYSlesXDnacFHIUXan6kOCUg8LQyQ9DbO19MupAsoCVe4YVYtfjwijfsRHHcnndg2tnP 8E+QSxMoBeJ8ok8Wj6/Q0e20rQwbBkc/hBSvmjC0HkSDz8RK8vEhMofS7Okwrq1S2xLV dNOpKNZrfL4411+tJGc5MOyPN7ZhORQ/rPRO38wftQZ6zI06qVelJaCNPmgSh6X06bDf 01GoVEMVbqyG8HT7pXst6vdEppd84GiNL+wkgnfRXTIvBBmn7sxu0iJUwfJy/DqecIHQ f7KA== X-Gm-Message-State: ALoCoQlaaN0c5Tlg/HWflYMOSAuJm7yeZ/h0VIyUPoUXImbexjmPm4rT4IzG0udvTFvkWFeOGjdh X-Received: by 10.66.149.98 with SMTP id tz2mr7694092pab.63.1419667769795; Sat, 27 Dec 2014 00:09:29 -0800 (PST) Received: from tornado.leadboat.com (c-50-131-89-155.hsd1.ca.comcast.net. [50.131.89.155]) by mx.google.com with ESMTPSA id v4sm30128880pbs.10.2014.12.27.00.09.28 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 27 Dec 2014 00:09:29 -0800 (PST) Date: Sat, 27 Dec 2014 03:09:26 -0500 From: Noah Misch To: Adam Brightwell Cc: PostgreSQL Hackers Subject: Re: CATUPDATE confusion? Message-ID: <20141227080926.GA2035611@tornado.leadboat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Pg-Spam-Score: -2.7 (--) 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 Mon, Nov 24, 2014 at 04:28:46PM -0500, Adam Brightwell wrote: > So, where I find this confusing is that the documentation supports this > functionality and the check keeps superuser separate from CATUPDATE... > however... comments and implementation in user.c state/do the opposite and > couple them together. > > Documentation: > http://www.postgresql.org/docs/9.4/static/catalog-pg-authid.html - "Role > can update system catalogs directly. (Even a superuser cannot do this > unless this column is true)" > > src/backend/commands/user.c > > /* superuser gets catupdate right by default */ > new_record[Anum_pg_authid_rolcatupdate - 1] = BoolGetDatum(issuper); > > and... > > /* > * issuper/createrole/catupdate/etc > * > * XXX It's rather unclear how to handle catupdate. It's probably best to > * keep it equal to the superuser status, otherwise you could end up with > * a situation where no existing superuser can alter the catalogs, > * including pg_authid! > */ > if (issuper >= 0) > { > new_record[Anum_pg_authid_rolsuper - 1] = BoolGetDatum(issuper > 0); > new_record_repl[Anum_pg_authid_rolsuper - 1] = true; > > new_record[Anum_pg_authid_rolcatupdate - 1] = BoolGetDatum(issuper > 0); > new_record_repl[Anum_pg_authid_rolcatupdate - 1] = true; > } That documentation is correct as far it goes. It does neglect to mention that, as you have discovered, any CREATE ROLE or ALTER ROLE [NO]SUPERUSER will change rolcatupdate to match. > Perhaps this is not an issue but it seemed odd to me, especially after > giving Peter's comment more thought. So, I suppose the question is whether > or not a superuser check should be added to 'has_rolcatupdate' or not? I I would not. PostgreSQL has had this feature since day one (original name "usecatupd"). It has two use cases, (1) giving effect to non-superuser catalog grants and (2) preventing a narrow class of superuser mistakes. We wouldn't add such a thing today, but one can safely ignore its existence. Making has_rolcatupdate() approve superusers unconditionally would exclude use case (2). Neither use case is valuable, but if I had to pick, (2) is more valuable than (1). > believe I understand the reasoning for coupling the two at role > creation/alter time, however, is there really a case where a superuser > wouldn't be allowed to bypass this check? Based on the comments, there > seems like there is potentially enough concern to allow it. And if it is > allowed, couldn't CATUPDATE then be treated like every other attribute and > the coupling with superuser removed? Thoughts? A superuser always has _some_ way to bypass the check, if nothing else by loading a C-language function to update pg_authid. The user.c code you quoted ensures that, if the DBA manages to remove rolcatupdate from every user, a simple CREATE ROLE or ALTER ROLE can fix things. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers