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

Commit18627c5

Browse files
committed
Allow the .pgpass hostname to match the default socket directory, as
well as a blank pghost.
1 parent7123349 commit18627c5

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

‎doc/src/sgml/libpq.sgml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.208 2006/05/06 16:25:11 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.209 2006/05/17 21:50:54 momjian Exp $ -->
22

33
<chapter id="libpq">
44
<title><application>libpq</application> - C Library</title>
@@ -4000,9 +4000,9 @@ current connection parameters will be used. (Therefore, put more-specific
40004000
entries first when you are using wildcards.)
40014001
If an entry needs to contain <literal>:</literal> or
40024002
<literal>\</literal>, escape this character with <literal>\</literal>.
4003-
A hostname of <literal>localhost</> matches both <literal>host</> (TCP)
4004-
and <literal>local</> (Unix domain socket) connections coming from the
4005-
local machine.
4003+
A hostname of <literal>localhost</> matches bothTCP<literal>host</> (hostname <literal>localhost</>)
4004+
andUnix domain socket<literal>local</> (<literal>pghost</> empty or the default socket directory)
4005+
connections coming from thelocal machine.
40064006
</para>
40074007

40084008
<para>

‎src/interfaces/libpq/fe-connect.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.328 2006/03/14 22:48:23 tgl Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.329 2006/05/17 21:50:54 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -3106,9 +3106,24 @@ PasswordFromFile(char *hostname, char *port, char *dbname, char *username)
31063106
if (username==NULL||strlen(username)==0)
31073107
returnNULL;
31083108

3109+
/* 'localhost' matches pghost of '' or the default socket directory */
31093110
if (hostname==NULL)
31103111
hostname=DefaultHost;
3112+
elseif (is_absolute_path(hostname))
3113+
{
3114+
charcanon_host[MAXPGPATH];
3115+
charcanon_def_socket[MAXPGPATH];
3116+
3117+
StrNCpy(canon_host,hostname,MAXPGPATH);
3118+
StrNCpy(canon_def_socket,DEFAULT_PGSOCKET_DIR,MAXPGPATH);
31113119

3120+
canonicalize_path(canon_host);
3121+
canonicalize_path(canon_def_socket);
3122+
3123+
if (strcmp(canon_host,canon_def_socket)==0)
3124+
hostname=DefaultHost;
3125+
}
3126+
31123127
if (port==NULL)
31133128
port=DEF_PGPORT_STR;
31143129

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp