static int wal_segment_size;
static bool integer_datetimes;
static int effective_io_concurrency;
-static bool assert_enabled;
+static bool assert_enabled;
/* should be static, but commands/variable.c needs to get at this */
char *role_string;
/* PGC_INTERNAL */ "internal",
/* PGC_POSTMASTER */ "postmaster",
/* PGC_SIGHUP */ "sighup",
+ /* PGC_SU_BACKEND */ "superuser-backend",
/* PGC_BACKEND */ "backend",
/* PGC_SUSET */ "superuser",
/* PGC_USERSET */ "user"
NULL, NULL, NULL
},
{
- {"log_connections", PGC_BACKEND, LOGGING_WHAT,
+ {"log_connections", PGC_SU_BACKEND, LOGGING_WHAT,
gettext_noop("Logs each successful connection."),
NULL
},
NULL, NULL, NULL
},
{
- {"log_disconnections", PGC_BACKEND, LOGGING_WHAT,
+ {"log_disconnections", PGC_SU_BACKEND, LOGGING_WHAT,
gettext_noop("Logs end of a session, including duration."),
NULL
},
SetConfigOption("data_directory", DataDir, PGC_POSTMASTER, PGC_S_OVERRIDE);
/*
- * Now read the config file a second time, allowing any settings in
- * the PG_AUTOCONF_FILENAME file to take effect. (This is pretty ugly,
- * but since we have to determine the DataDir before we can find the
- * autoconf file, the alternatives seem worse.)
+ * Now read the config file a second time, allowing any settings in the
+ * PG_AUTOCONF_FILENAME file to take effect. (This is pretty ugly, but
+ * since we have to determine the DataDir before we can find the autoconf
+ * file, the alternatives seem worse.)
*/
ProcessConfigFile(PGC_POSTMASTER);
* signals to individual backends only.
*/
break;
+ case PGC_SU_BACKEND:
+ /* Reject if we're connecting but user is not superuser */
+ if (context == PGC_BACKEND)
+ {
+ ereport(elevel,
+ (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+ errmsg("permission denied to set parameter \"%s\"",
+ name)));
+ return 0;
+ }
+ /* FALL THRU to process the same as PGC_BACKEND */
case PGC_BACKEND:
if (context == PGC_SIGHUP)
{
/*
- * If a PGC_BACKEND parameter is changed in the config file,
- * we want to accept the new value in the postmaster (whence
- * it will propagate to subsequently-started backends), but
- * ignore it in existing backends. This is a tad klugy, but
- * necessary because we don't re-read the config file during
- * backend start.
+ * If a PGC_BACKEND or PGC_SU_BACKEND parameter is changed in
+ * the config file, we want to accept the new value in the
+ * postmaster (whence it will propagate to
+ * subsequently-started backends), but ignore it in existing
+ * backends. This is a tad klugy, but necessary because we
+ * don't re-read the config file during backend start.
*
* In EXEC_BACKEND builds, this works differently: we load all
* nondefault settings from the CONFIG_EXEC_PARAMS file during
return -1;
#endif
}
- else if (context != PGC_POSTMASTER && context != PGC_BACKEND &&
+ else if (context != PGC_POSTMASTER &&
+ context != PGC_BACKEND &&
+ context != PGC_SU_BACKEND &&
source != PGC_S_CLIENT)
{
ereport(elevel,
if (record == NULL)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
- errmsg("unrecognized configuration parameter \"%s\"", name)));
+ errmsg("unrecognized configuration parameter \"%s\"",
+ name)));
/*
* Don't allow the parameters which can't be set in configuration
if ((record->context == PGC_INTERNAL) ||
(record->flags & GUC_DISALLOW_IN_FILE) ||
(record->flags & GUC_DISALLOW_IN_AUTO_FILE))
- ereport(ERROR,
- (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
- errmsg("parameter \"%s\" cannot be changed",
- name)));
+ ereport(ERROR,
+ (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
+ errmsg("parameter \"%s\" cannot be changed",
+ name)));
if (!validate_conf_option(record, name, value, PGC_S_FILE,
ERROR, true, NULL,
&newextra))
ereport(ERROR,
- (errmsg("invalid value for parameter \"%s\": \"%s\"", name, value)));
+ (errmsg("invalid value for parameter \"%s\": \"%s\"",
+ name, value)));
}
if (Tmpfd < 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("failed to open auto conf temp file \"%s\": %m ",
+ errmsg("failed to open auto conf temp file \"%s\": %m",
AutoConfTmpFileName)));
PG_TRY();
infile = AllocateFile(AutoConfFileName, "r");
if (infile == NULL)
ereport(ERROR,
- (errmsg("failed to open auto conf file \"%s\": %m ",
- AutoConfFileName)));
+ (errmsg("failed to open auto conf file \"%s\": %m",
+ AutoConfFileName)));
/* parse it */
ParseConfigFp(infile, AutoConfFileName, 0, LOG, &head, &tail);
GucContext varscontext;
/*
- * Assert that PGC_BACKEND case in set_config_option() will do the right
- * thing.
+ * Assert that PGC_BACKEND/PGC_SU_BACKEND case in set_config_option() will
+ * do the right thing.
*/
Assert(IsInitProcessingMode());
* certain point in their main loop. It's safer to wait than to read a
* file asynchronously.)
*
- * BACKEND options can only be set at postmaster startup, from the
- * configuration file, or by client request in the connection startup
- * packet (e.g., from libpq's PGOPTIONS variable). Furthermore, an
- * already-started backend will ignore changes to such an option in the
- * configuration file. The idea is that these options are fixed for a
- * given backend once it's started, but they can vary across backends.
+ * BACKEND and SU_BACKEND options can only be set at postmaster startup,
+ * from the configuration file, or by client request in the connection
+ * startup packet (e.g., from libpq's PGOPTIONS variable). SU_BACKEND
+ * options can be set from the startup packet only when the user is a
+ * superuser. Furthermore, an already-started backend will ignore changes
+ * to such an option in the configuration file. The idea is that these
+ * options are fixed for a given backend once it's started, but they can
+ * vary across backends.
*
* SUSET options can be set at postmaster startup, with the SIGHUP
- * mechanism, or from SQL if you're a superuser.
+ * mechanism, or from the startup packet or SQL if you're a superuser.
*
* USERSET options can be set by anyone any time.
*/
PGC_INTERNAL,
PGC_POSTMASTER,
PGC_SIGHUP,
+ PGC_SU_BACKEND,
PGC_BACKEND,
PGC_SUSET,
PGC_USERSET
#define GUC_UNIT_TIME 0x7000 /* mask for MS, S, MIN */
#define GUC_NOT_WHILE_SEC_REST 0x8000 /* can't set if security restricted */
-#define GUC_DISALLOW_IN_AUTO_FILE 0x00010000 /* can't set in PG_AUTOCONF_FILENAME */
+#define GUC_DISALLOW_IN_AUTO_FILE 0x00010000 /* can't set in
+ * PG_AUTOCONF_FILENAME */
/* GUC vars that are actually declared in guc.c, rather than elsewhere */
extern bool log_duration;