From nobody Thu Mar 09 09:37:34 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PXPH231Xmz3wS87; Thu, 9 Mar 2023 09:37:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PXPH22SMDz4WXs; Thu, 9 Mar 2023 09:37:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678354654; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vnb09Z2UljGjCf9eH0Csf2Bj2gAq4x4yWJJqwaCB19Q=; b=uAhClTYr2l9IkGMDFLhl+hPJE1iPYx5R2tYwCTvgWLllqSXAvFauqHSoJ8p7shcPI+Ehmw 3/j7hy9A5GXrzClQH00md6ttBtm3W748RNdBLALF2QaJVRZMxbCqIL5NYtt1cUmhXZoLLu g6XvyN4AwYxoP983mkb8sVYUCBa7SzCaMlYoHHdjfH6yhvYnZzd6+iql2YXafvuVJN5tt6 D0ssKdFWP/5dy5HS9cIl+Eaic+i/rzXgywecQEK7iDdvRaFVXUNH73LMbhbl47Q39moLP0 WSiec8SVPGeCyBEs81Evlq9Fqfyrd4jHfKfMiBK52kkVp/v+ctF5XIL51B2t3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678354654; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vnb09Z2UljGjCf9eH0Csf2Bj2gAq4x4yWJJqwaCB19Q=; b=I0YREfeQBp6duo1RmLkDIXmESmbKmLNOyTRgDqTzLmiVL5wTJp5t5KDgVOjIzgAW9lv1o5 qnchTAm7xtVZ31D9l7vSLSzy6H8mAVY/7k+RLzZyixbidZPje7L/8YGszba7QfKcGlT4Pf dAKWdXf2OEjKTRwfojSvy+WyqbhU6ueeHyTwQJbcpVyawOCvQ+CcrXKjIgkqcaKRqjR0D+ dgPyCEskM2bSX5idFDUYaiuX6FdqG9jsbzIgFCastoUQG1ROKsm/xi6MJqbke7eVHm1GvF 3kX67kTdSe5L0OrxnbmbCxusAUwsegcbMdYPyUo9HA6ErqhfWc30+R6N4rZ9pQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1678354654; a=rsa-sha256; cv=none; b=pSVI65oQy0wo5ZQozvha6tJg8fwg1Qdd1GW/k5OfEP/qBkkfV4EHF7rOm1XI2TKaV77g1v QgRYrxexMZ2+QMnMd4cQJyJ7vkU4pNqhC+FfTrG1KRh94Yyb2E8fh6qAlTV/FFl6DEvV9o vpcO7CAjx3ycMsuqb05k1gbSgPOIp5eZmS/0PhUoWtPlHFe3hfJEotfmsMDBGbtBS4kivu so47Mi4jHDo7s8Ki+Js2rOAKDxYTqQWll38Jq/xyQwmb7RQYWAayGl1w9m70lgY2o4grbJ zagGUGIuEsSns89PZCh93bNd4h5AmuKxzaDiYc/qDTrisJh5y1B9RswG1S1MyA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PXPH21Wkdz124h; Thu, 9 Mar 2023 09:37:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 3299bYf5039640; Thu, 9 Mar 2023 09:37:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 3299bYiv039639; Thu, 9 Mar 2023 09:37:34 GMT (envelope-from git) Date: Thu, 9 Mar 2023 09:37:34 GMT Message-Id: <202303090937.3299bYiv039639@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Tijl Coosemans Subject: git: ecad3f5c4d92 - main - rc.d: Generate machine-id from hostid_save List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tijl X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ecad3f5c4d922f93ceba455f8bff1c54e1ed4174 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tijl: URL: https://cgit.FreeBSD.org/src/commit/?id=ecad3f5c4d922f93ceba455f8bff1c54e1ed4174 commit ecad3f5c4d922f93ceba455f8bff1c54e1ed4174 Author: Tijl Coosemans AuthorDate: 2023-02-15 20:09:51 +0000 Commit: Tijl Coosemans CommitDate: 2023-03-09 09:31:55 +0000 rc.d: Generate machine-id from hostid_save rc.d/hostid_save saves a UUID generated by rc.d/hostid in /etc/hostid. Store the same UUID, without hyphens, in /etc/machine-id. The hypĥens are removed with a shell function because hostid_save runs before file systems are mounted so other tools may not be available yet. This eliminates some duplication between hostid and machine-id and for virtual machines machine-id now contains the UUID configured in the hypervisor like it does on Linux. Reviewed by: delphij Discussed with: bapt MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D38811 --- ObsoleteFiles.inc | 3 +++ etc/Makefile | 2 -- libexec/rc/rc.conf | 4 +--- libexec/rc/rc.d/Makefile | 1 - libexec/rc/rc.d/hostid_save | 28 ++++++++++++++++++++-------- libexec/rc/rc.d/machine_id | 34 ---------------------------------- sys/sys/param.h | 2 +- 7 files changed, 25 insertions(+), 49 deletions(-) diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index 23bdd366f40b..7bbd91525cd5 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -52,6 +52,9 @@ # xargs -n1 | sort | uniq -d; # done +# 20230308: machine-id merged into hostid_save +OLD_FILES+=etc/rc.d/machine-id + # 20230306: remove tzsetwall(3) OLD_FILES+=usr/share/man/man3/tzsetwall.3.gz diff --git a/etc/Makefile b/etc/Makefile index 88f890b91604..4e28739268e6 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -59,8 +59,6 @@ distribution: ${_+_}cd ${SRCTOP}/usr.sbin/rmt; ${MAKE} etc-rmt ${INSTALL_SYMLINK} -T "package=runtime" ../var/run/os-release \ ${DESTDIR}/etc/os-release - ${INSTALL_SYMLINK} -T "package=runtime" ../var/db/machine-id \ - ${DESTDIR}/etc/machine-id .if ${MK_UNBOUND} != "no" if [ ! -e ${DESTDIR}/etc/unbound ]; then \ ${INSTALL_SYMLINK} -T "package=unbound" \ diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf index 8a5f69dbef12..932fd2ace778 100644 --- a/libexec/rc/rc.conf +++ b/libexec/rc/rc.conf @@ -138,6 +138,7 @@ hostname="" # Set this! hostid_enable="YES" # Set host UUID. hostid_file="/etc/hostid" # File with hostuuid. hostid_uuidgen_flags="-r" # Flags to uuidgen. +machine_id_file="/etc/machine-id" # File with machine-id. 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. @@ -696,9 +697,6 @@ harvest_mask="511" # Entropy device harvests all but the very invasive sources. osrelease_enable="YES" # Update /var/run/os-release on boot (or NO). osrelease_file="/var/run/os-release" # File to update for os-release. osrelease_perms="444" # Default permission for os-release file. -machine_id_enable="YES" # Create /var/db/machine-id on boot if missing (or NO). -machine_id_file="/var/db/machine-id" # File to update for machine-id. -machine_id_perms="444" # Default permissions for machine-id file. dmesg_enable="YES" # Save dmesg(8) to /var/run/dmesg.boot watchdogd_enable="NO" # Start the software watchdog daemon watchdogd_flags="" # Flags to watchdogd (if enabled) diff --git a/libexec/rc/rc.d/Makefile b/libexec/rc/rc.d/Makefile index e2019c60f196..9be66195e774 100644 --- a/libexec/rc/rc.d/Makefile +++ b/libexec/rc/rc.d/Makefile @@ -49,7 +49,6 @@ CONFS= DAEMON \ local \ localpkg \ lockd \ - machine_id \ mixer \ motd \ mountcritlocal \ diff --git a/libexec/rc/rc.d/hostid_save b/libexec/rc/rc.d/hostid_save index f535ea2596f2..f737ed7f74cf 100755 --- a/libexec/rc/rc.d/hostid_save +++ b/libexec/rc/rc.d/hostid_save @@ -15,20 +15,32 @@ start_cmd="hostid_save" stop_cmd=":" rcvar="hostid_enable" +hostid_machine_id() +{ + local IFS + + IFS=- + set -- ${current_hostid} + IFS= + current_machine_id=$* +} + hostid_save() { current_hostid=`$SYSCTL_N kern.hostuuid` - if [ -r ${hostid_file} ]; then - read saved_hostid < ${hostid_file} - if [ ${saved_hostid} = ${current_hostid} ]; then - exit 0 - fi + read saved_hostid 2>/dev/null < ${hostid_file} + if [ "${saved_hostid}" != "${current_hostid}" ]; then + echo "${current_hostid}" > ${hostid_file} || + warn "could not store hostuuid in ${hostid_file}." fi - echo ${current_hostid} > ${hostid_file} - if [ $? -ne 0 ]; then - warn "could not store hostuuid in ${hostid_file}." + hostid_machine_id + + read saved_machine_id 2>/dev/null < ${machine_id_file} + if [ "${saved_machine_id}" != "${current_machine_id}" ]; then + echo "${current_machine_id}" > ${machine_id_file} || + warn "could not store hostuuid in ${machine_id_file}." fi } diff --git a/libexec/rc/rc.d/machine_id b/libexec/rc/rc.d/machine_id deleted file mode 100644 index 8bf3e41d0603..000000000000 --- a/libexec/rc/rc.d/machine_id +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# -# $FreeBSD$ -# - -# PROVIDE: machine_id -# REQUIRE: mountcritremote FILESYSTEMS -# BEFORE: LOGIN - -. /etc/rc.subr - -: ${machine_id_file:=/var/db/machine-id} -: ${machine_id_perms:=444} -name="machine_id" -desc="Update ${machine_id_file}" -rcvar="machine_id_enable" -start_cmd="machine_id_start" -stop_cmd=":" - - -machine_id_start() -{ - if [ ! -f ${machine_id_file} ] ; then - startmsg -n "Creating ${machine_id_file} " - t=$(mktemp -t machine-id) - /bin/uuidgen -r -c -o $t - install -C -o root -g wheel -m ${machine_id_perms} "$t" "${machine_id_file}" - rm -f "$t" - startmsg 'done.' - fi -} - -load_rc_config $name -run_rc_command "$1" diff --git a/sys/sys/param.h b/sys/sys/param.h index bdc73475b8e9..353c0243b6d5 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -76,7 +76,7 @@ * cannot include sys/param.h and should only be updated here. */ #undef __FreeBSD_version -#define __FreeBSD_version 1400081 +#define __FreeBSD_version 1400082 /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,