From owner-cvs-src@FreeBSD.ORG Mon May 21 18:10:15 2007 Return-Path: X-Original-To: cvs-src@FreeBSD.org Delivered-To: cvs-src@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5E50D16A469 for ; Mon, 21 May 2007 18:10:15 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from mail2.fluidhosting.com (mx24.fluidhosting.com [204.14.89.7]) by mx1.freebsd.org (Postfix) with SMTP id 091DE13C4C7 for ; Mon, 21 May 2007 18:10:14 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: (qmail 25447 invoked by uid 399); 21 May 2007 18:10:14 -0000 Received: from localhost (HELO lap.dougb.net) (dougb@dougbarton.us@127.0.0.1) by localhost with SMTP; 21 May 2007 18:10:14 -0000 X-Originating-IP: 127.0.0.1 Message-ID: <4651E084.1020605@FreeBSD.org> Date: Mon, 21 May 2007 11:10:12 -0700 From: Doug Barton Organization: http://www.FreeBSD.org/ User-Agent: Thunderbird 2.0b2 (X11/20070116) MIME-Version: 1.0 To: "Ralf S. Engelschall" References: <200705211144.l4LBiEHY098477@repoman.freebsd.org> In-Reply-To: <200705211144.l4LBiEHY098477@repoman.freebsd.org> Content-Type: multipart/mixed; boundary="------------030407080704040901030201" Cc: cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/etc/rc.d hostid X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 May 2007 18:10:15 -0000 This is a multi-part message in MIME format. --------------030407080704040901030201 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Ralf S. Engelschall wrote: > rse 2007-05-21 11:44:13 UTC > > FreeBSD src repository > > Modified files: > etc/rc.d hostid > Log: > Adjust UUID lower-case translation from straight-forward tr(1) > usage to an equivalent csh(1) usage as tr(1) stays in /usr/bin and > /etc/rc.d/hostid has just the root filesystem (and this way mainly the > tools in /bin) available. > > I've chosen csh(1) here as the string manipulation tools available in > /bin is extremely limited and the (only) alternative ed(1) usage would > have been a lot more complicated or even might require a temporary file. > > Revision Changes Path > 1.4 +2 -1 src/etc/rc.d/hostid > > http://www.FreeBSD.org/cgi/cvsweb.cgi/src/etc/rc.d/hostid.diff?&r1=1.3&r2=1.4&f=h I really don't like the idea of having an rc.d script depend on csh. We don't have any other examples of that, and I don't really want to start down that road. I would appreciate it if you'd do a little more research into ways that this could be done with the tools available. Meanwhile, I've attached a patch that simplifies the hostid_hardware() quite a bit, and has the added virtue of only calling csh if it's needed. hth, Doug -- This .signature sanitized for your protection --------------030407080704040901030201 Content-Type: text/plain; name="hostid.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="hostid.diff" Index: hostid =================================================================== RCS file: /usr/local/ncvs/src/etc/rc.d/hostid,v retrieving revision 1.5 diff -u -r1.5 hostid --- hostid 21 May 2007 11:57:01 -0000 1.5 +++ hostid 21 May 2007 18:02:54 -0000 @@ -56,19 +56,26 @@ hostid_hardware() { + local uuid + uuid=`kenv smbios.system.uuid 2>/dev/null` - uuid=`csh -c 'echo -n ${*:al}' "${uuid}"` - x="[0-9a-f]" - y=$x$x$x$x - z="0000" - case "${uuid}" in - $z$z-$z-$z-$z-$z$z$z) + + case "$uuid" in + 00000000-0000-0000-0000-000000000000) # Filter the special "Nil" UUID + return ;; - $y$y-$y-$y-$y-$y$y$y) - echo "${uuid}" + *[^A-Fa-f0-9-]*) + # Contains invalid (non-hex) characters + return + ;; + *[A-F]*) + # Contains capital letters that need to be changed + uuid=`csh -c 'echo -n ${*:al}' "${uuid}"` ;; esac + + echo "${uuid}" } hostid_reset() --------------030407080704040901030201--