From nobody Tue Jan 10 07:52:07 2023 X-Original-To: dev-commits-src-branches@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 4Nrjh80f95z2r177; Tue, 10 Jan 2023 07:52:08 +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 4Nrjh80Dprz4GZ3; Tue, 10 Jan 2023 07:52:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673337128; 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=UI0BcIHpG5v6memvjDVE3AsTxtzfaoC3HABp9LrIv34=; b=Nd3fmxcJNomAjIYb21TaFdnjPzj7taGvE7SC878a3N12S1xfXGoJOZTlAuhxMOa2iAFSym q9yattuxV+C/U6bI1PLRkbkCZyo+cy7zcdjdkc8QTcg4Aspzc2wPYt0WBzkMzgJto8897P SotxwqP6brGmD6MmtfRgJUEuKpkbUiPHMARPAhAaOvFP+k5EXxhcRzUn7sEbji2RghdQO+ qMqBlLSGy32NAHZIofAeH6+dENy916CjNYsweWjDsXp2TCTKZMH9tBjOUB3xDwliem40+h T6b21gGgVM+d135voeSqLpXIa3vOtJzSNRzjqm6M4wvYxiJUSDUJBdtrPqoxKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673337128; 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=UI0BcIHpG5v6memvjDVE3AsTxtzfaoC3HABp9LrIv34=; b=o0UG4au4lK9MwpOAHw0yrXgWEA8o/wS2sIdpoqPJBNvhmTOSMqyYcWTT6oXluuLZAvqucW aUca9R4Iu/zN8tWc7MRI9d2YDp86lgiEZj6FJryjr5M8ND78ko1sk1dJbDZUyd+rikcHBs BUA2FW50QhnzoBtqQNlbKRBBLxcLwxW5wdCjf0PZ+3CjMIsKgvfIw2b0euFNRefhFx9VQm 1X7ePlvzPqJyw8EXahLcdLQukFn4wHlDohV7TRCQ4K4T/qiWt7B/4N+PUPhlbcKU/3L20C kC1mRcUl9y02/zvv+MNJybhtrmybJaDBZW5tsGE9EAwExFkTFFk0d1LEAJeJyg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673337128; a=rsa-sha256; cv=none; b=IY1yHbbm3g2pnSkIUZMoMBd6Xu7eUvRSBnXGJ5B0PSC/fvwKOC5dgsOskIejBJAxuNRnQT nUTQ0GaWj0dCzYSel10WAQL5bC+/zhQ2Tg5s6V6OMy7EPsIQne44EucBd3iiDfH7fJfXLi D1eghjuZVuNLeo0AqDN/s7pd0HiRUHWGixt0VKtVb1cYeULxinZ1Pgl2kh/39sHPSNMnCu IxF0tHvgXUqDlgEaNHrbvHsC93fMAOpPNF7zTRm7b9bEfjOdC4crFv1VP6HH5wK5GejSkk tj5xp/gnLK2kE9rA1kXPyuu/EOrZDkMyP9xwwsCMmLID3FobxZCKLvSaKZWDQg== 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 4Nrjh76L0Lz11dy; Tue, 10 Jan 2023 07:52:07 +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 30A7q7x6079939; Tue, 10 Jan 2023 07:52:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30A7q7KM079938; Tue, 10 Jan 2023 07:52:07 GMT (envelope-from git) Date: Tue, 10 Jan 2023 07:52:07 GMT Message-Id: <202301100752.30A7q7KM079938@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Tobias C. Berner" Subject: git: 17333d92643d - stable/13 - Add new rc: machine_id to generate /etc/machine-id List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tcberner X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 17333d92643d998d1c6a2dc5f6b1508b6507ad31 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by tcberner (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=17333d92643d998d1c6a2dc5f6b1508b6507ad31 commit 17333d92643d998d1c6a2dc5f6b1508b6507ad31 Author: Tobias C. Berner AuthorDate: 2022-12-17 09:18:03 +0000 Commit: Tobias C. Berner CommitDate: 2023-01-10 07:51:01 +0000 Add new rc: machine_id to generate /etc/machine-id This new default-enabled rc will generate a /etc/machine-id file if it does not exist, and pre-fill it with a newly generated UUID of version 4 [2]. The file is generated in /var/db/machine-id and symlinked to /etc/machine-id to allow for read-only root partitions. This file is amongst other things used by libraries like GLib. Bump FreeBSD version 1400076 to be able to easily add support for older version of FreeBSD via a package. Bump FreeBSD version 1301511 to be able to easily add support for older version of FreeBSD via a package. [1] Linux machine-id(5): https://www.man7.org/linux/man-pages/man5/machine-id.5.html [2] f176fe8e7f638e585afcd2f4dd52a522c4648f63 Approved by: bapt MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D37722 (cherry picked from commit 62a149bf621947fb7475c64b1ff04fe19fe16b29) --- etc/Makefile | 2 ++ libexec/rc/rc.conf | 3 +++ libexec/rc/rc.d/Makefile | 1 + libexec/rc/rc.d/machine_id | 34 ++++++++++++++++++++++++++++++++++ sys/sys/param.h | 2 +- 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/etc/Makefile b/etc/Makefile index 104e40b6e345..49a7a12a41b5 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -58,6 +58,8 @@ 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 82796ba0ec48..e4f1ebe39de3 100644 --- a/libexec/rc/rc.conf +++ b/libexec/rc/rc.conf @@ -700,6 +700,9 @@ 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 0aa6b01448a5..0e7a04a5df1b 100644 --- a/libexec/rc/rc.d/Makefile +++ b/libexec/rc/rc.d/Makefile @@ -53,6 +53,7 @@ CONFS= DAEMON \ local \ localpkg \ lockd \ + machine_id \ mixer \ motd \ mountcritlocal \ diff --git a/libexec/rc/rc.d/machine_id b/libexec/rc/rc.d/machine_id new file mode 100644 index 000000000000..7cfd7b2d92f8 --- /dev/null +++ b/libexec/rc/rc.d/machine_id @@ -0,0 +1,34 @@ +#!/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 -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 57cf5937d952..4d1f940af760 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1301510 /* Master, propagated to newvers */ +#define __FreeBSD_version 1301511 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,