From owner-cvs-all@FreeBSD.ORG Fri Dec 2 14:57:43 2005 Return-Path: X-Original-To: cvs-all@freebsd.org Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9631216A41F; Fri, 2 Dec 2005 14:57:43 +0000 (GMT) (envelope-from ambrisko@ambrisko.com) Received: from mail.ambrisko.com (mail.ambrisko.com [64.174.51.43]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6AB0243D6E; Fri, 2 Dec 2005 14:57:32 +0000 (GMT) (envelope-from ambrisko@ambrisko.com) Received: from server2.ambrisko.com (HELO www.ambrisko.com) ([192.168.1.2]) by mail.ambrisko.com with ESMTP; 02 Dec 2005 06:57:32 -0800 Received: from ambrisko.com (localhost [127.0.0.1]) by www.ambrisko.com (8.12.11/8.12.9) with ESMTP id jB2EvWag075949; Fri, 2 Dec 2005 06:57:32 -0800 (PST) (envelope-from ambrisko@ambrisko.com) Received: (from ambrisko@localhost) by ambrisko.com (8.12.11/8.12.11/Submit) id jB2EvWbr075948; Fri, 2 Dec 2005 06:57:32 -0800 (PST) (envelope-from ambrisko) From: Doug Ambrisko Message-Id: <200512021457.jB2EvWbr075948@ambrisko.com> In-Reply-To: <20051202130916.GB1427@garage.freebsd.pl> To: Pawel Jakub Dawidek Date: Fri, 2 Dec 2005 06:57:32 -0800 (PST) X-Mailer: ELM [version 2.4ME+ PL94b (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Cc: Doug Ambrisko , src-committers@FreeBSD.org, cvs-all@FreeBSD.org, cvs-src@FreeBSD.org Subject: Re: cvs commit: src Makefile.inc1 src/lib/libc/gen __xuname.c getosreldate.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Dec 2005 14:57:43 -0000 Pawel Jakub Dawidek writes: | On Fri, Dec 02, 2005 at 12:50:30AM +0000, Doug Ambrisko wrote: | +> ambrisko 2005-12-02 00:50:30 UTC | +> | +> FreeBSD src repository | +> | +> Modified files: | +> . Makefile.inc1 | +> lib/libc/gen __xuname.c getosreldate.c | +> Log: | +> Add support to easily build FreeBSD unpacked in a chroot of another | +> FreeBSD machine. To do this add the man 1 uname changes to __xuname.c | +> so we can override the settings it reports. Add OSVERSION override | +> to getosreldate. Finally which Makefile.inc1 to use uname -m instead | +> of sysctl -n hw.machine_arch to get the arch. type. | +> | +> With these change you can put a complete FreeBSD OS image into a | +> chroot set: | +> UNAME_s=FreeBSD | +> UNAME_r=4.7-RELEASE | +> UNAME_v="FreeBSD $UNAME_r #1: Fri Jul 22 20:32:52 PDT 2005 fake@fake:/usr/obj/usr/src/sys/FAKE" | +> UNAME_m=i386 | +> UNAME_p=i386 | +> OSVERSION=470000 | +> on an amd64 or i386 and it just work including building ports and using | +> pkg_add -r etc. The caveat for this example is that these patches | +> have to be applied to FreeBSD 4.7 and the uname(1) changes need to | +> be merged. This also addresses issue with libtool. | +> | +> This is usefull for when a build machine has been trashed for an | +> old release and we want to do a build on a new machine that FreeBSD | +> 4.7 won't run on ... | [...] | +> name->sysname[sizeof(name->sysname) - 1] = '\0'; | +> + if ((p = getenv("UNAME_s"))) | +> + strncpy(name->sysname, p, sizeof(name->sysname)); | [...] | +> name->release[sizeof(name->release) - 1] = '\0'; | +> + if ((p = getenv("UNAME_r"))) | +> + strncpy(name->release, p, sizeof(name->release)); | [...] | +> + if ((p = getenv("UNAME_v"))) | +> + strncpy(name->version, p, sizeof(name->version)); | [...] | +> name->machine[sizeof(name->machine) - 1] = '\0'; | +> + if ((p = getenv("UNAME_m"))) | +> + strncpy(name->machine, p, sizeof(name->machine)); | | As you can see, previous code tried to NULL-terminate buffers copied using | strncpy(3) properly and you inserted your changes after these | terminations. Please, NULL-terminate the buffers after using strncpy(3). The prior code had to NULL-terminate by hand since the data could come from the sysctl not NULL-terminate. I thought the strncpy would NULL-terminate but you are correct. I'll fix this when I add the man-page changes this morning and finish a make buildworld/installworld/buildworld cycle. Thanks, Doug A.