Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csvnf-0006DK-CO for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Mar 2017 18:24:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1csvne-0006AY-HP for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Mar 2017 18:24:58 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1csvm8-0002CH-9U for pgsql-hackers@postgresql.org; Tue, 28 Mar 2017 18:23:24 +0000 Received: from tamriel.snowman.net ([72.66.115.51]) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csvm1-0005LR-Oc for pgsql-hackers@postgresql.org; Tue, 28 Mar 2017 18:23:23 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 4991E5F796; Tue, 28 Mar 2017 14:22:46 -0400 (EDT) Date: Tue, 28 Mar 2017 14:22:46 -0400 From: Stephen Frost To: Dave Page Cc: Robert Haas , Mark Dilger , Peter Eisentraut , PostgreSQL Hackers Subject: Re: Monitoring roles patch Message-ID: <20170328182246.GG9812@tamriel.snowman.net> References: <20170323122335.GK9812@tamriel.snowman.net> <20170328173721.GF9812@tamriel.snowman.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="/zZuIhN9RW1uCJRx" Content-Disposition: inline In-Reply-To: X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/3.13.0-91-generic (x86_64) X-Uptime: 14:06:36 up 262 days, 19:30, 23 users, load average: 0.10, 0.08, 0.12 User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -1.9 (-) 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 --/zZuIhN9RW1uCJRx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Dave, * Dave Page (dpage@pgadmin.org) wrote: > OK, so before I start hacking again, here's a proposal based on my > understanding of folks comments, and so open questions. If I can get > agreement and answers, I'll be able to break out vi again without > (hopefully) too many more revisions: >=20 > pg_read_all_stats: Will have C-coded access to pg_stats views and > pg_*_size that are currently hard-coded to superuser Not quite sure what you mean here by 'C-coded access to pg_stats *views*', but I'm guessing that isn't exactly what you meant since I'm sure we aren't going to change how view permissions are done in this patch. I take it you mean access to the functions under the views? If so, I believe this is correct. > pg_read_all_settings: Will have C-coded access to read GUCs that are > currently hard-coded to the superuser Right. > pg_monitor: Will include pg_read_all_stats and pg_read_all_settings, > and all explicitly GRANTable rights, e.g. in contrib modules. Right. > Patch to be rebased on Simon's updated version. Right. > Questions: >=20 > - pg_stat_statements has a hard-coded superuser check. Shall I remove > that, and include REVOKE ALL FROM ALL and then GRANT to pg_monitor? pg_stat_statements shouldn't have ever had that superuser check and it shouldn't have ever used '=3D=3D' for the user check, it should have been using 'has_privs_of_role()' from the start, which means that the superuser check isn't necessary. I don't think we should remove that check, nor should we REVOKE EXECUTE =66rom public for the function. We *should* add a hard-coded role check to allow another role which isn't a member of the role whose query it is to view the query. That shouldn't be pg_monitor, of course (as discussed). I don't think pg_read_all_stats or pg_read_all_settings really covers this case either- this is more like pg_read_all_queries and should also be used for pg_stat_activity. That would then be granted to pg_monitor. > - pgrowlocks has hard-coded access to superuser and users with SELECT > on the table being examined. How should this be handled? I don't see any hard-coded superuser check? There is a pg_class_aclcheck() for SELECT rights on the table. I like the idea of having another way to grant access to run this function on a table besides giving SELECT rights on the entire table to the user. This would fall under the mandate of the role described in your next bullet, in my view. > - Stephen suggested a separate role for functions that can lock > tables. Is this still desired, or shall we just grant access to > pg_monitor (I think the latter is fine)? Right, I was thinking something like pg_stat_all_tables or pg_stat_scan_tables or similar. We would add that (perhaps also with a SELECT check like pgrowlocks has) for the other functions like pgstattuple and pg_freespacemap and pg_visibility. > - Based on Peter's concerns, is pg_read_all_stats the right name? > Maybe pg_read_monitoring_stats? I'd rather not get too wrapped up in the naming.. The documentation is the important part here, imv. Thanks! Stephen --/zZuIhN9RW1uCJRx Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJY2qn1AAoJEO1sijiDR2RVZ4QQAI/ovHX3HtObElbd/g4RHd3o xQ5yVWm91nqRWFZld9nLbbQgAHCyuEJRE0BpjSI/jnFPwrdlNHs9ivqbWt47qPFL u+1txO3wPwDhdFYVCg8KBpqjjkCIBZaCMSWsJNUHQnD1Sf40lL1TPK811BL/gkly 0K+57ZrzT5OTQkIKhRGkfyOZ3CiwibgHqw1Rmb05c4pHU8OE4F+khbMHqGtAvfei eeMEIWX8roC/TDxZz7rSZtNB9V1G9Ka10oXAHg05AM4r4/q7ypfR/jDRi+X9P9xY 8BMjDblyChh6gESZU0dXkrt1sYUCiUpwI5EQv4OHzxBqCLeR3Lqkt9IuOmOY2+kt EVzgxHdEEZMdyrT4ubsCHNoS/+1CbxB362h3uz9KOjEACVQ3zW1Mr1mCkuAFPJ5d XkpBw7ycWqxffo+N1+HUexAqd4TgX0iPChZ+x+CgRTSp/C2c/quG0SpQyE1Skg57 DB3c0U7NC0ycU7lZMeGKrc+6UbTMTtU6SOWytIEVRGiGbssOa9e/fwELDglbUvwe 15E7NjgLiQNuPEbiLdilZiHNvQjQYtrdcE55uDionAdnzKCn3OWwss/44iNTxe4W 8HEuB0Pw1Woku3pCd80HhB1sF/ETrN0m2DTclT+f2S26Sg8W/npzh4q93fh+kWWb ZBHnholCkT0zpgyj9VGb =Dskz -----END PGP SIGNATURE----- --/zZuIhN9RW1uCJRx--