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 */
4444/* Standard TCP port number for Ident service.Assigned by IANA */
4545#define IDENT_PORT 113
4646
47- /* Name of the config file*/
48- #define CONF_FILE "pg_hba.conf"
49-
50- /* Name of the usermap file */
51- #define USERMAP_FILE "pg_ident.conf"
52-
5347/* This is used to separate values in multi-valued column strings */
5448#define MULTI_VALUE_SEP "\001"
5549
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 */
6963static List * hba_lines = NIL ;
7064static List * 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 */
7367static List * ident_lines = NIL ;
7468static List * ident_line_nums = NIL ;
7569
@@ -743,8 +737,9 @@ parse_hba(List *line, int line_num, hbaPort *port,
743737{
744738ereport (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 ))));
748743if (cidr_slash )
749744* cidr_slash = '/' ;
750745if (gai_result )
@@ -777,8 +772,9 @@ parse_hba(List *line, int line_num, hbaPort *port,
777772{
778773ereport (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 ))));
782778if (gai_result )
783779freeaddrinfo_all (hints .ai_family ,gai_result );
784780gotohba_other_error ;
@@ -791,8 +787,8 @@ parse_hba(List *line, int line_num, hbaPort *port,
791787{
792788ereport (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 )));
796792gotohba_other_error ;
797793}
798794}
@@ -849,13 +845,14 @@ parse_hba(List *line, int line_num, hbaPort *port,
849845if (line_item )
850846ereport (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 ))));
854851else
855852ereport (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 */
861858hba_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 */
10381031void
10391032load_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
10441036if (hba_lines || hba_line_nums )
10451037free_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... */
10601041if (file == NULL )
10611042ereport (FATAL ,
10621043(errcode_for_file_access (),
10631044errmsg ("could not open configuration file \"%s\": %m" ,
1064- conf_file )));
1045+ HbaFileName )));
10651046
10661047tokenize_file (file ,& hba_lines ,& hba_line_nums );
10671048FreeFile (file );
1068- pfree (conf_file );
10691049}
10701050
10711051
@@ -1121,13 +1101,14 @@ parse_ident_usermap(List *line, int line_number, const char *usermap_name,
11211101if (line_item )
11221102ereport (LOG ,
11231103(errcode (ERRCODE_CONFIG_FILE_ERROR ),
1124- errmsg ("invalid entry in pg_ident.conf file at line %d, token \"%s\"" ,
1125- line_number , (const char * )lfirst (line_item ))));
1104+ errmsg ("invalid entry in \"%s\" at line %d, token \"%s\"" ,
1105+ IdentFileName ,line_number ,
1106+ (const char * )lfirst (line_item ))));
11261107else
11271108ereport (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,
11911172void
11921173load_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
11981177if (ident_lines || ident_line_nums )
11991178free_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" );
12131181if (file == NULL )
12141182{
1183+ /* not fatal ... we just won't do any special ident maps */
12151184ereport (LOG ,
12161185(errcode_for_file_access (),
12171186errmsg ("could not open Ident usermap file \"%s\": %m" ,
1218- map_file )));
1187+ IdentFileName )));
12191188}
12201189else
12211190{
12221191tokenize_file (file ,& ident_lines ,& ident_line_nums );
12231192FreeFile (file );
12241193}
1225- pfree (map_file );
12261194}
12271195
12281196