10
10
*
11
11
*
12
12
* 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 $
14
14
*
15
15
*-------------------------------------------------------------------------
16
16
*/
44
44
/* Standard TCP port number for Ident service. Assigned by IANA */
45
45
#define IDENT_PORT 113
46
46
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
-
53
47
/* This is used to separate values in multi-valued column strings */
54
48
#define MULTI_VALUE_SEP "\001"
55
49
65
59
* one token, since blank lines are not entered in the data structure.
66
60
*/
67
61
68
- /* pre-parsed content of CONF_FILE and corresponding line #s */
62
+ /* pre-parsed content of HBA config file and corresponding line #s */
69
63
static List * hba_lines = NIL ;
70
64
static List * hba_line_nums = NIL ;
71
65
72
- /* pre-parsed content of USERMAP_FILE and corresponding line #s */
66
+ /* pre-parsed content of ident usermap file and corresponding line #s */
73
67
static List * ident_lines = NIL ;
74
68
static List * ident_line_nums = NIL ;
75
69
@@ -743,8 +737,9 @@ parse_hba(List *line, int line_num, hbaPort *port,
743
737
{
744
738
ereport (LOG ,
745
739
(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 ))));
748
743
if (cidr_slash )
749
744
* cidr_slash = '/' ;
750
745
if (gai_result )
@@ -777,8 +772,9 @@ parse_hba(List *line, int line_num, hbaPort *port,
777
772
{
778
773
ereport (LOG ,
779
774
(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 ))));
782
778
if (gai_result )
783
779
freeaddrinfo_all (hints .ai_family , gai_result );
784
780
goto hba_other_error ;
@@ -791,8 +787,8 @@ parse_hba(List *line, int line_num, hbaPort *port,
791
787
{
792
788
ereport (LOG ,
793
789
(errcode (ERRCODE_CONFIG_FILE_ERROR ),
794
- errmsg ("IP address and mask do not match in pg_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 )));
796
792
goto hba_other_error ;
797
793
}
798
794
}
@@ -849,13 +845,14 @@ parse_hba(List *line, int line_num, hbaPort *port,
849
845
if (line_item )
850
846
ereport (LOG ,
851
847
(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 ))));
854
851
else
855
852
ereport (LOG ,
856
853
(errcode (ERRCODE_CONFIG_FILE_ERROR ),
857
- errmsg ("missing field in pg_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 )));
859
856
860
857
/* Come here if suitable message already logged */
861
858
hba_other_error :
@@ -1030,42 +1027,25 @@ load_user(void)
1030
1027
1031
1028
/*
1032
1029
* 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.
1037
1030
*/
1038
1031
void
1039
1032
load_hba (void )
1040
1033
{
1041
- FILE * file ; /* The config file we have to read */
1042
- char * conf_file ; /* The name of the config file */
1034
+ FILE * file ;
1043
1035
1044
1036
if (hba_lines || hba_line_nums )
1045
1037
free_lines (& hba_lines , & hba_line_nums );
1046
1038
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... */
1060
1041
if (file == NULL )
1061
1042
ereport (FATAL ,
1062
1043
(errcode_for_file_access (),
1063
1044
errmsg ("could not open configuration file \"%s\": %m" ,
1064
- conf_file )));
1045
+ HbaFileName )));
1065
1046
1066
1047
tokenize_file (file , & hba_lines , & hba_line_nums );
1067
1048
FreeFile (file );
1068
- pfree (conf_file );
1069
1049
}
1070
1050
1071
1051
@@ -1121,13 +1101,14 @@ parse_ident_usermap(List *line, int line_number, const char *usermap_name,
1121
1101
if (line_item )
1122
1102
ereport (LOG ,
1123
1103
(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 ))));
1126
1107
else
1127
1108
ereport (LOG ,
1128
1109
(errcode (ERRCODE_CONFIG_FILE_ERROR ),
1129
- errmsg ("missing entry in pg_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 )));
1131
1112
1132
1113
* error_p = true;
1133
1114
}
@@ -1191,38 +1172,25 @@ check_ident_usermap(const char *usermap_name,
1191
1172
void
1192
1173
load_ident (void )
1193
1174
{
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 ;
1197
1176
1198
1177
if (ident_lines || ident_line_nums )
1199
1178
free_lines (& ident_lines , & ident_line_nums );
1200
1179
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" );
1213
1181
if (file == NULL )
1214
1182
{
1183
+ /* not fatal ... we just won't do any special ident maps */
1215
1184
ereport (LOG ,
1216
1185
(errcode_for_file_access (),
1217
1186
errmsg ("could not open Ident usermap file \"%s\": %m" ,
1218
- map_file )));
1187
+ IdentFileName )));
1219
1188
}
1220
1189
else
1221
1190
{
1222
1191
tokenize_file (file , & ident_lines , & ident_line_nums );
1223
1192
FreeFile (file );
1224
1193
}
1225
- pfree (map_file );
1226
1194
}
1227
1195
1228
1196
0 commit comments