7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.30 1998/03/15 08:18:03 scrappy Exp $
10
+ * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.31 1998/06/13 04:27:15 momjian Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -154,8 +154,8 @@ read_hba_entry2(FILE *file, UserAuth *userauth_p, char auth_arg[],
154
154
155
155
156
156
static void
157
- process_hba_record (FILE * file , SockAddr * raddr , const char database [],
158
- bool * matches_p , bool * error_p ,
157
+ process_hba_record (FILE * file , SockAddr * raddr , const char user [],
158
+ const char database [], bool * matches_p , bool * error_p ,
159
159
UserAuth * userauth_p , char auth_arg [])
160
160
{
161
161
/*---------------------------------------------------------------------------
@@ -210,7 +210,8 @@ process_hba_record(FILE *file, SockAddr *raddr, const char database[],
210
210
* sort of connection, ignore it.
211
211
*/
212
212
213
- if ((strcmp (db , database ) != 0 && strcmp (db , "all" ) != 0 ) ||
213
+ if ((strcmp (buf , database ) != 0 && strcmp (buf , "all" ) != 0 &&
214
+ (strcmp (buf , "sameuser" ) != 0 || strcmp (user , database ) != 0 )) ||
214
215
raddr -> sa .sa_family != AF_UNIX )
215
216
return ;
216
217
}
@@ -269,7 +270,8 @@ process_hba_record(FILE *file, SockAddr *raddr, const char database[],
269
270
* sort of connection, ignore it.
270
271
*/
271
272
272
- if ((strcmp (db , database ) != 0 && strcmp (db , "all" ) != 0 ) ||
273
+ if ((strcmp (buf , database ) != 0 && strcmp (buf , "all" ) != 0 &&
274
+ (strcmp (buf , "sameuser" ) != 0 || strcmp (user , database ) != 0 )) ||
273
275
raddr -> sa .sa_family != AF_INET ||
274
276
((file_ip_addr .s_addr ^ raddr -> in .sin_addr .s_addr ) & mask .s_addr ) != 0x0000 )
275
277
return ;
@@ -297,9 +299,9 @@ process_hba_record(FILE *file, SockAddr *raddr, const char database[],
297
299
298
300
299
301
static void
300
- process_open_config_file (FILE * file , SockAddr * raddr , const char database [],
301
- bool * host_ok_p , UserAuth * userauth_p ,
302
- char auth_arg [])
302
+ process_open_config_file (FILE * file , SockAddr * raddr , const char user [],
303
+ const char database [], bool * host_ok_p ,
304
+ UserAuth * userauth_p , char auth_arg [])
303
305
{
304
306
/*---------------------------------------------------------------------------
305
307
This function does the same thing as find_hba_entry, only with
@@ -333,7 +335,7 @@ process_open_config_file(FILE *file, SockAddr *raddr, const char database[],
333
335
read_through_eol (file );
334
336
else
335
337
{
336
- process_hba_record (file , raddr , database ,
338
+ process_hba_record (file , raddr , user , database ,
337
339
& found_entry , & error , userauth_p , auth_arg );
338
340
}
339
341
}
@@ -353,8 +355,8 @@ process_open_config_file(FILE *file, SockAddr *raddr, const char database[],
353
355
354
356
355
357
static void
356
- find_hba_entry (SockAddr * raddr , const char database [], bool * host_ok_p ,
357
- UserAuth * userauth_p , char auth_arg [])
358
+ find_hba_entry (SockAddr * raddr , const char user [], const char database [] ,
359
+ bool * host_ok_p , UserAuth * userauth_p , char auth_arg [])
358
360
{
359
361
/*--------------------------------------------------------------------------
360
362
Read the config file and find an entry that allows connection from
@@ -428,7 +430,7 @@ find_hba_entry(SockAddr *raddr, const char database[], bool *host_ok_p,
428
430
}
429
431
else
430
432
{
431
- process_open_config_file (file , raddr , database , host_ok_p , userauth_p ,
433
+ process_open_config_file (file , raddr , user , database , host_ok_p , userauth_p ,
432
434
auth_arg );
433
435
FreeFile (file );
434
436
}
@@ -1054,8 +1056,8 @@ GetCharSetByHost(char TableName[], int host, const char DataDir[])
1054
1056
#endif
1055
1057
1056
1058
extern int
1057
- hba_getauthmethod (SockAddr * raddr , char * database , char * auth_arg ,
1058
- UserAuth * auth_method )
1059
+ hba_getauthmethod (SockAddr * raddr , char * user , char * database ,
1060
+ char * auth_arg , UserAuth * auth_method )
1059
1061
{
1060
1062
/*---------------------------------------------------------------------------
1061
1063
Determine what authentication method should be used when accessing database
@@ -1066,7 +1068,7 @@ hba_getauthmethod(SockAddr *raddr, char *database, char *auth_arg,
1066
1068
1067
1069
host_ok = false;
1068
1070
1069
- find_hba_entry (raddr , database , & host_ok , auth_method , auth_arg );
1071
+ find_hba_entry (raddr , user , database , & host_ok , auth_method , auth_arg );
1070
1072
1071
1073
return (host_ok ? STATUS_OK : STATUS_ERROR );
1072
1074
}
0 commit comments