Re: [HACKERS] PostgreSQL 8.0.3 and Ipv6 - Mailing list pgsql-patches

From Tom Lane
Subject Re: [HACKERS] PostgreSQL 8.0.3 and Ipv6
Date
Msg-id 16773.1124728213@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] PostgreSQL 8.0.3 and Ipv6  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: [HACKERS] PostgreSQL 8.0.3 and Ipv6  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-patches
Andrew Dunstan <andrew@dunslane.net> writes:
> Try this instead if you prefer.

I thought this was a little bit too trusting about there being a
getaddrinfo to probe, so I tightened it up as per the attached
applied patch.

Where are we at this point on the Windows/IPv6 issue --- are there
more fixes to come, or is it done?

            regards, tom lane


*** src/bin/initdb/initdb.c.orig    Tue Aug  2 11:16:27 2005
--- src/bin/initdb/initdb.c    Mon Aug 22 12:24:42 2005
***************
*** 54,66 ****
  #include <unistd.h>
  #include <locale.h>
  #include <signal.h>
- #include <errno.h>
  #ifdef HAVE_LANGINFO_H
  #include <langinfo.h>
  #endif

  #include "libpq/pqsignal.h"
  #include "mb/pg_wchar.h"
  #include "getopt_long.h"

  #ifndef HAVE_INT_OPTRESET
--- 54,66 ----
  #include <unistd.h>
  #include <locale.h>
  #include <signal.h>
  #ifdef HAVE_LANGINFO_H
  #include <langinfo.h>
  #endif

  #include "libpq/pqsignal.h"
  #include "mb/pg_wchar.h"
+ #include "getaddrinfo.h"
  #include "getopt_long.h"

  #ifndef HAVE_INT_OPTRESET
***************
*** 1210,1220 ****
      conflines = replace_token(conflines,"@remove-line-for-nolocal@","");
  #endif

! #ifndef HAVE_IPV6
      conflines = replace_token(conflines,
                                "host    all         all         ::1",
                                "#host    all         all         ::1");
! #endif

      /* Replace default authentication methods */
      conflines = replace_token(conflines,
--- 1210,1251 ----
      conflines = replace_token(conflines,"@remove-line-for-nolocal@","");
  #endif

! #if defined(HAVE_IPV6) && defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
!     /*
!      * Probe to see if there is really any platform support for IPv6, and
!      * comment out the relevant pg_hba line if not.  This avoids runtime
!      * warnings if getaddrinfo doesn't actually cope with IPv6.  Particularly
!      * useful on Windows, where executables built on a machine with IPv6
!      * may have to run on a machine without.
!      *
!      * We don't bother with testing if we aren't using the system version
!      * of getaddrinfo, since we know our own version doesn't do IPv6.
!      */
!     {
!         struct addrinfo *gai_result;
!         struct addrinfo hints;
!
!         /* for best results, this code should match parse_hba() */
!         hints.ai_flags = AI_NUMERICHOST;
!         hints.ai_family = PF_UNSPEC;
!         hints.ai_socktype = 0;
!         hints.ai_protocol = 0;
!         hints.ai_addrlen = 0;
!         hints.ai_canonname = NULL;
!         hints.ai_addr = NULL;
!         hints.ai_next = NULL;
!
!         if (getaddrinfo("::1", NULL, &hints, &gai_result) != 0)
!             conflines = replace_token(conflines,
!                                       "host    all         all         ::1",
!                                       "#host    all         all         ::1");
!     }
! #else /* !HAVE_IPV6 etc */
!     /* If we didn't compile IPV6 support at all, always comment it out */
      conflines = replace_token(conflines,
                                "host    all         all         ::1",
                                "#host    all         all         ::1");
! #endif /* HAVE_IPV6 etc */

      /* Replace default authentication methods */
      conflines = replace_token(conflines,

pgsql-patches by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: [HACKERS] PostgreSQL 8.0.3 and Ipv6
Next
From: Andrew Dunstan
Date:
Subject: Re: [HACKERS] PostgreSQL 8.0.3 and Ipv6