Re: odd psql behaviour on OSX - Mailing list pgsql-general

From Steve Atkins
Subject Re: odd psql behaviour on OSX
Date
Msg-id 20020425160419.A16925@blighty.com
Whole thread Raw
In response to Re: odd psql behaviour on OSX  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: odd psql behaviour on OSX  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: odd psql behaviour on OSX  ("Robert J. Sanford, Jr." <rsanford@nolimitsystems.com>)
List pgsql-general
On Thu, Apr 25, 2002 at 05:50:00PM -0400, Tom Lane wrote:
> "Robert J. Sanford, Jr." <rsanford@nolimitsystems.com> writes:
> > i have to say that i don't understand why psql could not see the servers
> > without this. actually, i'm guessing from previous emails that it isn't
> > psql but one of the system libs that psql uses that needs some addresses
> > to be explicity mapped. i just don't understand.
>
> Me either.  You'd likely have more luck asking about it in an OS X
> hackers' forum than here, though.  Just tell 'em the program is trying
> to look up so-and-so with gethostbyname(), and getting a failure return.

Uhm, I've not looked at this bit of psql source code and I've never
worked with OS X, so I may be completely off-base here, but noones
mentioned this possibility yet.

gethostbyname(3) is specced to take a hostname and return hostent.
If you pass it the string "192.168.1.1" it is specced to look up the
*hostname* 192.168.1.1 and return the addresses associated with that
hostname.

This is hidden by the fact that some system resolver libraries
recognise a query for a dotted-quad address and fake up a response,
and still more so by some recursive resolvers that'll do the same
thing.

The robust way to parse a hostname/address passed in by a user is to
attempt an inet_aton or inet_pton on it, and only if that fails attempt
a gethostbyname(3).

Is it possible that this is causing the symptoms here?

Cheers,
  Steve


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: odd psql behaviour on OSX
Next
From: Uros Gruber
Date:
Subject: Auth problem in pg_hdba.conf