From: | Marko Kreen <marko(at)l-t(dot)ee> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Peter Eisentraut <peter_e(at)gmx(dot)net>, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org |
Subject: | Re: use GUC for cmdline |
Date: | 2001-06-22 08:52:42 |
Message-ID: | 20010622105242.A14582@l-t.ee |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-patches |
On Thu, Jun 21, 2001 at 09:09:20PM -0400, Tom Lane wrote:
> Marko Kreen <marko(at)l-t(dot)ee> writes:
> >> Uh, removing the security checks is NOT what I had in mind. Wasn't
> >> my example clear enough?
>
> > Ee, this is done in set_config_option?
>
> No, you still need the if (secure) --- because that changes while
> we're reading the switches. *If* secure is true, it's okay to set
> the option with PGC_POSTMASTER context.
secure_ctx changes too. it will be PGC_BACKEND after '-p'.
I did it this way, because I imagined the 'if (secure)' as a
permission check for non-GUC variables. For GUC the permission
checks should be done in guc.c, this also means clearer code
in postgres.c. Now that I think about it, it could be
even simplified to the following.
This is mostly matter of taste, and I can ofcourse do it your
way, but ATM it seems to me you missed the secure_ctx = ctx;
line in last patch.
--
marko
diff -u src/backend/tcop/postgres.c src/backend/tcop/postgres.c
--- src/backend/tcop/postgres.c
+++ src/backend/tcop/postgres.c
@@ -1120,8 +1120,8 @@
char *potential_DataDir = NULL;
- /* all options are allowed if not under postmaster */
- ctx = IsUnderPostmaster ? PGC_BACKEND : PGC_POSTMASTER;
+ /* all options are allowed if not under postmaster or until -p */
+ ctx = PGC_POSTMASTER;
/*
* Catch standard options before doing much else. This even works on
@@ -1207,8 +1207,7 @@
/*
* specify the size of buffer pool
*/
- if (secure)
- SetConfigOption("shared_buffers", optarg, ctx, true);
+ SetConfigOption("shared_buffers", optarg, ctx, true);
break;
case 'C':
@@ -1227,8 +1226,8 @@
case 'd': /* debug level */
tmp = "true";
SetConfigOption("debug_level", optarg, ctx, true);
- if (DebugLvl >= 1);
- SetConfigOption("log_connections", tmp, ctx, true);
+ if (DebugLvl >= 1)
+ SetConfigOption("log_connections", tmp, ctx, true);
if (DebugLvl >= 2)
SetConfigOption("debug_print_query", tmp, ctx, true);
if (DebugLvl >= 3)
@@ -1260,8 +1259,7 @@
/*
* turn off fsync
*/
- if (secure)
- SetConfigOption("fsync", "false", ctx, true);
+ SetConfigOption("fsync", "false", ctx, true);
break;
case 'f':
@@ -1356,6 +1354,7 @@
DBName = strdup(optarg);
secure = false; /* subsequent switches are NOT
* secure */
+ ctx = PGC_BACKEND;
}
break;
diff -u src/backend/utils/misc/guc.c src/backend/utils/misc/guc.c
--- src/backend/utils/misc/guc.c
+++ src/backend/utils/misc/guc.c
@@ -196,7 +196,7 @@
{"fsync", PGC_SIGHUP, &enableFsync, true, NULL},
{"silent_mode", PGC_POSTMASTER, &SilentMode, false, NULL},
- {"log_connections", PGC_SIGHUP, &Log_connections, false, NULL},
+ {"log_connections", PGC_BACKEND, &Log_connections, false, NULL},
{"log_timestamp", PGC_SIGHUP, &Log_timestamp, false, NULL},
{"log_pid", PGC_SIGHUP, &Log_pid, false, NULL},
From | Date | Subject | |
---|---|---|---|
Next Message | RISKO Gergely | 2001-06-22 11:13:50 | Re: nocreatetable for 7.1.2 [patch] |
Previous Message | Rainer Mager | 2001-06-22 04:56:17 | RE: Re: [ADMIN] High memory usage [PATCH] |