From owner-cvs-src@FreeBSD.ORG Fri Dec 2 13:09:59 2005 Return-Path: X-Original-To: cvs-src@FreeBSD.org Delivered-To: cvs-src@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C1FD016A41F; Fri, 2 Dec 2005 13:09:59 +0000 (GMT) (envelope-from pjd@garage.freebsd.pl) Received: from mail.garage.freebsd.pl (arm132.internetdsl.tpnet.pl [83.17.198.132]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0D14643D46; Fri, 2 Dec 2005 13:09:59 +0000 (GMT) (envelope-from pjd@garage.freebsd.pl) Received: by mail.garage.freebsd.pl (Postfix, from userid 65534) id D2F0A52C81; Fri, 2 Dec 2005 14:09:57 +0100 (CET) Received: from localhost (dkc38.neoplus.adsl.tpnet.pl [83.24.6.38]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.garage.freebsd.pl (Postfix) with ESMTP id 9FCA652C7F; Fri, 2 Dec 2005 14:09:51 +0100 (CET) Date: Fri, 2 Dec 2005 14:09:16 +0100 From: Pawel Jakub Dawidek To: Doug Ambrisko Message-ID: <20051202130916.GB1427@garage.freebsd.pl> References: <200512020050.jB20oU8c000911@repoman.freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="4bRzO86E/ozDv8r1" Content-Disposition: inline In-Reply-To: <200512020050.jB20oU8c000911@repoman.freebsd.org> X-PGP-Key-URL: http://people.freebsd.org/~pjd/pjd.asc X-OS: FreeBSD 7.0-CURRENT i386 User-Agent: mutt-ng/devel-r535 (FreeBSD) X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on mail.garage.freebsd.pl X-Spam-Level: X-Spam-Status: No, score=-0.5 required=3.0 tests=BAYES_00,RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL autolearn=no version=3.0.4 Cc: cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src Makefile.inc1 src/lib/libc/gen __xuname.c getosreldate.c 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: Fri, 02 Dec 2005 13:10:00 -0000 --4bRzO86E/ozDv8r1 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 02, 2005 at 12:50:30AM +0000, Doug Ambrisko wrote: +> ambrisko 2005-12-02 00:50:30 UTC +>=20 +> FreeBSD src repository +>=20 +> Modified files: +> . Makefile.inc1=20 +> lib/libc/gen __xuname.c getosreldate.c=20 +> 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. +> =20 +> With these change you can put a complete FreeBSD OS image into a +> chroot set: +> UNAME_s=3DFreeBSD +> UNAME_r=3D4.7-RELEASE +> UNAME_v=3D"FreeBSD $UNAME_r #1: Fri Jul 22 20:32:52 PDT 2005 f= ake@fake:/usr/obj/usr/src/sys/FAKE" +> UNAME_m=3Di386 +> UNAME_p=3Di386 +> OSVERSION=3D470000 +> 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. +> =20 +> 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] =3D '\0'; +> + if ((p =3D getenv("UNAME_s"))) +> + strncpy(name->sysname, p, sizeof(name->sysname)); [...] +> name->release[sizeof(name->release) - 1] =3D '\0'; +> + if ((p =3D getenv("UNAME_r"))) +> + strncpy(name->release, p, sizeof(name->release)); [...] +> + if ((p =3D getenv("UNAME_v"))) +> + strncpy(name->version, p, sizeof(name->version)); [...] +> name->machine[sizeof(name->machine) - 1] =3D '\0'; +> + if ((p =3D 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). PS. Very useful change. At least for me:) --=20 Pawel Jakub Dawidek http://www.wheel.pl pjd@FreeBSD.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am! --4bRzO86E/ozDv8r1 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (FreeBSD) iD8DBQFDkEd7ForvXbEpPzQRAgFNAKC7KJQl1RzqUvEeKiXiBkmxQpPd3QCg7WIH DQZ0LTNK2lRzk6Aa4bPiYw4= =7fTL -----END PGP SIGNATURE----- --4bRzO86E/ozDv8r1--