*** a/src/backend/utils/adt/misc.c --- b/src/backend/utils/adt/misc.c *************** *** 112,118 **** pg_signal_backend(int pid, int sig) return SIGNAL_BACKEND_ERROR; } ! if (!(superuser() || proc->roleId == GetUserId())) return SIGNAL_BACKEND_NOPERMISSION; /* --- 112,125 ---- return SIGNAL_BACKEND_ERROR; } ! /* ! * Superuser can send signal without restriction, owner can send signals to all ! * users attached to owned databases without superuser, others can signals only to ! * sessions with same account. ! */ ! if (!(superuser() || proc->roleId == GetUserId() ! || (pg_database_ownercheck(proc->databaseId, GetUserId()) ! && !superuser_arg(proc->roleId)))) return SIGNAL_BACKEND_NOPERMISSION; /* *************** *** 151,157 **** pg_cancel_backend(PG_FUNCTION_ARGS) if (r == SIGNAL_BACKEND_NOPERMISSION) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), ! (errmsg("must be superuser or have the same role to cancel queries running in other server processes")))); PG_RETURN_BOOL(r == SIGNAL_BACKEND_SUCCESS); } --- 158,164 ---- if (r == SIGNAL_BACKEND_NOPERMISSION) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), ! (errmsg("must be superuser or database owner or have the same role to cancel queries running in other server processes")))); PG_RETURN_BOOL(r == SIGNAL_BACKEND_SUCCESS); } *************** *** 168,174 **** pg_terminate_backend(PG_FUNCTION_ARGS) if (r == SIGNAL_BACKEND_NOPERMISSION) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), ! (errmsg("must be superuser or have the same role to terminate other server processes")))); PG_RETURN_BOOL(r == SIGNAL_BACKEND_SUCCESS); } --- 175,181 ---- if (r == SIGNAL_BACKEND_NOPERMISSION) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), ! (errmsg("must be superuser or database owner or have the same role to terminate other server processes")))); PG_RETURN_BOOL(r == SIGNAL_BACKEND_SUCCESS); } *** a/src/backend/utils/adt/pgstatfuncs.c --- b/src/backend/utils/adt/pgstatfuncs.c *************** *** 656,663 **** pg_stat_get_activity(PG_FUNCTION_ARGS) else nulls[3] = true; ! /* Values only available to same user or superuser */ ! if (superuser() || beentry->st_userid == GetUserId()) { switch (beentry->st_state) { --- 656,664 ---- else nulls[3] = true; ! /* Values only available to same user or superuser or owner */ ! if (superuser() || beentry->st_userid == GetUserId() ! || pg_database_ownercheck(beentry->st_databaseid, GetUserId())) { switch (beentry->st_state) {