pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #9136: pg_is_xlog_replay_paused() should not need Superuser
7+ messages / 4 participants
[nested] [flat]

* BUG #9136: pg_is_xlog_replay_paused() should not need Superuser
@ 2014-02-07 10:16 sys-milan@statpro.com
  2014-04-17 00:02 ` Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser Bruce Momjian <bruce@momjian.us>
  2014-04-18 15:47 ` Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser Matheus de Oliveira <matioli.matheus@gmail.com>
  0 siblings, 2 replies; 7+ messages in thread

From: sys-milan@statpro.com @ 2014-02-07 10:16 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      9136
Logged by:          Renato Ramonda
Email address:      sys-milan@statpro.com
PostgreSQL version: 9.2.6
Operating system:   Ubuntu 12.04
Description:        

The admin function pg_is_xlog_replay_paused() is read only and can be useful
for monitoring, as such it should NOT require superuser privileges (as it
does now). 

For reference, the read-only functions for monitoring the replication delay
such as pg_current_xlog_location can be executed without superuser
privileges (as remarked by the official documentation here
http://www.postgresql.org/docs/9.1/static/functions-admin.html )



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser
  2014-02-07 10:16 BUG #9136: pg_is_xlog_replay_paused() should not need Superuser sys-milan@statpro.com
@ 2014-04-17 00:02 ` Bruce Momjian <bruce@momjian.us>
  2014-04-18 13:11   ` Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser Magnus Hagander <magnus@hagander.net>
  1 sibling, 1 reply; 7+ messages in thread

From: Bruce Momjian @ 2014-04-17 00:02 UTC (permalink / raw)
  To: sys-milan@statpro.com; +Cc: pgsql-bugs

On Fri, Feb  7, 2014 at 10:16:36AM +0000, sys-milan@statpro.com wrote:
> The following bug has been logged on the website:
> 
> Bug reference:      9136
> Logged by:          Renato Ramonda
> Email address:      sys-milan@statpro.com
> PostgreSQL version: 9.2.6
> Operating system:   Ubuntu 12.04
> Description:        
> 
> The admin function pg_is_xlog_replay_paused() is read only and can be useful
> for monitoring, as such it should NOT require superuser privileges (as it
> does now). 
> 
> For reference, the read-only functions for monitoring the replication delay
> such as pg_current_xlog_location can be executed without superuser
> privileges (as remarked by the official documentation here
> http://www.postgresql.org/docs/9.1/static/functions-admin.html )

Is this correct?  Do we have proper super-user restrictions on all the
right fields now?

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser
  2014-02-07 10:16 BUG #9136: pg_is_xlog_replay_paused() should not need Superuser sys-milan@statpro.com
  2014-04-17 00:02 ` Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser Bruce Momjian <bruce@momjian.us>
@ 2014-04-18 13:11   ` Magnus Hagander <magnus@hagander.net>
  2014-04-18 14:53     ` Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 7+ messages in thread

From: Magnus Hagander @ 2014-04-18 13:11 UTC (permalink / raw)
  To: Bruce Momjian <bruce@momjian.us>; +Cc: sys-milan@statpro.com; pgsql-bugs

On Thu, Apr 17, 2014 at 2:02 AM, Bruce Momjian <bruce@momjian.us> wrote:

> On Fri, Feb  7, 2014 at 10:16:36AM +0000, sys-milan@statpro.com wrote:
> > The following bug has been logged on the website:
> >
> > Bug reference:      9136
> > Logged by:          Renato Ramonda
> > Email address:      sys-milan@statpro.com
> > PostgreSQL version: 9.2.6
> > Operating system:   Ubuntu 12.04
> > Description:
> >
> > The admin function pg_is_xlog_replay_paused() is read only and can be
> useful
> > for monitoring, as such it should NOT require superuser privileges (as it
> > does now).
> >
> > For reference, the read-only functions for monitoring the replication
> delay
> > such as pg_current_xlog_location can be executed without superuser
> > privileges (as remarked by the official documentation here
> > http://www.postgresql.org/docs/9.1/static/functions-admin.html )
>
> 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.

-- 
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser
  2014-02-07 10:16 BUG #9136: pg_is_xlog_replay_paused() should not need Superuser sys-milan@statpro.com
  2014-04-17 00:02 ` Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser Bruce Momjian <bruce@momjian.us>
  2014-04-18 13:11   ` Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser Magnus Hagander <magnus@hagander.net>
@ 2014-04-18 14:53     ` Bruce Momjian <bruce@momjian.us>
  2014-08-26 22:52       ` Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 7+ messages in thread

From: Bruce Momjian @ 2014-04-18 14:53 UTC (permalink / raw)
  To: Magnus Hagander <magnus@hagander.net>; +Cc: sys-milan@statpro.com; pgsql-bugs

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?

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser
  2014-02-07 10:16 BUG #9136: pg_is_xlog_replay_paused() should not need Superuser sys-milan@statpro.com
  2014-04-17 00:02 ` Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser Bruce Momjian <bruce@momjian.us>
  2014-04-18 13:11   ` Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser Magnus Hagander <magnus@hagander.net>
  2014-04-18 14:53     ` Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser Bruce Momjian <bruce@momjian.us>
@ 2014-08-26 22:52       ` Bruce Momjian <bruce@momjian.us>
  2014-08-29 13:05         ` Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 7+ messages in thread

From: Bruce Momjian @ 2014-08-26 22:52 UTC (permalink / raw)
  To: Magnus Hagander <magnus@hagander.net>; +Cc: sys-milan@statpro.com; pgsql-bugs

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  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Attachments:

superuser.diff (text/x-diff, 2.6K) download 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 **** <literal><function>pg_xlog_replay_pause()</function></literal> </entry> <entry><type>void</type></entry> ! <entry>Pauses recovery immediately. </entry> </row> <row> --- 16469,16475 ---- <literal><function>pg_xlog_replay_pause()</function></literal> </entry> <entry><type>void</type></entry> ! <entry>Pauses recovery immediately (restricted to superusers). </entry> </row> <row> *************** postgres=# SELECT * FROM pg_xlogfile_nam *** 16477,16483 **** <literal><function>pg_xlog_replay_resume()</function></literal> </entry> <entry><type>void</type></entry> ! <entry>Restarts recovery if it was paused. </entry> </row> </tbody> --- 16477,16483 ---- <literal><function>pg_xlog_replay_resume()</function></literal> </entry> <entry><type>void</type></entry> ! <entry>Restarts recovery if it was paused (restricted to superusers). </entry> </row> </tbody> *************** postgres=# SELECT * FROM pg_xlogfile_nam *** 16585,16591 **** for controlling and interacting with replication features. See <xref linkend="streaming-replication"> and <xref linkend="streaming-replication-slots"> for information about the ! underlying features. </para> <para> --- 16585,16591 ---- for controlling and interacting with replication features. See <xref linkend="streaming-replication"> and <xref linkend="streaming-replication-slots"> for information about the ! underlying features. Use of these functions is restricted to superusers. </para> <para> 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 ----
^ permalink raw reply [nested|flat] 7+ messages in thread

* Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser
  2014-02-07 10:16 BUG #9136: pg_is_xlog_replay_paused() should not need Superuser sys-milan@statpro.com
  2014-04-17 00:02 ` Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser Bruce Momjian <bruce@momjian.us>
  2014-04-18 13:11   ` Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser Magnus Hagander <magnus@hagander.net>
  2014-04-18 14:53     ` Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser Bruce Momjian <bruce@momjian.us>
  2014-08-26 22:52       ` Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser Bruce Momjian <bruce@momjian.us>
@ 2014-08-29 13:05         ` Bruce Momjian <bruce@momjian.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Bruce Momjian @ 2014-08-29 13:05 UTC (permalink / raw)
  To: Magnus Hagander <magnus@hagander.net>; +Cc: sys-milan@statpro.com; pgsql-bugs

On Tue, Aug 26, 2014 at 06:52:16PM -0400, Bruce Momjian wrote:
> 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.

Patch applied, backpatch to 9.4.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: BUG #9136: pg_is_xlog_replay_paused() should not need Superuser
  2014-02-07 10:16 BUG #9136: pg_is_xlog_replay_paused() should not need Superuser sys-milan@statpro.com
@ 2014-04-18 15:47 ` Matheus de Oliveira <matioli.matheus@gmail.com>
  1 sibling, 0 replies; 7+ messages in thread

From: Matheus de Oliveira @ 2014-04-18 15:47 UTC (permalink / raw)
  To: sys-milan@statpro.com; +Cc: pgsql-bugs

On Fri, Feb 7, 2014 at 8:16 AM, <sys-milan@statpro.com> wrote:

> The admin function pg_is_xlog_replay_paused() is read only and can be
> useful
> for monitoring, as such it should NOT require superuser privileges (as it
> does now).
>

Just as an workaround for this situation, you can create a function with
SECURITY DEFINER that wraps the call of pg_is_xlog_replay_paused.

Best regards,
-- 
Matheus de Oliveira
Analista de Banco de Dados
Dextra Sistemas - MPS.Br nível F!
www.dextra.com.br/postgres

^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2014-08-29 13:05 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-02-07 10:16 BUG #9136: pg_is_xlog_replay_paused() should not need Superuser sys-milan@statpro.com
2014-04-17 00:02 ` Bruce Momjian <bruce@momjian.us>
2014-04-18 13:11   ` Magnus Hagander <magnus@hagander.net>
2014-04-18 14:53     ` Bruce Momjian <bruce@momjian.us>
2014-08-26 22:52       ` Bruce Momjian <bruce@momjian.us>
2014-08-29 13:05         ` Bruce Momjian <bruce@momjian.us>
2014-04-18 15:47 ` Matheus de Oliveira <matioli.matheus@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox