Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Oct 2005 19:44:07 +0100
From:      Ceri Davies <ceri@submonkey.net>
To:        Brooks Davis <brooks@one-eyed-alien.net>
Cc:        arch@freebsd.org
Subject:   Re: error in trimdomain(3)
Message-ID:  <20051003184407.GJ56760@submonkey.net>
In-Reply-To: <20051003182406.GA3629@odin.ac.hmc.edu>
References:  <20051001093550.GA32354@odin.ac.hmc.edu> <20051003103124.GB56760@submonkey.net> <20051003180344.GA31888@odin.ac.hmc.edu> <20051003181808.GI56760@submonkey.net> <20051003182406.GA3629@odin.ac.hmc.edu>

next in thread | previous in thread | raw e-mail | index | archive | help

--WRT3RXLOp/bBMgTI
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Oct 03, 2005 at 11:24:06AM -0700, Brooks Davis wrote:
> On Mon, Oct 03, 2005 at 07:18:08PM +0100, Ceri Davies wrote:
> > On Mon, Oct 03, 2005 at 11:03:44AM -0700, Brooks Davis wrote:
> > > On Mon, Oct 03, 2005 at 11:31:24AM +0100, Ceri Davies wrote:
> > > > On Sat, Oct 01, 2005 at 02:35:50AM -0700, Brooks Davis wrote:
> > > > > I discovered today that the trimdomain() implementation in libuti=
l deviates
> > > > > slightly from the manpage.  The manpage says:
> > > > >=20
> > > > >      The function trimdomain() removes the current domain name fr=
om the passed
> > > > >      fullhost name by writing a NUL character over the first peri=
od of the
> > > > >                                                        ^^^^^^^^^^=
^^
> > > > >      passed name.  The current domain name is determined by calli=
ng
> > > > >      gethostname(3) and removing everything up to the first perio=
d.
> > > > >=20
> > > > > which clearly indicates that trimdomain() should return either the
> > > > > unmodified string or a host name with no domain.  In reality it w=
ill
> > > > > remove the domain name even if the result is not a host name.  Th=
is
> > > > > means that if the host b.com calls trimdomain with "a.b.com" as t=
he
> > > > > input string, the result is "a.b".
> > > >=20
> > > > That's actually what the excerpt above says will happen.
> > > >=20
> > > > gethostname returns "b.com", removing everything up to the first pe=
riod
> > > > yields ".com", and that removed from "a.b.com" gives you "a.b".
> > > >=20
> > > > I don't care if it needs to be changed, but that does exactly what =
it
> > > > says on the tin so far as I can see.
> > >=20
> > > There are two refrences to "first period".  You are correct that the
> > > domain name of b.com is .com, but the refrence I highlighted states t=
hat
> > > the only allowable modification to the host name is writing a NUL to
> > > the first period in the string (it's actually messier than this becau=
se
> > > trimdomain also supports X11 DISPLAY strings and thus does a memmove =
and
> > > reterminates if there is a :0 or :0.0 type string after domain.)
> >=20
> > I agree that the documentation gives that impressions but the fact that
> > it bothers to call gethostname at all makes me wonder; if it's just goi=
ng
> > to replace the first period with a NUL then I don't see why that call is
> > necessary, unless the intention is to achieve the current behaviour.
>=20
> My interpretation is that the function is intended to remove the domain
> only if it is the local domain and thus implicit.

Ah, now I see it; yes, I'm with you.

Ceri
--=20
Only two things are infinite, the universe and human stupidity, and I'm
not sure about the former.			  -- Einstein (attrib.)

--WRT3RXLOp/bBMgTI
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (FreeBSD)

iD8DBQFDQXv3ocfcwTS3JF8RAtcdAJ942llczaTBFXnzbJMDnHV9y9c1PgCgqAzv
cqQgllQ/FDho4l5kTHreb5A=
=anH9
-----END PGP SIGNATURE-----

--WRT3RXLOp/bBMgTI--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20051003184407.GJ56760>