The original of this seems to have gotten lost in the ether somewhere. It might turn up some day ...


andrew

Tom Lane wrote:

Andrew Dunstan <[EMAIL PROTECTED]> writes:


The attached tiny patch will possibly help to avoid some confusion by Windows users about the "local" line in pg_hba.conf (and thus help reduce queries to us ;-) ).



I was wondering if we could teach initdb to remove that line altogether in Windows installations.





I think this does what Tom and Peter suggested. I don't have a Windows box to test it on, though.


cheers

andrew


Index: src/backend/libpq/pg_hba.conf.sample
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/libpq/pg_hba.conf.sample,v
retrieving revision 1.53
diff -c -w -r1.53 pg_hba.conf.sample
*** src/backend/libpq/pg_hba.conf.sample	26 Aug 2004 16:50:05 -0000	1.53
--- src/backend/libpq/pg_hba.conf.sample	22 Sep 2004 14:17:41 -0000
***************
*** 60,67 ****
  
  # TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
  
! local   all         all                               @authmethod@
! # IPv4-style local connections:
  host    all         all         127.0.0.1/32          @authmethod@
! # IPv6-style local connections:
  host    all         all         ::1/128               @authmethod@
--- 60,68 ----
  
  # TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
  
! @[EMAIL PROTECTED] "local" is for Unix domain socket connections only
! @[EMAIL PROTECTED]   all         all                               @authmethod@
! # IPv4 local connections:
  host    all         all         127.0.0.1/32          @authmethod@
! # IPv6 local connections:
  host    all         all         ::1/128               @authmethod@
Index: src/bin/initdb/initdb.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/initdb/initdb.c,v
retrieving revision 1.54
diff -c -w -r1.54 initdb.c
*** src/bin/initdb/initdb.c	2 Sep 2004 17:58:41 -0000	1.54
--- src/bin/initdb/initdb.c	22 Sep 2004 14:17:42 -0000
***************
*** 147,152 ****
--- 147,153 ----
  static void *xmalloc(size_t size);
  static char *xstrdup(const char *s);
  static char **replace_token(char **lines, char *token, char *replacement);
+ static char **filter_lines_with_token(char **lines, char *token);
  static char **readfile(char *path);
  static void writefile(char *path, char **lines);
  static int	mkdir_p(char *path, mode_t omode);
***************
*** 311,316 ****
--- 312,348 ----
  }
  
  /*
+  * make a copy of lines without any that contain the token
+  * a sort of poor man's grep -v
+  *
+  */
+ 
+ static char **
+ filter_lines_with_token(char **lines, char *token)
+ {
+ 	int			numlines = 1;
+ 	int			i, src, dst;
+ 	char	  **result;
+ 
+ 	for (i = 0; lines[i]; i++)
+ 		numlines++;
+ 
+ 	result = (char **) xmalloc(numlines * sizeof(char *));
+ 
+ 	for (src = 0, dst = 0; src < numlines; src++)
+ 	{
+ 
+ 		if (lines[src] == NULL || strstr(lines[src], token) == NULL)
+ 		{
+ 			result[dst++] = lines[src];
+ 		}
+ 
+ 	}
+ 
+ 	return result;
+ }
+ 
+ /*
   * get the lines from a text file
   */
  static char **
***************
*** 1093,1098 ****
--- 1125,1136 ----
  
  	conflines = readfile(hba_file);
  
+ #ifdef WIN32
+ 	conflines = filter_lines_with_token(conflines,"@remove-line-for-win32@");
+ #else
+ 	conflines = replace_token(conflines,"@remove-line-for-win32@","");
+ #endif
+ 
  #ifndef HAVE_IPV6
  	conflines = replace_token(conflines,
  							  "host    all         all         ::1",

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Reply via email to