Re: odd psql behaviour on OSX

From: Steve Atkins <steve(at)blighty(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: odd psql behaviour on OSX
Date: 2002-04-25 23:04:19
Message-ID: 20020425160419.A16925@blighty.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Apr 25, 2002 at 05:50:00PM -0400, Tom Lane wrote:
> "Robert J. Sanford, Jr." <rsanford(at)nolimitsystems(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Uros Gruber 2002-04-25 23:21:57 Auth problem in pg_hdba.conf
Previous Message Tom Lane 2002-04-25 22:22:28 Re: odd psql behaviour on OSX