Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id ADF13633169 for ; Wed, 14 Jul 2010 18:44:12 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 03973-02 for ; Wed, 14 Jul 2010 21:44:05 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from tamriel.snowman.net (tamriel.snowman.net [72.66.115.51]) by mail.postgresql.org (Postfix) with ESMTP id 2265C632AF0 for ; Wed, 14 Jul 2010 18:44:05 -0300 (ADT) Received: by tamriel.snowman.net (Postfix, from userid 1000) id DE44F2291D; Wed, 14 Jul 2010 17:44:03 -0400 (EDT) Date: Wed, 14 Jul 2010 17:44:03 -0400 From: Stephen Frost To: Tom Lane Cc: Magnus Hagander , Christopher Head , pgsql-bugs Subject: Re: BUG #5559: Full SSL verification fails when hostaddr provided Message-ID: <20100714214403.GQ21875@tamriel.snowman.net> References: <18252.1279058967@sss.pgh.pa.us> <6811.1279123338@sss.pgh.pa.us> <7342.1279124972@sss.pgh.pa.us> <20100714173942.GM21875@tamriel.snowman.net> <9371.1279130114@sss.pgh.pa.us> <20100714183240.GO21875@tamriel.snowman.net> <10950.1279135209@sss.pgh.pa.us> <20100714212805.GP21875@tamriel.snowman.net> <18347.1279143321@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="iQZKyoMEJGyIPpZr" Content-Disposition: inline In-Reply-To: <18347.1279143321@sss.pgh.pa.us> X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/2.6.26-1-amd64 (x86_64) X-Uptime: 17:36:32 up 321 days, 9:01, 32 users, load average: 0.12, 0.11, 0.07 User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201007/106 X-Sequence-Number: 27450 --iQZKyoMEJGyIPpZr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Tom Lane (tgl@sss.pgh.pa.us) wrote: > Stephen Frost writes: > > krb5_sname_to_principal() will use the passed hostname for the sec= ond > > component. If type is KRB5_NT_SRV_HST this name will be looked up= with > > gethostbyname(). If hostname is NULL, the local hostname will be = used. >=20 > > If we were passing in NULL before when hostaddr was set and host wasn't, > > then we were probably ending up with Kerberos trying to use the local > > hostname, which almost certainly wasn't right. >=20 > Ah. I agree that that would be unexpected behavior. >=20 > > I expect that the > > correct answer here would be to do whatever the actual connection logic > > does- if it connects using host, then use host, if it connects using > > hostaddr, then use hostaddr. >=20 > Uh, no, because hostaddr is (required to be) a numeric IP. The odds of > it being useful in this context seem negligible. Err, no, it'll work just fine- gethostbyname() will take the dotted-quad numeric IP and return the hostname and Kerberos will use that to generate the principal. Maybe I'm missing something, but hostaddr being an IP is just like if you passed in host with an IP, which I believe is what psql does when called like so: beren:/home/sfrost> psql -h 172.18.148.12 -d gis Welcome to psql 8.3.7, the PostgreSQL interactive terminal. and that certainly works just fine. beren:/home/sfrost> klist [...] 07/14/10 17:37:50 07/14/10 17:58:25 postgres/beren.tsf.noblis.org@TSF.NOB= LIS.ORG > At this point I'm satisfied that what the code is doing is right. We > can't authenticate against Kerberos without knowing the server host > name, because we can't form a correct principal name. Whether use of > hostaddr would avoid an rDNS lookup inside the library is not relevant. I don't believe anything is going to avoid an rDNS lookup except bombing out before invoking krb5_sname_to_principal(). Perhaps that's what's intended, to avoid any DNS lookup, but I don't believe it's because it wouldn't *work* to give krb5_sname_to_principal() an IP address=20 (provided rDNS is, in fact, functional in your environment). Thanks, Stephen --iQZKyoMEJGyIPpZr Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkw+L6MACgkQrzgMPqB3kigoHgCffiAHsttw3OZvakfcXfqBXCdi A4kAoIie5MGQdMQ3aqaot4CokaZsOZ/C =UtIp -----END PGP SIGNATURE----- --iQZKyoMEJGyIPpZr--