1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-26 23:43:30 +03:00

Use GRANT system to manage access to sensitive functions

Now that pg_dump will properly dump out any ACL changes made to
functions which exist in pg_catalog, switch to using the GRANT system
to manage access to those functions.

This means removing 'if (!superuser()) ereport()' checks from the
functions themselves and then REVOKEing EXECUTE right from 'public' for
these functions in system_views.sql.

Reviews by Alexander Korotkov, Jose Luis Tallon
This commit is contained in:
Stephen Frost
2016-04-06 21:45:32 -04:00
parent 23f34fa4ba
commit 1574783b4c
7 changed files with 81 additions and 75 deletions

View File

@@ -1217,6 +1217,9 @@ pgstat_drop_relation(Oid relid)
* pgstat_reset_counters() -
*
* Tell the statistics collector to reset counters for our database.
*
* Permission checking for this function is managed through the normal
* GRANT system.
* ----------
*/
void
@@ -1227,11 +1230,6 @@ pgstat_reset_counters(void)
if (pgStatSock == PGINVALID_SOCKET)
return;
if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to reset statistics counters")));
pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_RESETCOUNTER);
msg.m_databaseid = MyDatabaseId;
pgstat_send(&msg, sizeof(msg));
@@ -1241,6 +1239,9 @@ pgstat_reset_counters(void)
* pgstat_reset_shared_counters() -
*
* Tell the statistics collector to reset cluster-wide shared counters.
*
* Permission checking for this function is managed through the normal
* GRANT system.
* ----------
*/
void
@@ -1251,11 +1252,6 @@ pgstat_reset_shared_counters(const char *target)
if (pgStatSock == PGINVALID_SOCKET)
return;
if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to reset statistics counters")));
if (strcmp(target, "archiver") == 0)
msg.m_resettarget = RESET_ARCHIVER;
else if (strcmp(target, "bgwriter") == 0)
@@ -1274,6 +1270,9 @@ pgstat_reset_shared_counters(const char *target)
* pgstat_reset_single_counter() -
*
* Tell the statistics collector to reset a single counter.
*
* Permission checking for this function is managed through the normal
* GRANT system.
* ----------
*/
void
@@ -1284,11 +1283,6 @@ pgstat_reset_single_counter(Oid objoid, PgStat_Single_Reset_Type type)
if (pgStatSock == PGINVALID_SOCKET)
return;
if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to reset statistics counters")));
pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_RESETSINGLECOUNTER);
msg.m_databaseid = MyDatabaseId;
msg.m_resettype = type;