On Fri, May 13, 2011 at 00:21, Tom Lane <t...@sss.pgh.pa.us> wrote:
> Magnus Hagander <mag...@hagander.net> writes:
>> On Tue, May 10, 2011 at 05:39, Tom Lane <t...@sss.pgh.pa.us> wrote:
>>> I wouldn't have a problem with making the Windows port throw an error
>>> for "local" lines.  We'd have to fix initdb to remove that line from the
>>> sample file (if it doesn't already), but that's surely not hard.
>
>> It does already (that's what the @remove-line-for-nolocal@ markup in
>> the sample file is for).
>
>> So +1 for making it throw an error.
>
> Although this should be a simple change, I don't want to do it because
> I'm not in a position to test it.  Do you want to take care of it?

Here's a patch that I think does what we want. It works fine on
Windows - I just want to make sure this is what you meant as well?

-- 
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/
commit 4c64761b53f1acec54af3c63b436d9f6defb845c
Author: Magnus Hagander <mag...@hagander.net>
Date:   Mon May 30 20:11:13 2011 +0200

    Refuse "local" lines in pg_hba.conf on platforms that don't support it
    
    This makes the behavior compatible with that of hostssl, which
    also throws an error when there is no SSL support included.

diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c
index c17863f..f3a3b6e 100644
--- a/src/backend/libpq/hba.c
+++ b/src/backend/libpq/hba.c
@@ -824,7 +824,16 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
 	token = lfirst(line_item);
 	if (strcmp(token, "local") == 0)
 	{
+#ifdef HAVE_UNIX_SOCKETS
 		parsedline->conntype = ctLocal;
+#else
+		ereport(LOG,
+				(errcode(ERRCODE_CONFIG_FILE_ERROR),
+				 errmsg("local connections are not supported by this build"),
+				 errcontext("line %d of configuration file \"%s\"",
+							line_num, HbaFileName)));
+		return false;
+#endif
 	}
 	else if (strcmp(token, "host") == 0
 			 || strcmp(token, "hostssl") == 0
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to