From owner-freebsd-arch@FreeBSD.ORG Mon Oct 3 18:18:16 2005 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 74C5816A41F for ; Mon, 3 Oct 2005 18:18:16 +0000 (GMT) (envelope-from ceri@submonkey.net) Received: from shrike.submonkey.net (cpc2-cdif2-3-1-cust208.cdif.cable.ntl.com [82.31.78.208]) by mx1.FreeBSD.org (Postfix) with ESMTP id D76CD43D49 for ; Mon, 3 Oct 2005 18:18:15 +0000 (GMT) (envelope-from ceri@submonkey.net) Received: from ceri by shrike.submonkey.net with local (Exim 4.53 (FreeBSD)) id 1EMUt6-000Nx0-Ps; Mon, 03 Oct 2005 19:18:08 +0100 Date: Mon, 3 Oct 2005 19:18:08 +0100 From: Ceri Davies To: Brooks Davis Message-ID: <20051003181808.GI56760@submonkey.net> Mail-Followup-To: Ceri Davies , Brooks Davis , arch@freebsd.org References: <20051001093550.GA32354@odin.ac.hmc.edu> <20051003103124.GB56760@submonkey.net> <20051003180344.GA31888@odin.ac.hmc.edu> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="0z5c7mBtSy1wdr4F" Content-Disposition: inline In-Reply-To: <20051003180344.GA31888@odin.ac.hmc.edu> X-PGP: finger ceri@FreeBSD.org User-Agent: Mutt/1.5.11 Sender: Ceri Davies Cc: arch@freebsd.org Subject: Re: error in trimdomain(3) X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Oct 2005 18:18:16 -0000 --0z5c7mBtSy1wdr4F Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 libutil de= viates > > > slightly from the manpage. The manpage says: > > >=20 > > > The function trimdomain() removes the current domain name from t= he passed > > > fullhost name by writing a NUL character over the first period o= f the > > > ^^^^^^^^^^^^ > > > passed name. The current domain name is determined by calling > > > gethostname(3) and removing everything up to the first period. > > >=20 > > > which clearly indicates that trimdomain() should return either the > > > unmodified string or a host name with no domain. In reality it will > > > remove the domain name even if the result is not a host name. This > > > means that if the host b.com calls trimdomain with "a.b.com" as the > > > 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 period > > 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 that > 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 because > 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.) 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 going 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. Ceri --=20 Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. -- Einstein (attrib.) --0z5c7mBtSy1wdr4F Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (FreeBSD) iD8DBQFDQXXgocfcwTS3JF8RAmJHAJ9u4yAyax8AtVgp9VxYFU02flYgRgCghzPX E9v1sNqo9Z6OmeDIojPSEKU= =APzW -----END PGP SIGNATURE----- --0z5c7mBtSy1wdr4F--