Skip to content

Commit c93872d

Browse files
committed
Remove pg_hba.conf 'local' line for Win32 because it doesn't support unix domain
connections. Andrew Dunstan
1 parent 513e89b commit c93872d

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

src/backend/libpq/pg_hba.conf.sample

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@
6060

6161
# TYPE DATABASE USER CIDR-ADDRESS METHOD
6262

63-
local all all @authmethod@
64-
# IPv4-style local connections:
63+
@remove-line-for-win32@# "local" is for Unix domain socket connections only
64+
@remove-line-for-win32@local all all @authmethod@
65+
# IPv4 local connections:
6566
host all all 127.0.0.1/32 @authmethod@
66-
# IPv6-style local connections:
67+
# IPv6 local connections:
6768
host all all ::1/128 @authmethod@

src/bin/initdb/initdb.c

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* Portions Copyright (c) 1994, Regents of the University of California
4040
* Portions taken from FreeBSD.
4141
*
42-
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.54 2004/09/02 17:58:41 tgl Exp $
42+
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.55 2004/10/06 09:01:18 momjian Exp $
4343
*
4444
*-------------------------------------------------------------------------
4545
*/
@@ -147,6 +147,9 @@ char backend_exec[MAXPGPATH];
147147
static void *xmalloc(size_t size);
148148
static char *xstrdup(const char *s);
149149
static char **replace_token(char **lines, char *token, char *replacement);
150+
#ifdef WIN32
151+
static char **filter_lines_with_token(char **lines, char *token);
152+
#endif
150153
static char **readfile(char *path);
151154
static void writefile(char *path, char **lines);
152155
static int mkdir_p(char *path, mode_t omode);
@@ -310,6 +313,34 @@ replace_token(char **lines, char *token, char *replacement)
310313

311314
}
312315

316+
/*
317+
* make a copy of lines without any that contain the token
318+
* a sort of poor man's grep -v
319+
*
320+
*/
321+
#ifdef WIN32
322+
static char **
323+
filter_lines_with_token(char **lines, char *token)
324+
{
325+
int numlines = 1;
326+
int i, src, dst;
327+
char **result;
328+
329+
for (i = 0; lines[i]; i++)
330+
numlines++;
331+
332+
result = (char **) xmalloc(numlines * sizeof(char *));
333+
334+
for (src = 0, dst = 0; src < numlines; src++)
335+
{
336+
if (lines[src] == NULL || strstr(lines[src], token) == NULL)
337+
result[dst++] = lines[src];
338+
}
339+
340+
return result;
341+
}
342+
#endif
343+
313344
/*
314345
* get the lines from a text file
315346
*/
@@ -1093,6 +1124,12 @@ setup_config(void)
10931124

10941125
conflines = readfile(hba_file);
10951126

1127+
#ifdef WIN32
1128+
conflines = filter_lines_with_token(conflines,"@remove-line-for-win32@");
1129+
#else
1130+
conflines = replace_token(conflines,"@remove-line-for-win32@","");
1131+
#endif
1132+
10961133
#ifndef HAVE_IPV6
10971134
conflines = replace_token(conflines,
10981135
"host all all ::1",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy