From nobody Sat Dec 24 08:39:29 2022 X-Original-To: dev-commits-src-main@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 4NfHXw26WFz1HTQD; Sat, 24 Dec 2022 08:39:44 +0000 (UTC) (envelope-from tcberner@gmail.com) Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NfHXv585Kz3jqb; Sat, 24 Dec 2022 08:39:43 +0000 (UTC) (envelope-from tcberner@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-qv1-f43.google.com with SMTP id pp21so4505688qvb.5; Sat, 24 Dec 2022 00:39:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7GbBOmwnegL4k4uiK93ANEKck64AT4pI2Z89OctYj5A=; b=CtYItQegj3al3pi9FMkOO/RPZXXAmQk5hDOckmcU3DnpNdigH7SOTfb463iQg0/Pml 55No+ENIi+j2eme3NvprHbsCYTChGhRkkd8oRWwJiY/hfILoW0v8M6MQeCMG0yaUnFwO bbf2Q83zc5a5wpk0UpTwYzlInmfioeCTPEp33klVTZOHc8tbSEcTONbz/AIylYUcJ9Q2 OaZrUh2XgbY0pLaDO+XiTwKX0velt/qsGJSYhq1yes87vf3LwFpbCaTFgPvOO/I68cI+ 8ygiVb8q3EClFa2pL4zY+1qKXDxENzFAdxWUOfMTB+40Rc1KhW2KcrBnei08YfVlQCJP 1S7g== X-Gm-Message-State: AFqh2krMvhCWkcr7wgPbFQN/pfW/m6DEDsTTvmFt2ou4hmX6sa8nU65W dYjcpVki8Ap++FB3NVnCs113fL/IFe9keQ== X-Google-Smtp-Source: AMrXdXtiKHOu5pEGQ/fMzgAL1wqVbYBr6eUzuxAvUhLn8u2mzUy4uSDTaLmolVvBPfZsPTI6qlFMbg== X-Received: by 2002:a05:6214:2d10:b0:513:520c:9180 with SMTP id mz16-20020a0562142d1000b00513520c9180mr16482123qvb.38.1671871182516; Sat, 24 Dec 2022 00:39:42 -0800 (PST) Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com. [209.85.222.172]) by smtp.gmail.com with ESMTPSA id v7-20020a05620a0f0700b006fbb4b98a25sm3856117qkl.109.2022.12.24.00.39.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 24 Dec 2022 00:39:41 -0800 (PST) Received: by mail-qk1-f172.google.com with SMTP id g8so3339701qkl.2; Sat, 24 Dec 2022 00:39:41 -0800 (PST) X-Received: by 2002:a05:620a:17ab:b0:6ff:c8a1:a0fb with SMTP id ay43-20020a05620a17ab00b006ffc8a1a0fbmr666062qkb.583.1671871181545; Sat, 24 Dec 2022 00:39:41 -0800 (PST) List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 References: <202212231636.2BNGaluc012056@gitrepo.freebsd.org> <876513140.46.1671814393751@mailrelay> In-Reply-To: <876513140.46.1671814393751@mailrelay> From: "Tobias C. Berner" Date: Sat, 24 Dec 2022 09:39:29 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: git: 62a149bf6219 - main - Add new rc: machine_id to generate /etc/machine-id To: Ronald Klop Cc: "Tobias C. Berner" , dev-commits-src-all@freebsd.org, src-committers@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4NfHXv585Kz3jqb X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N Moin moin I think it tries to solve the same problem of giving the machine a unique i= d. From the linux man page [1] The machine ID does not change based on local or network configuration or when hardware is replaced. Due to this and its greater length, it is a more useful replacement for the gethostid(3) call that POSIX specifies. mfg Tobias [1] https://www.man7.org/linux/man-pages/man5/machine-id.5.html On Fri, 23 Dec 2022 at 17:53, Ronald Klop wrote: > > Hi, > > What is the difference or overlap of this and /etc/hostid ? > > Regards, > Ronald. > > =C3=82 > > Van: "Tobias C. Berner" > Datum: vrijdag, 23 december 2022 17:36 > Aan: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-com= mits-src-main@FreeBSD.org > Onderwerp: git: 62a149bf6219 - main - Add new rc: machine_id to generate = /etc/machine-id > > The branch main has been updated by tcberner (ports committer): > > URL: https://cgit.FreeBSD.org/src/commit/?id=3D62a149bf621947fb7475c64b1f= f04fe19fe16b29 > > commit 62a149bf621947fb7475c64b1ff04fe19fe16b29 > Author: Tobias C. Berner > AuthorDate: 2022-12-17 09:18:03 +0000 > Commit: Tobias C. Berner > CommitDate: 2022-12-23 16:33:19 +0000 > > Add new rc: machine_id to generate /etc/machine-id > > This new default-enabled rc will generate a /etc/machine-id file if i= t > does not exist, and pre-fill it with a newly generated UUID of versio= n 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 old= er > version of FreeBSD via a package. > > [1] Linux machine-id(5): https://www.man7.org/linux/man-pages/man5/ma= chine-id.5.html > [2] f176fe8e7f638e585afcd2f4dd52a522c4648f63 > > Approved by: bapt > MFC after: 1 week > Differential Revision: https://reviews.freebsd.org/D37722 > --- > 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 3036b7acdd19..10d2f7ea2c5c 100644 > --- a/etc/Makefile > +++ b/etc/Makefile > @@ -59,6 +59,8 @@ distribution: > ${_+_}cd ${SRCTOP}/usr.sbin/rmt; ${MAKE} etc-rmt > ${INSTALL_SYMLINK} -T "package=3Druntime" ../var/run/os-release \ > ${DESTDIR}/etc/os-release > + ${INSTALL_SYMLINK} -T "package=3Druntime" ../var/db/machine-id \ > + ${DESTDIR}/etc/machine-id > .if ${MK_UNBOUND} !=3D "no" > if [ ! -e ${DESTDIR}/etc/unbound ]; then \ > ${INSTALL_SYMLINK} -T "package=3Dunbound" \ > diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf > index d10855e1e5fa..a1f6a3f69e8d 100644 > --- a/libexec/rc/rc.conf > +++ b/libexec/rc/rc.conf > @@ -694,6 +694,9 @@ harvest_mask=3D"511" # Entropy device harvests all b= ut the very invasive sources. > osrelease_enable=3D"YES" # Update /var/run/os-release on boot (or NO). > osrelease_file=3D"/var/run/os-release" # File to update for os-release. > osrelease_perms=3D"444" # Default permission for os-release file. > +machine_id_enable=3D"YES" # Create /var/db/machine-id on boot if miss= ing (or NO). > +machine_id_file=3D"/var/db/machine-id" # File to update for machine-id= . > +machine_id_perms=3D"444" # Default permissions for machine-id file. > dmesg_enable=3D"YES" # Save dmesg(8) to /var/run/dmesg.boot > watchdogd_enable=3D"NO" # Start the software watchdog daemon > watchdogd_flags=3D"" # Flags to watchdogd (if enabled) > diff --git a/libexec/rc/rc.d/Makefile b/libexec/rc/rc.d/Makefile > index 0e43b1cd94dc..e990dea60721 100644 > --- a/libexec/rc/rc.d/Makefile > +++ b/libexec/rc/rc.d/Makefile > @@ -52,6 +52,7 @@ CONFS=3D 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:=3D/var/db/machine-id} > +: ${machine_id_perms:=3D444} > +name=3D"machine_id" > +desc=3D"Update ${machine_id_file}" > +rcvar=3D"machine_id_enable" > +start_cmd=3D"machine_id_start" > +stop_cmd=3D":" > + > + > +machine_id_start() > +{ > + if [ ! -f ${machine_id_file} ] ; then > + startmsg -n "Creating ${machine_id_file} " > + t=3D$(mktemp -t machine-id) > + /bin/uuidgen -r -o $t > + install -C -o root -g wheel -m ${machine_id_perms} "$t" "${machin= e_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 bb56fe1140cf..9b123a38a7a8 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 1400075 > +#define __FreeBSD_version 1400076 > > /* > * __FreeBSD_kernel__ indicates that this system uses the kernel of Free= BSD, > =C3=82 > ________________________________ > > > =C3=82