Thread: PostgreSQL 8.0.3, AIX 5.1, getaddrinfo, AI_NUMERICHOST

PostgreSQL 8.0.3, AIX 5.1, getaddrinfo, AI_NUMERICHOST

From
"Logan O'Sullivan Bruns"
Date:
Hello everyone,

I ran into a minor bug with PostgreSQL 8.0.3 compiled with xlc on AIX
5.1 (5100-04). Basically it worked fine connecting via unix domain
sockets but when you connected to it using TCP/IP with JDBC the child
process would SEGV. I tracked the problem to a call to getaddrinfo
while evaluating the host based access control rules.

The code in function parse_hba on line 752 of hba.c sets the ai_flags
member of the addrinfo struct to AI_NUMERICHOST. This is eventually
passed into a call to getaddrinfo that results in the SEGV. The manual
page from the box implies that at least this version of AIX does not
the AI_NUMERICHOST flag. (As opposed to, say, Solaris which clearly
does.)

Ifdefing the code so that ai_flags is set to zero on AIX fixes the
problem.

Anyway, I hope this is helpful to someone or the right place to send
such notes. Please let me know if you need any additional information.

Thanks,
  logan


Re: PostgreSQL 8.0.3, AIX 5.1, getaddrinfo, AI_NUMERICHOST

From
"Mohan, Ross"
Date:
Wow, nice catch, nice analysis. Checking now whether my AIX5.2/3 boxes
set this correctly.


-----Original Message-----
From: pgsql-ports-owner@postgresql.org [mailto:pgsql-ports-owner@postgresql.org] On Behalf Of Logan O'Sullivan Bruns
Sent: Wednesday, August 03, 2005 8:04 PM
To: pgsql-ports@postgresql.org
Subject: [PORTS] PostgreSQL 8.0.3, AIX 5.1, getaddrinfo, AI_NUMERICHOST


Hello everyone,

I ran into a minor bug with PostgreSQL 8.0.3 compiled with xlc on AIX 5.1 (5100-04). Basically it worked fine
connectingvia unix domain sockets but when you connected to it using TCP/IP with JDBC the child process would SEGV. I
trackedthe problem to a call to getaddrinfo while evaluating the host based access control rules. 

The code in function parse_hba on line 752 of hba.c sets the ai_flags member of the addrinfo struct to AI_NUMERICHOST.
Thisis eventually passed into a call to getaddrinfo that results in the SEGV. The manual page from the box implies that
atleast this version of AIX does not the AI_NUMERICHOST flag. (As opposed to, say, Solaris which clearly 
does.)

Ifdefing the code so that ai_flags is set to zero on AIX fixes the problem.

Anyway, I hope this is helpful to someone or the right place to send such notes. Please let me know if you need any
additionalinformation. 

Thanks,
  logan


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Re: PostgreSQL 8.0.3, AIX 5.1, getaddrinfo, AI_NUMERICHOST

From
"Mohan, Ross"
Date:
Apparently something amiss.

even on AIX5.3, the getaddrinfo.h is ONLY present courtesy of PG distro.


I found that odd.


But: it's there, and it does the right thing (ver8.0.2)


-----Original Message-----
From: pgsql-ports-owner@postgresql.org [mailto:pgsql-ports-owner@postgresql.org] On Behalf Of Mohan, Ross
Sent: Monday, August 08, 2005 10:20 AM
To: pgsql-ports@postgresql.org
Subject: Re: [PORTS] PostgreSQL 8.0.3, AIX 5.1, getaddrinfo, AI_NUMERICHOST


Wow, nice catch, nice analysis. Checking now whether my AIX5.2/3 boxes set this correctly.


-----Original Message-----
From: pgsql-ports-owner@postgresql.org [mailto:pgsql-ports-owner@postgresql.org] On Behalf Of Logan O'Sullivan Bruns
Sent: Wednesday, August 03, 2005 8:04 PM
To: pgsql-ports@postgresql.org
Subject: [PORTS] PostgreSQL 8.0.3, AIX 5.1, getaddrinfo, AI_NUMERICHOST


Hello everyone,

I ran into a minor bug with PostgreSQL 8.0.3 compiled with xlc on AIX 5.1 (5100-04). Basically it worked fine
connectingvia unix domain sockets but when you connected to it using TCP/IP with JDBC the child process would SEGV. I
trackedthe problem to a call to getaddrinfo while evaluating the host based access control rules. 

The code in function parse_hba on line 752 of hba.c sets the ai_flags member of the addrinfo struct to AI_NUMERICHOST.
Thisis eventually passed into a call to getaddrinfo that results in the SEGV. The manual page from the box implies that
atleast this version of AIX does not the AI_NUMERICHOST flag. (As opposed to, say, Solaris which clearly 
does.)

Ifdefing the code so that ai_flags is set to zero on AIX fixes the problem.

Anyway, I hope this is helpful to someone or the right place to send such notes. Please let me know if you need any
additionalinformation. 

Thanks,
  logan


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

Re: PostgreSQL 8.0.3, AIX 5.1, getaddrinfo, AI_NUMERICHOST

From
"Logan O'Sullivan Bruns"
Date:
I only have access to AIX5.1. On 5.1 the relevant prototype and
defines are in netdb.h.

The man page for has:

struct addrinfo {

  int               ai_flags;          /* AI_PASSIVE, AI_CANONNAME */

Note the absence of AI_NUMERICHOST. It isn't mentioned anywhere in the
man page but it is present in the header. Perhaps it wasn't a complete
implementation for 5.1 but they fixed it by 5.3?

  - logan

On Mon, Aug 08, 2005 at 06:30:01PM -0000, Mohan, Ross wrote:
> Apparently something amiss.
>
> even on AIX5.3, the getaddrinfo.h is ONLY present courtesy of PG distro.
>
>
> I found that odd.
>
>
> But: it's there, and it does the right thing (ver8.0.2)
>
>
> -----Original Message-----
> From: pgsql-ports-owner@postgresql.org [mailto:pgsql-ports-owner@postgresql.org] On Behalf Of Mohan, Ross
> Sent: Monday, August 08, 2005 10:20 AM
> To: pgsql-ports@postgresql.org
> Subject: Re: [PORTS] PostgreSQL 8.0.3, AIX 5.1, getaddrinfo, AI_NUMERICHOST
>
>
> Wow, nice catch, nice analysis. Checking now whether my AIX5.2/3 boxes set this correctly.
>
>
> -----Original Message-----
> From: pgsql-ports-owner@postgresql.org [mailto:pgsql-ports-owner@postgresql.org] On Behalf Of Logan O'Sullivan Bruns
> Sent: Wednesday, August 03, 2005 8:04 PM
> To: pgsql-ports@postgresql.org
> Subject: [PORTS] PostgreSQL 8.0.3, AIX 5.1, getaddrinfo, AI_NUMERICHOST
>
>
> Hello everyone,
>
> I ran into a minor bug with PostgreSQL 8.0.3 compiled with xlc on AIX 5.1 (5100-04). Basically it worked fine
connectingvia unix domain sockets but when you connected to it using TCP/IP with JDBC the child process would SEGV. I
trackedthe problem to a call to getaddrinfo while evaluating the host based access control rules. 
>
> The code in function parse_hba on line 752 of hba.c sets the ai_flags member of the addrinfo struct to
AI_NUMERICHOST.This is eventually passed into a call to getaddrinfo that results in the SEGV. The manual page from the
boximplies that at least this version of AIX does not the AI_NUMERICHOST flag. (As opposed to, say, Solaris which
clearly
> does.)
>
> Ifdefing the code so that ai_flags is set to zero on AIX fixes the problem.
>
> Anyway, I hope this is helpful to someone or the right place to send such notes. Please let me know if you need any
additionalinformation. 
>
> Thanks,
>   logan
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
>        choose an index scan if your joining column's datatypes do not
>        match
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faq

Re: PostgreSQL 8.0.3, AIX 5.1, getaddrinfo, AI_NUMERICHOST

From
Tom Lane
Date:
"Logan O'Sullivan Bruns" <logan@gedanken.org> writes:
> I only have access to AIX5.1. On 5.1 the relevant prototype and
> defines are in netdb.h.

> The man page for has:

> struct addrinfo {
>   int               ai_flags;          /* AI_PASSIVE, AI_CANONNAME */

> Note the absence of AI_NUMERICHOST. It isn't mentioned anywhere in the
> man page but it is present in the header.

Defined how?

We do have

#ifndef AI_NUMERICHOST
#define AI_NUMERICHOST 0
#endif

in our own code, so we should do the right thing on platforms that don't
define the symbol.  If AIX 5.1 defines the symbol and then chokes when
you use it, that's a bug to take up with IBM, not us.

            regards, tom lane

Re: PostgreSQL 8.0.3, AIX 5.1, getaddrinfo, AI_NUMERICHOST

From
"Mohan, Ross"
Date:
"Yea, what he said" ;-)


I found the working stuff in getaddrinfo.h in PG distro only.

However, in NETDB.H as Logan noted, it is there on my 5.3 AIX:

....
/* Flag definitions for addrinfo hints in protocol-independent name/addr/service service. RFC2133 */
/* Also flag definitions for getipnodebyname  RFC 2553  */
#define AI_CANONNAME    0x01    /* canonical name to be included in return */
#define AI_PASSIVE      0x02    /* prepare return for call to bind() */
#define AI_NUMERICHOST  0x04    /* RFC 2553, nodename is a numeric host address string */
#define AI_ADDRCONFIG   0x08    /* RFC 2553, source address family configured */
#define AI_V4MAPPED     0x10    /* RFC 2553, accept v4 mapped addresses */
#define AI_ALL          0x20    /* RFC 2553, accept all addresses */
#define AI_NUMERICSERV  0x40    /* RFC 2553, service name is a numeric string */
#define AI_DEFAULT      (AI_V4MAPPED | AI_ADDRCONFIG)     /* RFC 2553 */
.....



I wonder if the 4 vice 0 is an issue....think not, b/c the
PG distro header has a good IFDEF stanza for this....




-----Original Message-----
From:    Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent:    Mon 08-Aug-05 5:06 PM
To:    Logan O'Sullivan Bruns
Cc:    Mohan, Ross; pgsql-ports@postgresql.org
Subject:    Re: [PORTS] PostgreSQL 8.0.3, AIX 5.1, getaddrinfo, AI_NUMERICHOST
"Logan O'Sullivan Bruns" <logan@gedanken.org> writes:
> I only have access to AIX5.1. On 5.1 the relevant prototype and
> defines are in netdb.h.

> The man page for has:

> struct addrinfo {
>   int               ai_flags;          /* AI_PASSIVE, AI_CANONNAME */

> Note the absence of AI_NUMERICHOST. It isn't mentioned anywhere in the
> man page but it is present in the header.

Defined how?

We do have

#ifndef AI_NUMERICHOST
#define AI_NUMERICHOST 0
#endif

in our own code, so we should do the right thing on platforms that don't
define the symbol.  If AIX 5.1 defines the symbol and then chokes when
you use it, that's a bug to take up with IBM, not us.

            regards, tom lane




Re: PostgreSQL 8.0.3, AIX 5.1, getaddrinfo, AI_NUMERICHOST

From
"Logan O'Sullivan Bruns"
Date:
For AIX 5.1, if I compile it as is with the 4 value then it SEGVs but
it is fine if I set it to zero. They have the define in the header but
not in the manual page. My guess is that at least in 5.1 it is an
incomplete implementation. The header more accurately reflects the RFC
then the actual implementation.

I do agree though it isn't postgres's fault and it sounds like it is
fixed in AIX 5.3 anyway.

Thanks,
  logan

On Mon, Aug 08, 2005 at 10:04:24PM -0000, Mohan, Ross wrote:
> "Yea, what he said" ;-)
>
>
> I found the working stuff in getaddrinfo.h in PG distro only.
>
> However, in NETDB.H as Logan noted, it is there on my 5.3 AIX:
>
> ....
> /* Flag definitions for addrinfo hints in protocol-independent name/addr/service service. RFC2133 */
> /* Also flag definitions for getipnodebyname  RFC 2553  */
> #define AI_CANONNAME    0x01    /* canonical name to be included in return */
> #define AI_PASSIVE      0x02    /* prepare return for call to bind() */
> #define AI_NUMERICHOST  0x04    /* RFC 2553, nodename is a numeric host address string */
> #define AI_ADDRCONFIG   0x08    /* RFC 2553, source address family configured */
> #define AI_V4MAPPED     0x10    /* RFC 2553, accept v4 mapped addresses */
> #define AI_ALL          0x20    /* RFC 2553, accept all addresses */
> #define AI_NUMERICSERV  0x40    /* RFC 2553, service name is a numeric string */
> #define AI_DEFAULT      (AI_V4MAPPED | AI_ADDRCONFIG)     /* RFC 2553 */
> .....
>
>
>
> I wonder if the 4 vice 0 is an issue....think not, b/c the
> PG distro header has a good IFDEF stanza for this....
>
>
>
>
> -----Original Message-----
> From:    Tom Lane [mailto:tgl@sss.pgh.pa.us]
> Sent:    Mon 08-Aug-05 5:06 PM
> To:    Logan O'Sullivan Bruns
> Cc:    Mohan, Ross; pgsql-ports@postgresql.org
> Subject:    Re: [PORTS] PostgreSQL 8.0.3, AIX 5.1, getaddrinfo, AI_NUMERICHOST
> "Logan O'Sullivan Bruns" <logan@gedanken.org> writes:
> > I only have access to AIX5.1. On 5.1 the relevant prototype and
> > defines are in netdb.h.
>
> > The man page for has:
>
> > struct addrinfo {
> >   int               ai_flags;          /* AI_PASSIVE, AI_CANONNAME */
>
> > Note the absence of AI_NUMERICHOST. It isn't mentioned anywhere in the
> > man page but it is present in the header.
>
> Defined how?
>
> We do have
>
> #ifndef AI_NUMERICHOST
> #define AI_NUMERICHOST 0
> #endif
>
> in our own code, so we should do the right thing on platforms that don't
> define the symbol.  If AIX 5.1 defines the symbol and then chokes when
> you use it, that's a bug to take up with IBM, not us.
>
>             regards, tom lane
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend