10
10
* Written by Peter Eisentraut <peter_e@gmx.net>.
11
11
*
12
12
* IDENTIFICATION
13
- * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.245 2004/10/17 22:01:51 tgl Exp $
13
+ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.246 2004/10/22 19:48:19 tgl Exp $
14
14
*
15
15
*--------------------------------------------------------------------
16
16
*/
@@ -1522,7 +1522,8 @@ static struct config_string ConfigureNamesString[] =
1522
1522
gettext_noop ("If a dynamically loadable module needs to be opened and "
1523
1523
"the specified name does not have a directory component (i.e., the "
1524
1524
"name does not contain a slash), the system will search this path for "
1525
- "the specified file." )
1525
+ "the specified file." ),
1526
+ GUC_SUPERUSER_ONLY
1526
1527
},
1527
1528
& Dynamic_library_path ,
1528
1529
"$libdir" , NULL , NULL
@@ -1531,7 +1532,8 @@ static struct config_string ConfigureNamesString[] =
1531
1532
{
1532
1533
{"krb_server_keyfile" , PGC_POSTMASTER , CONN_AUTH_SECURITY ,
1533
1534
gettext_noop ("Sets the location of the Kerberos server key file." ),
1534
- NULL
1535
+ NULL ,
1536
+ GUC_SUPERUSER_ONLY
1535
1537
},
1536
1538
& pg_krb_server_keyfile ,
1537
1539
PG_KRB_SRVTAB , NULL , NULL
@@ -1608,7 +1610,7 @@ static struct config_string ConfigureNamesString[] =
1608
1610
{"preload_libraries" , PGC_POSTMASTER , RESOURCES_KERNEL ,
1609
1611
gettext_noop ("Lists shared libraries to preload into server." ),
1610
1612
NULL ,
1611
- GUC_LIST_INPUT | GUC_LIST_QUOTE
1613
+ GUC_LIST_INPUT | GUC_LIST_QUOTE | GUC_SUPERUSER_ONLY
1612
1614
},
1613
1615
& preload_libraries_string ,
1614
1616
"" , NULL , NULL
@@ -1680,15 +1682,17 @@ static struct config_string ConfigureNamesString[] =
1680
1682
{"log_directory" , PGC_SIGHUP , LOGGING_WHERE ,
1681
1683
gettext_noop ("Sets the destination directory for log files." ),
1682
1684
gettext_noop ("May be specified as relative to the data directory "
1683
- "or as absolute path." )
1685
+ "or as absolute path." ),
1686
+ GUC_SUPERUSER_ONLY
1684
1687
},
1685
1688
& Log_directory ,
1686
1689
"pg_log" , assign_canonical_path , NULL
1687
1690
},
1688
1691
{
1689
1692
{"log_filename" , PGC_SIGHUP , LOGGING_WHERE ,
1690
1693
gettext_noop ("Sets the file name pattern for log files." ),
1691
- NULL
1694
+ NULL ,
1695
+ GUC_SUPERUSER_ONLY
1692
1696
},
1693
1697
& Log_filename ,
1694
1698
"postgresql-%Y-%m-%d_%H%M%S.log" , NULL , NULL
@@ -1747,7 +1751,8 @@ static struct config_string ConfigureNamesString[] =
1747
1751
{
1748
1752
{"unix_socket_directory" , PGC_POSTMASTER , CONN_AUTH_SETTINGS ,
1749
1753
gettext_noop ("Sets the directory where the Unix-domain socket will be created." ),
1750
- NULL
1754
+ NULL ,
1755
+ GUC_SUPERUSER_ONLY
1751
1756
},
1752
1757
& UnixSocketDir ,
1753
1758
"" , assign_canonical_path , NULL
@@ -1774,7 +1779,7 @@ static struct config_string ConfigureNamesString[] =
1774
1779
1775
1780
{
1776
1781
{"custom_variable_classes" , PGC_POSTMASTER , RESOURCES_KERNEL ,
1777
- gettext_noop ("Sets the list of known custom variable classes" ),
1782
+ gettext_noop ("Sets the list of known custom variable classes. " ),
1778
1783
NULL ,
1779
1784
GUC_LIST_INPUT | GUC_LIST_QUOTE
1780
1785
},
@@ -1785,7 +1790,8 @@ static struct config_string ConfigureNamesString[] =
1785
1790
{
1786
1791
{"data_directory" , PGC_POSTMASTER , FILE_LOCATIONS ,
1787
1792
gettext_noop ("Sets the server's data directory." ),
1788
- NULL
1793
+ NULL ,
1794
+ GUC_SUPERUSER_ONLY
1789
1795
},
1790
1796
& data_directory ,
1791
1797
NULL , NULL , NULL
@@ -1795,7 +1801,7 @@ static struct config_string ConfigureNamesString[] =
1795
1801
{"config_file" , PGC_POSTMASTER , FILE_LOCATIONS ,
1796
1802
gettext_noop ("Sets the server's main configuration file." ),
1797
1803
NULL ,
1798
- GUC_DISALLOW_IN_FILE
1804
+ GUC_DISALLOW_IN_FILE | GUC_SUPERUSER_ONLY
1799
1805
},
1800
1806
& ConfigFileName ,
1801
1807
NULL , NULL , NULL
@@ -1804,7 +1810,8 @@ static struct config_string ConfigureNamesString[] =
1804
1810
{
1805
1811
{"hba_file" , PGC_POSTMASTER , FILE_LOCATIONS ,
1806
1812
gettext_noop ("Sets the server's \"hba\" configuration file" ),
1807
- NULL
1813
+ NULL ,
1814
+ GUC_SUPERUSER_ONLY
1808
1815
},
1809
1816
& HbaFileName ,
1810
1817
NULL , NULL , NULL
@@ -1813,7 +1820,8 @@ static struct config_string ConfigureNamesString[] =
1813
1820
{
1814
1821
{"ident_file" , PGC_POSTMASTER , FILE_LOCATIONS ,
1815
1822
gettext_noop ("Sets the server's \"ident\" configuration file" ),
1816
- NULL
1823
+ NULL ,
1824
+ GUC_SUPERUSER_ONLY
1817
1825
},
1818
1826
& IdentFileName ,
1819
1827
NULL , NULL , NULL
@@ -1822,7 +1830,8 @@ static struct config_string ConfigureNamesString[] =
1822
1830
{
1823
1831
{"external_pid_file" , PGC_POSTMASTER , FILE_LOCATIONS ,
1824
1832
gettext_noop ("Writes the postmaster PID to the specified file." ),
1825
- NULL
1833
+ NULL ,
1834
+ GUC_SUPERUSER_ONLY
1826
1835
},
1827
1836
& external_pid_file ,
1828
1837
NULL , assign_canonical_path , NULL
@@ -1874,6 +1883,8 @@ static int guc_var_compare(const void *a, const void *b);
1874
1883
static int guc_name_compare (const char * namea , const char * nameb );
1875
1884
static void push_old_value (struct config_generic * gconf );
1876
1885
static void ReportGUCOption (struct config_generic * record );
1886
+ static void ShowGUCConfigOption (const char * name , DestReceiver * dest );
1887
+ static void ShowAllGUCConfig (DestReceiver * dest );
1877
1888
static char * _ShowOption (struct config_generic * record );
1878
1889
static bool check_userlimit_privilege (struct config_generic * record ,
1879
1890
GucSource source , int elevel );
@@ -3966,6 +3977,10 @@ GetConfigOption(const char *name)
3966
3977
ereport (ERROR ,
3967
3978
(errcode (ERRCODE_UNDEFINED_OBJECT ),
3968
3979
errmsg ("unrecognized configuration parameter \"%s\"" , name )));
3980
+ if ((record -> flags & GUC_SUPERUSER_ONLY ) && !superuser ())
3981
+ ereport (ERROR ,
3982
+ (errcode (ERRCODE_INSUFFICIENT_PRIVILEGE ),
3983
+ errmsg ("must be superuser to examine \"%s\"" , name )));
3969
3984
3970
3985
switch (record -> vartype )
3971
3986
{
@@ -4002,6 +4017,10 @@ GetConfigOptionResetString(const char *name)
4002
4017
ereport (ERROR ,
4003
4018
(errcode (ERRCODE_UNDEFINED_OBJECT ),
4004
4019
errmsg ("unrecognized configuration parameter \"%s\"" , name )));
4020
+ if ((record -> flags & GUC_SUPERUSER_ONLY ) && !superuser ())
4021
+ ereport (ERROR ,
4022
+ (errcode (ERRCODE_INSUFFICIENT_PRIVILEGE ),
4023
+ errmsg ("must be superuser to examine \"%s\"" , name )));
4005
4024
4006
4025
switch (record -> vartype )
4007
4026
{
@@ -4268,8 +4287,7 @@ define_custom_variable(struct config_generic * variable)
4268
4287
}
4269
4288
4270
4289
static void
4271
- init_custom_variable (
4272
- struct config_generic * gen ,
4290
+ init_custom_variable (struct config_generic * gen ,
4273
4291
const char * name ,
4274
4292
const char * short_desc ,
4275
4293
const char * long_desc ,
@@ -4462,7 +4480,7 @@ ResetPGVariable(const char *name)
4462
4480
/*
4463
4481
* SHOW command
4464
4482
*/
4465
- void
4483
+ static void
4466
4484
ShowGUCConfigOption (const char * name , DestReceiver * dest )
4467
4485
{
4468
4486
TupOutputState * tstate ;
@@ -4490,9 +4508,10 @@ ShowGUCConfigOption(const char *name, DestReceiver *dest)
4490
4508
/*
4491
4509
* SHOW ALL command
4492
4510
*/
4493
- void
4511
+ static void
4494
4512
ShowAllGUCConfig (DestReceiver * dest )
4495
4513
{
4514
+ bool am_superuser = superuser ();
4496
4515
int i ;
4497
4516
TupOutputState * tstate ;
4498
4517
TupleDesc tupdesc ;
@@ -4512,7 +4531,8 @@ ShowAllGUCConfig(DestReceiver *dest)
4512
4531
{
4513
4532
struct config_generic * conf = guc_variables [i ];
4514
4533
4515
- if (conf -> flags & GUC_NO_SHOW_ALL )
4534
+ if ((conf -> flags & GUC_NO_SHOW_ALL ) ||
4535
+ ((conf -> flags & GUC_SUPERUSER_ONLY ) && !am_superuser ))
4516
4536
continue ;
4517
4537
4518
4538
/* assign to the values array */
@@ -4544,6 +4564,10 @@ GetConfigOptionByName(const char *name, const char **varname)
4544
4564
ereport (ERROR ,
4545
4565
(errcode (ERRCODE_UNDEFINED_OBJECT ),
4546
4566
errmsg ("unrecognized configuration parameter \"%s\"" , name )));
4567
+ if ((record -> flags & GUC_SUPERUSER_ONLY ) && !superuser ())
4568
+ ereport (ERROR ,
4569
+ (errcode (ERRCODE_INSUFFICIENT_PRIVILEGE ),
4570
+ errmsg ("must be superuser to examine \"%s\"" , name )));
4547
4571
4548
4572
if (varname )
4549
4573
* varname = record -> name ;
@@ -4567,7 +4591,13 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
4567
4591
conf = guc_variables [varnum ];
4568
4592
4569
4593
if (noshow )
4570
- * noshow = (conf -> flags & GUC_NO_SHOW_ALL ) ? true : false;
4594
+ {
4595
+ if ((conf -> flags & GUC_NO_SHOW_ALL ) ||
4596
+ ((conf -> flags & GUC_SUPERUSER_ONLY ) && !superuser ()))
4597
+ * noshow = true;
4598
+ else
4599
+ * noshow = false;
4600
+ }
4571
4601
4572
4602
/* first get the generic attributes */
4573
4603
0 commit comments