Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XMPbG-0001Jl-O0 for pgsql-bugs@arkaria.postgresql.org; Tue, 26 Aug 2014 22:52:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XMPbG-0003sM-6i for pgsql-bugs@arkaria.postgresql.org; Tue, 26 Aug 2014 22:52:26 +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 1XMPbE-0003pV-Rr for pgsql-bugs@postgresql.org; Tue, 26 Aug 2014 22:52:25 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1XMPb9-00013D-5S for pgsql-bugs@postgresql.org; Tue, 26 Aug 2014 22:52:22 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1XMPb6-00069C-3R; Tue, 26 Aug 2014 18:52:16 -0400 Date: Tue, 26 Aug 2014 18:52:16 -0400 From: Bruce Momjian To: Magnus Hagander Cc: sys-milan@statpro.com, pgsql-bugs Subject: Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser Message-ID: <20140826225216.GI14956@momjian.us> References: <20140207101636.26701.59633@wrigleys.postgresql.org> <20140417000206.GV7443@momjian.us> <20140418145323.GB28349@momjian.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="K8nIJk4ghYZn606h" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20140418145323.GB28349@momjian.us> User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --K8nIJk4ghYZn606h Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Fri, Apr 18, 2014 at 10:53:23AM -0400, Bruce Momjian wrote: > On Fri, Apr 18, 2014 at 03:11:44PM +0200, Magnus Hagander wrote: > > Is this correct?  Do we have proper super-user restrictions on all the > > right fields now? > > > > > > I'm not sure what the security problem would be for allowing non-superusers to > > run pg_is_xlog_replay_paused(). And if there are none, there is no reason why > > the function should be restricted like that. > > > >  Also, looking at that specific documentation page, ISTM it needs a better way > > to show which functions actually *do* require superuser privileges. In some > > groups it states which do require it, and in some where it doesn't. Perhaps we > > should add a column to each of the tables with a yes/no value indicating if > > superuser is required for that specific function? Or at least have every table > > be prefixed by a statement saying which require superuser. > > Well, right now we seem to have an inconsistent setup that is being > complained about regularly. Who can review it all and make a > recommendation? Should we just hold all this for 9.5? I have developed the attached patch. I marked the xlog replay pause/resume functions as super-user, and marked the replication slots as super-user. I don't see any other place that is missing or needs a section heading. I don't think we need a new column as most functions in a section are either super-user only or not. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + --K8nIJk4ghYZn606h Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="superuser.diff" diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml new file mode 100644 index c715ca2..1cc80a5 *** a/doc/src/sgml/func.sgml --- b/doc/src/sgml/func.sgml *************** postgres=# SELECT * FROM pg_xlogfile_nam *** 16469,16475 **** pg_xlog_replay_pause() void ! Pauses recovery immediately. --- 16469,16475 ---- pg_xlog_replay_pause() void ! Pauses recovery immediately (restricted to superusers). *************** postgres=# SELECT * FROM pg_xlogfile_nam *** 16477,16483 **** pg_xlog_replay_resume() void ! Restarts recovery if it was paused. --- 16477,16483 ---- pg_xlog_replay_resume() void ! Restarts recovery if it was paused (restricted to superusers). *************** postgres=# SELECT * FROM pg_xlogfile_nam *** 16585,16591 **** for controlling and interacting with replication features. See and for information about the ! underlying features. --- 16585,16591 ---- for controlling and interacting with replication features. See and for information about the ! underlying features. Use of these functions is restricted to superusers. diff --git a/src/backend/access/transam/xlogfuncs.c b/src/backend/access/transam/xlogfuncs.c new file mode 100644 index f186468..133143d *** a/src/backend/access/transam/xlogfuncs.c --- b/src/backend/access/transam/xlogfuncs.c *************** pg_xlog_replay_resume(PG_FUNCTION_ARGS) *** 382,392 **** Datum pg_is_xlog_replay_paused(PG_FUNCTION_ARGS) { - if (!superuser()) - ereport(ERROR, - (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - (errmsg("must be superuser to control recovery")))); - if (!RecoveryInProgress()) ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), --- 382,387 ---- --K8nIJk4ghYZn606h Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs --K8nIJk4ghYZn606h--