Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit337ffcd

Browse files
committed
Adjust configuration-files GUC behavior as per my recent proposal.
The vars are renamed to data_directory, config_file, hba_file, andident_file, and are guaranteed to be set to accurate absolute pathsduring postmaster startup.This commit does not yet do anything about hiding path values fromnon-superusers.
1 parent0d069c5 commit337ffcd

File tree

8 files changed

+261
-213
lines changed

8 files changed

+261
-213
lines changed

‎doc/src/sgml/runtime.sgml

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.286 2004/10/08 01:36:31 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.287 2004/10/09 23:12:53 tgl Exp $
33
-->
44

55
<Chapter Id="runtime">
@@ -568,8 +568,8 @@ SET ENABLE_SEQSCAN TO OFF;
568568
<title>File Locations</title>
569569

570570
<variablelist>
571-
<varlistentry id="guc-pgdata" xreflabel="pgdata">
572-
<term><varname>pgdata</varname> (<type>string</type>)</term>
571+
<varlistentry id="guc-data-directory" xreflabel="data-directory">
572+
<term><varname>data_directory</varname> (<type>string</type>)</term>
573573
<listitem>
574574
<para>
575575
Specifies the directory to use for data storage.
@@ -578,36 +578,45 @@ SET ENABLE_SEQSCAN TO OFF;
578578
</listitem>
579579
</varlistentry>
580580

581-
<varlistentry id="guc-hba-conf" xreflabel="hba-conf">
582-
<term><varname>hba_conf</varname> (<type>string</type>)</term>
581+
<varlistentry id="guc-config-file" xreflabel="config-file">
582+
<term><varname>config_file</varname> (<type>string</type>)</term>
583583
<listitem>
584584
<para>
585-
Specifies the file name to use for configuration of host-based
586-
authentication (HBA).
587-
This option can only be set at server start or in the
588-
<filename>postgresql.conf</filename> file.
585+
Specifies the main server configuration file
586+
(customarily called <filename>postgresql.conf</>).
587+
This option can only be set on the postmaster command line.
589588
</para>
590589
</listitem>
591590
</varlistentry>
592591

593-
<varlistentry id="guc-ident-conf" xreflabel="ident-conf">
594-
<term><varname>ident_conf</varname> (<type>string</type>)</term>
592+
<varlistentry id="guc-hba-file" xreflabel="hba-file">
593+
<term><varname>hba_file</varname> (<type>string</type>)</term>
595594
<listitem>
596595
<para>
597-
Specifies the file name to use for configuration of
596+
Specifies the configuration file for host-based authentication.
597+
This option can only be set at server start.
598+
</para>
599+
</listitem>
600+
</varlistentry>
601+
602+
<varlistentry id="guc-ident-file" xreflabel="ident-file">
603+
<term><varname>ident_file</varname> (<type>string</type>)</term>
604+
<listitem>
605+
<para>
606+
Specifies the configuration file for
598607
<application>ident</> authentication.
599-
This option can only be set at server start or in the
600-
<filename>postgresql.conf</filename> file.
608+
This option can only be set at server start.
601609
</para>
602610
</listitem>
603611
</varlistentry>
604612

605-
<varlistentry id="external-pidfile" xreflabel="external-pidfile">
606-
<term><varname>external_pidfile</varname> (<type>string</type>)</term>
613+
<varlistentry id="external-pid-file" xreflabel="external-pid-file">
614+
<term><varname>external_pid_file</varname> (<type>string</type>)</term>
607615
<listitem>
608616
<para>
609-
Specifies the location of an additional <application>postmaster</>
610-
process-id (PID) file for use by server administration programs.
617+
Specifies that the <application>postmaster</> should create an
618+
additional process-id (PID) file for use by server administration
619+
programs.
611620
This option can only be set at server start.
612621
</para>
613622
</listitem>
@@ -616,11 +625,10 @@ SET ENABLE_SEQSCAN TO OFF;
616625

617626
<para>
618627
In a default installation, none of the above options is set explicitly
619-
in the <filename>postgresql.conf</filename> file.In this case, the
628+
in the <filename>postgresql.conf</filename> file.Instead, the
620629
data directory is specified by the <option>-D</option> command-line
621-
option or the <envar>PGDATA</envar> environment variable; there is no
622-
default for it. The configuration files are all placed within the
623-
data directory.
630+
option or the <envar>PGDATA</envar> environment variable, and the
631+
configuration files are all placed within the data directory.
624632
</para>
625633

626634
<para>
@@ -630,27 +638,29 @@ SET ENABLE_SEQSCAN TO OFF;
630638
when they are kept separate.) To do this, the <option>-D</option>
631639
command-line option or <envar>PGDATA</envar> environment variable
632640
must point to the directory containing the configuration files,
633-
and the <varname>pgdata</> option is set in
641+
and the <varname>data_directory</> option is set in
634642
<filename>postgresql.conf</filename> (or on the command line) to show
635-
where the data directory is actually located.
643+
where the data directory is actually located. Notice that
644+
<varname>data_directory</> overrides <option>-D</option> for the location
645+
of the data directory, but not for the location of the configuration
646+
files.
636647
</para>
637648

638649
<para>
639-
If you wish, you can also make the <option>-D</option>
640-
command-line option or <envar>PGDATA</envar> environment variable
641-
point directly to the master configuration file (which then need not be
642-
named <filename>postgresql.conf</filename>). The <varname>pgdata</>
643-
option must be set to determine the data directory location.
644-
The other configuration files will by default be sought
645-
in the data directory.
650+
If you wish, you can specify the configuration file names and locations
651+
individually using the options <varname>config_file</>,
652+
<varname>hba_file</> and/or <varname>ident_file</>.
653+
<varname>config_file</> can only be specified on the
654+
<command>postmaster</command> command line, but the others can be
655+
set within the main configuration file. If all three options plus
656+
<varname>data_directory</> are explicitly set, then it is not necessary
657+
to specify <option>-D</option> or <envar>PGDATA</envar>.
646658
</para>
647659

648660
<para>
649-
With any of these approaches, you can specify the locations of the
650-
secondary configuration files (<filename>pg_hba.conf</> and
651-
<filename>pg_ident.conf</>) by setting <varname>hba_conf</> and/or
652-
<varname>ident_conf</> in the master configuration file. These options
653-
override the normal locations and names of the secondary files.
661+
When setting any of these options, a relative path will be interpreted
662+
with respect to the directory in which the <command>postmaster</command>
663+
is started.
654664
</para>
655665
</sect2>
656666

‎src/backend/libpq/hba.c

Lines changed: 29 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.131 2004/10/08 01:36:34 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.132 2004/10/09 23:12:57 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -44,12 +44,6 @@
4444
/* Standard TCP port number for Ident service.Assigned by IANA */
4545
#defineIDENT_PORT 113
4646

47-
/* Name of the config file*/
48-
#defineCONF_FILE "pg_hba.conf"
49-
50-
/* Name of the usermap file */
51-
#defineUSERMAP_FILE "pg_ident.conf"
52-
5347
/* This is used to separate values in multi-valued column strings */
5448
#defineMULTI_VALUE_SEP "\001"
5549

@@ -65,11 +59,11 @@
6559
* one token, since blank lines are not entered in the data structure.
6660
*/
6761

68-
/* pre-parsed content ofCONF_FILE and corresponding line #s */
62+
/* pre-parsed content ofHBA config file and corresponding line #s */
6963
staticList*hba_lines=NIL;
7064
staticList*hba_line_nums=NIL;
7165

72-
/* pre-parsed content ofUSERMAP_FILE and corresponding line #s */
66+
/* pre-parsed content ofident usermap file and corresponding line #s */
7367
staticList*ident_lines=NIL;
7468
staticList*ident_line_nums=NIL;
7569

@@ -743,8 +737,9 @@ parse_hba(List *line, int line_num, hbaPort *port,
743737
{
744738
ereport(LOG,
745739
(errcode(ERRCODE_CONFIG_FILE_ERROR),
746-
errmsg("invalid IP address \"%s\" in pg_hba.conf file line %d: %s",
747-
token,line_num,gai_strerror(ret))));
740+
errmsg("invalid IP address \"%s\" in \"%s\" line %d: %s",
741+
token,HbaFileName,line_num,
742+
gai_strerror(ret))));
748743
if (cidr_slash)
749744
*cidr_slash='/';
750745
if (gai_result)
@@ -777,8 +772,9 @@ parse_hba(List *line, int line_num, hbaPort *port,
777772
{
778773
ereport(LOG,
779774
(errcode(ERRCODE_CONFIG_FILE_ERROR),
780-
errmsg("invalid IP mask \"%s\" in pg_hba.conf file line %d: %s",
781-
token,line_num,gai_strerror(ret))));
775+
errmsg("invalid IP mask \"%s\" in \"%s\" line %d: %s",
776+
token,HbaFileName,line_num,
777+
gai_strerror(ret))));
782778
if (gai_result)
783779
freeaddrinfo_all(hints.ai_family,gai_result);
784780
gotohba_other_error;
@@ -791,8 +787,8 @@ parse_hba(List *line, int line_num, hbaPort *port,
791787
{
792788
ereport(LOG,
793789
(errcode(ERRCODE_CONFIG_FILE_ERROR),
794-
errmsg("IP address and mask do not match inpg_hba.conf file line %d",
795-
line_num)));
790+
errmsg("IP address and mask do not match in\"%s\" line %d",
791+
HbaFileName,line_num)));
796792
gotohba_other_error;
797793
}
798794
}
@@ -849,13 +845,14 @@ parse_hba(List *line, int line_num, hbaPort *port,
849845
if (line_item)
850846
ereport(LOG,
851847
(errcode(ERRCODE_CONFIG_FILE_ERROR),
852-
errmsg("invalid entry in pg_hba.conf file at line %d, token \"%s\"",
853-
line_num, (char*)lfirst(line_item))));
848+
errmsg("invalid entry in \"%s\" at line %d, token \"%s\"",
849+
HbaFileName,line_num,
850+
(char*)lfirst(line_item))));
854851
else
855852
ereport(LOG,
856853
(errcode(ERRCODE_CONFIG_FILE_ERROR),
857-
errmsg("missing field inpg_hba.conf file at end of line %d",
858-
line_num)));
854+
errmsg("missing field in\"%s\" at end of line %d",
855+
HbaFileName,line_num)));
859856

860857
/* Come here if suitable message already logged */
861858
hba_other_error:
@@ -1030,42 +1027,25 @@ load_user(void)
10301027

10311028
/*
10321029
* Read the config file and create a List of Lists of tokens in the file.
1033-
* If we find a file by the old name of the config file (pg_hba), we issue
1034-
* an error message because it probably needs to be converted.He didn't
1035-
* follow directions and just installed his old hba file in the new database
1036-
* system.
10371030
*/
10381031
void
10391032
load_hba(void)
10401033
{
1041-
FILE*file;/* The config file we have to read */
1042-
char*conf_file;/* The name of the config file */
1034+
FILE*file;
10431035

10441036
if (hba_lines||hba_line_nums)
10451037
free_lines(&hba_lines,&hba_line_nums);
10461038

1047-
if (guc_hbafile)
1048-
{
1049-
/* HBA filename specified in config file */
1050-
conf_file=pstrdup(guc_hbafile);
1051-
}
1052-
else
1053-
{
1054-
/* put together the full pathname to the config file */
1055-
conf_file=palloc(strlen(ConfigDir)+strlen(CONF_FILE)+2);
1056-
sprintf(conf_file,"%s/%s",ConfigDir,CONF_FILE);
1057-
}
1058-
1059-
file=AllocateFile(conf_file,"r");
1039+
file=AllocateFile(HbaFileName,"r");
1040+
/* Failure is fatal since with no HBA entries we can do nothing... */
10601041
if (file==NULL)
10611042
ereport(FATAL,
10621043
(errcode_for_file_access(),
10631044
errmsg("could not open configuration file \"%s\": %m",
1064-
conf_file)));
1045+
HbaFileName)));
10651046

10661047
tokenize_file(file,&hba_lines,&hba_line_nums);
10671048
FreeFile(file);
1068-
pfree(conf_file);
10691049
}
10701050

10711051

@@ -1121,13 +1101,14 @@ parse_ident_usermap(List *line, int line_number, const char *usermap_name,
11211101
if (line_item)
11221102
ereport(LOG,
11231103
(errcode(ERRCODE_CONFIG_FILE_ERROR),
1124-
errmsg("invalid entry in pg_ident.conf file at line %d, token \"%s\"",
1125-
line_number, (constchar*)lfirst(line_item))));
1104+
errmsg("invalid entry in \"%s\" at line %d, token \"%s\"",
1105+
IdentFileName,line_number,
1106+
(constchar*)lfirst(line_item))));
11261107
else
11271108
ereport(LOG,
11281109
(errcode(ERRCODE_CONFIG_FILE_ERROR),
1129-
errmsg("missing entry inpg_ident.conf file at end of line %d",
1130-
line_number)));
1110+
errmsg("missing entry in\"%s\" at end of line %d",
1111+
IdentFileName,line_number)));
11311112

11321113
*error_p= true;
11331114
}
@@ -1191,38 +1172,25 @@ check_ident_usermap(const char *usermap_name,
11911172
void
11921173
load_ident(void)
11931174
{
1194-
FILE*file;/* The map file we have to read */
1195-
char*map_file;/* The name of the map file we have to
1196-
* read */
1175+
FILE*file;
11971176

11981177
if (ident_lines||ident_line_nums)
11991178
free_lines(&ident_lines,&ident_line_nums);
12001179

1201-
if (guc_identfile)
1202-
{
1203-
/* IDENT filename specified in config file */
1204-
map_file=pstrdup(guc_identfile);
1205-
}
1206-
else
1207-
{
1208-
map_file=palloc(strlen(ConfigDir)+strlen(USERMAP_FILE)+2);
1209-
sprintf(map_file,"%s/%s",ConfigDir,USERMAP_FILE);
1210-
}
1211-
1212-
file=AllocateFile(map_file,"r");
1180+
file=AllocateFile(IdentFileName,"r");
12131181
if (file==NULL)
12141182
{
1183+
/* not fatal ... we just won't do any special ident maps */
12151184
ereport(LOG,
12161185
(errcode_for_file_access(),
12171186
errmsg("could not open Ident usermap file \"%s\": %m",
1218-
map_file)));
1187+
IdentFileName)));
12191188
}
12201189
else
12211190
{
12221191
tokenize_file(file,&ident_lines,&ident_line_nums);
12231192
FreeFile(file);
12241193
}
1225-
pfree(map_file);
12261194
}
12271195

12281196

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp