Re: [HACKERS] [BUGS] 7.4 beta 1: SET log_statement=false

Поиск
Список
Период
Сортировка
Искать

Re: [HACKERS] [BUGS] 7.4 beta 1: SET log_statement=false

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Tom Lane wrote:
> Bruce Momjian  writes:
> > Yes, I have been thinking of that.  The big question is whether a
> > non-super user can control the reset value?
> 
> He could (via PGOPTIONS) ... but since he can only increase it, there is
> nothing to fear.

I have followed your suggestion and applied the following patch to have
PGC_USERLIMIT track reset_val rather than session_val.  I now see that
all sources set the default, except SET:

        makeDefault = changeVal && (source <= PGC_S_OVERRIDE) && (value != NULL$

        typedef enum
        {
            PGC_S_DEFAULT,              /* wired-in default */
            PGC_S_ENV_VAR,              /* postmaster environment variable */
            PGC_S_FILE,                 /* postgresql.conf */
            PGC_S_ARGV,                 /* postmaster command line */
            PGC_S_UNPRIVILEGED,         /* dividing line for USERLIMIT */
            PGC_S_DATABASE,             /* per-database setting */
            PGC_S_USER,                 /* per-user setting */
            PGC_S_CLIENT,               /* from client connection request */
            PGC_S_OVERRIDE,             /* special case to forcibly set default$
            PGC_S_SESSION               /* SET command */
        } GucSource;

This fixes the reported problem where log_statement couldn't be turned
on then off in a session by a non-super user.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: src/backend/utils/misc/guc.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/utils/misc/guc.c,v
retrieving revision 1.151
diff -c -c -r1.151 guc.c
*** src/backend/utils/misc/guc.c	26 Aug 2003 15:38:25 -0000	1.151
--- src/backend/utils/misc/guc.c	31 Aug 2003 04:41:15 -0000
***************
*** 2556,2562 ****
  					/* Limit non-superuser changes */
  					if (record->context == PGC_USERLIMIT &&
  						source > PGC_S_UNPRIVILEGED &&
! 						newval < conf->session_val &&
  						!superuser())
  					{
  						ereport(elevel,
--- 2556,2562 ----
  					/* Limit non-superuser changes */
  					if (record->context == PGC_USERLIMIT &&
  						source > PGC_S_UNPRIVILEGED &&
! 						newval < conf->reset_val &&
  						!superuser())
  					{
  						ereport(elevel,
***************
*** 2569,2576 ****
  					/* Allow admin to override non-superuser setting */
  					if (record->context == PGC_USERLIMIT &&
  						source < PGC_S_UNPRIVILEGED &&
! 						record->session_source > PGC_S_UNPRIVILEGED &&
! 						newval > conf->session_val &&
  						!superuser())
  						DoIt = DoIt_orig;
  				}
--- 2569,2576 ----
  					/* Allow admin to override non-superuser setting */
  					if (record->context == PGC_USERLIMIT &&
  						source < PGC_S_UNPRIVILEGED &&
! 						record->reset_source > PGC_S_UNPRIVILEGED &&
! 						newval > conf->reset_val &&
  						!superuser())
  						DoIt = DoIt_orig;
  				}
***************
*** 2652,2659 ****
  					/* Limit non-superuser changes */
  					if (record->context == PGC_USERLIMIT &&
  						source > PGC_S_UNPRIVILEGED &&
! 						conf->session_val != 0 &&
! 						(newval > conf->session_val || newval == 0) &&
  						!superuser())
  					{
  						ereport(elevel,
--- 2652,2659 ----
  					/* Limit non-superuser changes */
  					if (record->context == PGC_USERLIMIT &&
  						source > PGC_S_UNPRIVILEGED &&
! 						conf->reset_val != 0 &&
! 						(newval > conf->reset_val || newval == 0) &&
  						!superuser())
  					{
  						ereport(elevel,
***************
*** 2666,2673 ****
  					/* Allow admin to override non-superuser setting */
  					if (record->context == PGC_USERLIMIT &&
  						source < PGC_S_UNPRIVILEGED &&
! 						record->session_source > PGC_S_UNPRIVILEGED &&
! 						newval < conf->session_val &&
  						!superuser())
  						DoIt = DoIt_orig;
  				}
--- 2666,2673 ----
  					/* Allow admin to override non-superuser setting */
  					if (record->context == PGC_USERLIMIT &&
  						source < PGC_S_UNPRIVILEGED &&
! 						record->reset_source > PGC_S_UNPRIVILEGED &&
! 						newval < conf->reset_val &&
  						!superuser())
  						DoIt = DoIt_orig;
  				}
***************
*** 2749,2755 ****
  					/* Limit non-superuser changes */
  					if (record->context == PGC_USERLIMIT &&
  						source > PGC_S_UNPRIVILEGED &&
! 						newval > conf->session_val &&
  						!superuser())
  					{
  						ereport(elevel,
--- 2749,2755 ----
  					/* Limit non-superuser changes */
  					if (record->context == PGC_USERLIMIT &&
  						source > PGC_S_UNPRIVILEGED &&
! 						newval > conf->reset_val &&
  						!superuser())
  					{
  						ereport(elevel,
***************
*** 2762,2769 ****
  					/* Allow admin to override non-superuser setting */
  					if (record->context == PGC_USERLIMIT &&
  						source < PGC_S_UNPRIVILEGED &&
! 						record->session_source > PGC_S_UNPRIVILEGED &&
! 						newval < conf->session_val &&
  						!superuser())
  						DoIt = DoIt_orig;
  				}
--- 2762,2769 ----
  					/* Allow admin to override non-superuser setting */
  					if (record->context == PGC_USERLIMIT &&
  						source < PGC_S_UNPRIVILEGED &&
! 						record->reset_source > PGC_S_UNPRIVILEGED &&
! 						newval < conf->reset_val &&
  						!superuser())
  						DoIt = DoIt_orig;
  				}
***************
*** 2860,2867 ****
  						}
  						/* Allow admin to override non-superuser setting */
  						if (source < PGC_S_UNPRIVILEGED &&
! 							record->session_source > PGC_S_UNPRIVILEGED &&
! 							newval < conf->session_val &&
  							!superuser())
  							DoIt = DoIt_orig;
  					}
--- 2860,2867 ----
  						}
  						/* Allow admin to override non-superuser setting */
  						if (source < PGC_S_UNPRIVILEGED &&
! 							record->reset_source > PGC_S_UNPRIVILEGED &&
! 							newval < conf->reset_val &&
  							!superuser())
  							DoIt = DoIt_orig;
  					}

Re: [HACKERS] [BUGS] 7.4 beta 1: SET log_statement=false

От:
Bertrand Petit <pgsql-bugs@phoe.frmug.org>
Дата:
On Thu, Sep 04, 2003 at 01:06:15AM -0400, Bruce Momjian wrote:
> I have followed your suggestion and applied the following patch to have
> PGC_USERLIMIT track reset_val rather than session_val.  I now see that
> all sources set the default, except SET:

	I just updated my CVS workign directory tree. Your patch as
expected.

	Thanks!
	Bertrand.

-- 
%!PS
297.6 420.9 translate 90 rotate 0 setgray gsave 0 1 1{pop 0 180 moveto 100
180 170 100 170 -10 curveto 180 -9 180 -9 190 -10 curveto 190 100 100 180
0 180 curveto fill 180 rotate}for grestore/Bookman-LightItalic findfont
240 scalefont setfont -151.536392 -63.7998886 moveto (bp)show showpage
FAQ