cvs commit: src Makefile.inc1 src/lib/libc/gen __xuname.c getosreldate.c

Pawel Jakub Dawidek pjd at FreeBSD.org
Fri Dec 2 13:10:00 GMT 2005


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 at 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).

PS. Very useful change. At least for me:)

-- 
Pawel Jakub Dawidek                       http://www.wheel.pl
pjd at FreeBSD.org                           http://www.FreeBSD.org
FreeBSD committer                         Am I Evil? Yes, I Am!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/cvs-src/attachments/20051202/519af54b/attachment.bin


More information about the cvs-src mailing list