Index: etc/rc.d/Makefile =================================================================== RCS file: /usr/repo/src/etc/rc.d/Makefile,v retrieving revision 1.80 diff -u -p -r1.80 Makefile --- etc/rc.d/Makefile 6 Apr 2007 02:27:02 -0000 1.80 +++ etc/rc.d/Makefile 9 Apr 2007 14:32:20 -0000 @@ -14,7 +14,7 @@ FILES= DAEMON FILESYSTEMS LOGIN NETWORKI fsck ftpd \ gbde geli geli2 \ hcsecd \ - hostapd hostname \ + hostapd hostid hostname \ idmapd inetd initrandom \ ip6addrctl ip6fw ipfilter ipfs ipfw ipmon \ ipnat ipsec ipxrouted isdnd \ Index: etc/rc.d/hostid =================================================================== RCS file: etc/rc.d/hostid diff -N etc/rc.d/hostid --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ etc/rc.d/hostid 9 Apr 2007 14:52:16 -0000 @@ -0,0 +1,79 @@ +#!/bin/sh +# +# Copyright (c) 2007 Pawel Jakub Dawidek +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +# PROVIDE: hostid +# REQUIRE: root +# BEFORE: mountcritlocal +# KEYWORD: nojail + +. /etc/rc.subr + +name="hostid" +start_cmd="hostid_start" +stop_cmd=":" +reset_cmd="hostid_reset" +extra_commands="reset" + +hostid_set() +{ + uuid=$1 + # Generate hostid based on hostuuid - take first four bytes from md5(uuid). + id=`echo -n $uuid | md5` + id="0x${id%????????????????????????}" + # Set both kern.hostuuid and kern.hostid. + echo "Setting hostuuid: ${uuid}." + ${SYSCTL_W} kern.hostuuid="${uuid}" >/dev/null + echo "Setting hostid: ${id}." + ${SYSCTL_W} kern.hostid=${id} >/dev/null +} + +hostid_reset() +{ + uuid=`uuidgen` + # Store newly generated UUID in ${hostid_file}. + echo $uuid > ${hostid_file} + if [ $? -ne 0 ]; then + warn "could not store hostuuid in ${hostid_file}." + fi + hostid_set $uuid +} + +hostid_start() +{ + # If ${hostid_file} already exists, we take UUID from there. + if [ -r ${hostid_file} ]; then + hostid_set `cat ${hostid_file}` + else + # No hostid file, generate UUID. + hostid_reset + fi +} + +load_rc_config $name +run_rc_command "$1" Index: etc/defaults/rc.conf =================================================================== RCS file: /usr/repo/src/etc/defaults/rc.conf,v retrieving revision 1.312 diff -u -p -r1.312 rc.conf --- etc/defaults/rc.conf 6 Apr 2007 02:27:02 -0000 1.312 +++ etc/defaults/rc.conf 9 Apr 2007 14:27:15 -0000 @@ -93,6 +93,7 @@ extra_netfs_types="NO" # List of network ### Basic network and firewall/security options: ### hostname="" # Set this! +hostid_file="/etc/hostid" # File with hostuuid. nisdomainname="NO" # Set to NIS domain if using NIS (or NO). dhclient_program="/sbin/dhclient" # Path to dhcp client program. dhclient_flags="" # Extra flags to pass to dhcp client. Index: usr.bin/uuidgen/Makefile =================================================================== RCS file: /usr/repo/src/usr.bin/uuidgen/Makefile,v retrieving revision 1.2 diff -u -p -r1.2 Makefile --- usr.bin/uuidgen/Makefile 7 Dec 2003 21:34:56 -0000 1.2 +++ usr.bin/uuidgen/Makefile 9 Apr 2007 14:29:03 -0000 @@ -1,5 +1,7 @@ # $FreeBSD: src/usr.bin/uuidgen/Makefile,v 1.2 2003/12/07 21:34:56 mux Exp $ +BINDIR= /bin + PROG= uuidgen WARNS?= 6 Index: ObsoleteFiles.inc =================================================================== RCS file: /usr/repo/src/ObsoleteFiles.inc,v retrieving revision 1.77 diff -u -p -r1.77 ObsoleteFiles.inc --- ObsoleteFiles.inc 28 Mar 2007 07:49:57 -0000 1.77 +++ ObsoleteFiles.inc 9 Apr 2007 14:53:01 -0000 @@ -14,6 +14,8 @@ # The file is partitioned: OLD_FILES first, then OLD_LIBS and OLD_DIRS last. # +# 20070409: uuidgen moved to /bin/ +OLD_FILES+=usr/bin/uuidgen # 20070328: bzip2 1.0.4 OLD_FILES+=usr/share/info/bzip2.info.gz # 20070303: libarchive 2.0 Index: sys/sys/sysctl.h =================================================================== RCS file: /usr/repo/src/sys/sys/sysctl.h,v retrieving revision 1.145 diff -u -p -r1.145 sysctl.h --- sys/sys/sysctl.h 17 Sep 2006 20:00:35 -0000 1.145 +++ sys/sys/sysctl.h 9 Apr 2007 14:34:12 -0000 @@ -389,7 +389,8 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e #define KERN_USRSTACK 33 /* int: address of USRSTACK */ #define KERN_LOGSIGEXIT 34 /* int: do we log sigexit procs? */ #define KERN_IOV_MAX 35 /* int: value of UIO_MAXIOV */ -#define KERN_MAXID 36 /* number of valid kern ids */ +#define KERN_HOSTUUID 36 /* string: host UUID identifier */ +#define KERN_MAXID 37 /* number of valid kern ids */ #define CTL_KERN_NAMES { \ { 0, 0 }, \ @@ -427,6 +428,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e { "usrstack", CTLTYPE_INT }, \ { "logsigexit", CTLTYPE_INT }, \ { "iov_max", CTLTYPE_INT }, \ + { "hostuuid", CTLTYPE_STRING }, \ } /* Index: sys/sys/kernel.h =================================================================== RCS file: /usr/repo/src/sys/sys/kernel.h,v retrieving revision 1.133 diff -u -p -r1.133 kernel.h --- sys/sys/kernel.h 5 Apr 2007 20:40:47 -0000 1.133 +++ sys/sys/kernel.h 9 Apr 2007 14:48:20 -0000 @@ -56,6 +56,7 @@ /* 1.1 */ extern unsigned long hostid; +extern char *hostuuid; extern char hostname[MAXHOSTNAMELEN]; extern char domainname[MAXHOSTNAMELEN]; extern char kernelname[MAXPATHLEN]; Index: sys/kern/kern_mib.c =================================================================== RCS file: /usr/repo/src/sys/kern/kern_mib.c,v retrieving revision 1.76 diff -u -p -r1.76 kern_mib.c --- sys/kern/kern_mib.c 21 Aug 2005 18:03:31 -0000 1.76 +++ sys/kern/kern_mib.c 9 Apr 2007 14:48:49 -0000 @@ -301,6 +301,9 @@ SYSCTL_STRING(_kern, KERN_NISDOMAINNAME, u_long hostid; SYSCTL_ULONG(_kern, KERN_HOSTID, hostid, CTLFLAG_RW, &hostid, 0, "Host ID"); +char hostuuid[64] = "00000000-0000-0000-0000-000000000000"; +SYSCTL_STRING(_kern, KERN_HOSTUUID, hostuuid, CTLFLAG_RW, hostuuid, + sizeof(hostuuid), "Host UUID"); /* * This is really cheating. These actually live in the libc, something