Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Dec 2022 17:53:13 +0100 (CET)
From:      Ronald Klop <ronald-lists@klop.ws>
To:        "Tobias C. Berner" <tcberner@FreeBSD.org>
Cc:        dev-commits-src-all@FreeBSD.org, src-committers@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   Re: git: 62a149bf6219 - main - Add new rc: machine_id to generate /etc/machine-id
Message-ID:  <876513140.46.1671814393751@mailrelay>
In-Reply-To: <202212231636.2BNGaluc012056@gitrepo.freebsd.org>
References:  <202212231636.2BNGaluc012056@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
------=_Part_45_1998427481.1671814393669
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Hi,

What is the difference or overlap of this and /etc/hostid ?

Regards,
Ronald.

=C3=82=20
Van: "Tobias C. Berner" <tcberner@FreeBSD.org>
Datum: vrijdag, 23 december 2022 17:36
Aan: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commi=
ts-src-main@FreeBSD.org
Onderwerp: git: 62a149bf6219 - main - Add new rc: machine_id to generate /e=
tc/machine-id
>=20
> The branch main has been updated by tcberner (ports committer):
>=20
> URL: https://cgit.FreeBSD.org/src/commit/?id=3D62a149bf621947fb7475c64b1f=
f04fe19fe16b29
>=20
> commit 62a149bf621947fb7475c64b1ff04fe19fe16b29
> Author:     Tobias C. Berner <tcberner@FreeBSD.org>
> AuthorDate: 2022-12-17 09:18:03 +0000
> Commit:     Tobias C. Berner <tcberner@FreeBSD.org>
> CommitDate: 2022-12-23 16:33:19 +0000
>=20
>     Add new rc: machine_id to generate /etc/machine-id
>    =20
>     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].
>    =20
>     The file is generated in /var/db/machine-id and symlinked to
>     /etc/machine-id to allow for read-only root partitions.
>    =20
>     This file is amongst other things used by libraries like GLib.
>    =20
>     Bump FreeBSD version 1400076 to be able to easily add support for old=
er
>     version of FreeBSD via a package.
>    =20
>     [1] Linux machine-id(5): https://www.man7.org/linux/man-pages/man5/ma=
chine-id.5.html
>     [2] f176fe8e7f638e585afcd2f4dd52a522c4648f63
>    =20
>     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(-)
>=20
> 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
> =20
>  /*
>   * __FreeBSD_kernel__ indicates that this system uses the kernel of Free=
BSD,
> =C3=82=20
>=20
>=20
>=20

=C3=82=20
------=_Part_45_1998427481.1671814393669
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<html><head></head><body>Hi,<br>
<br>
What is the difference or overlap of this and /etc/hostid ?<br>
<br>
Regards,<br>
Ronald.<br>
<br>
=C3=82&nbsp;
<p><strong>Van:</strong> "Tobias C. Berner" &lt;tcberner@FreeBSD.org&gt;<br=
>
<strong>Datum:</strong> vrijdag, 23 december 2022 17:36<br>
<strong>Aan:</strong> src-committers@FreeBSD.org, dev-commits-src-all@FreeB=
SD.org, dev-commits-src-main@FreeBSD.org<br>
<strong>Onderwerp:</strong> git: 62a149bf6219 - main - Add new rc: machine_=
id to generate /etc/machine-id</p>

<blockquote style=3D"padding-right: 0px; padding-left: 5px; margin-left: 5p=
x; border-left: #000000 2px solid; margin-right: 0px">
<div class=3D"MessageRFC822Viewer" id=3D"P">
<div class=3D"TextPlainViewer" id=3D"P.P">The branch main has been updated =
by tcberner (ports committer):<br>
<br>
URL: <a href=3D"https://cgit.FreeBSD.org/src/commit/?id=3D62a149bf621947fb7=
475c64b1ff04fe19fe16b29">https://cgit.FreeBSD.org/src/commit/?id=3D62a149bf=
621947fb7475c64b1ff04fe19fe16b29</a><br>
<br>
commit 62a149bf621947fb7475c64b1ff04fe19fe16b29<br>
Author: &nbsp;&nbsp;&nbsp;&nbsp;Tobias C. Berner &lt;tcberner@FreeBSD.org&g=
t;<br>
AuthorDate: 2022-12-17 09:18:03 +0000<br>
Commit: &nbsp;&nbsp;&nbsp;&nbsp;Tobias C. Berner &lt;tcberner@FreeBSD.org&g=
t;<br>
CommitDate: 2022-12-23 16:33:19 +0000<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;Add new rc: machine_id to generate /etc/machine-id<=
br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;This new default-enabled rc will generate a /etc/ma=
chine-id file if it<br>
&nbsp;&nbsp;&nbsp;&nbsp;does not exist, and pre-fill it with a newly genera=
ted UUID of version 4<br>
&nbsp;&nbsp;&nbsp;&nbsp;[2].<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;The file is generated in /var/db/machine-id and sym=
linked to<br>
&nbsp;&nbsp;&nbsp;&nbsp;/etc/machine-id to allow for read-only root partiti=
ons.<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;This file is amongst other things used by libraries=
 like GLib.<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;Bump FreeBSD version 1400076 to be able to easily a=
dd support for older<br>
&nbsp;&nbsp;&nbsp;&nbsp;version of FreeBSD via a package.<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;[1] Linux machine-id(5): <a href=3D"https://www.man=
7.org/linux/man-pages/man5/machine-id.5.html">https://www.man7.org/linux/ma=
n-pages/man5/machine-id.5.html</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;[2] f176fe8e7f638e585afcd2f4dd52a522c4648f63<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;Approved by: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;bapt<br>
&nbsp;&nbsp;&nbsp;&nbsp;MFC after: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 week<br>
&nbsp;&nbsp;&nbsp;&nbsp;Differential Revision: &nbsp;<a href=3D"https://rev=
iews.freebsd.org/D37722">https://reviews.freebsd.org/D37722</a><br>;
---<br>
&nbsp;etc/Makefile &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;2 ++<br>
&nbsp;libexec/rc/rc.conf &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| =
&nbsp;3 +++<br>
&nbsp;libexec/rc/rc.d/Makefile &nbsp;&nbsp;| &nbsp;1 +<br>
&nbsp;libexec/rc/rc.d/machine_id | 34 ++++++++++++++++++++++++++++++++++<br=
>
&nbsp;sys/sys/param.h &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;| &nbsp;2 +-<br>
&nbsp;5 files changed, 41 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/etc/Makefile b/etc/Makefile<br>
index 3036b7acdd19..10d2f7ea2c5c 100644<br>
--- a/etc/Makefile<br>
+++ b/etc/Makefile<br>
@@ -59,6 +59,8 @@ distribution:<br>
&nbsp;&nbsp;&nbsp;&nbsp;${_+_}cd ${SRCTOP}/usr.sbin/rmt; ${MAKE} etc-rmt<br=
>
&nbsp;&nbsp;&nbsp;&nbsp;${INSTALL_SYMLINK} -T "package=3Druntime" ../var/ru=
n/os-release \<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${DESTDIR}/etc/os-release<b=
r>
+ &nbsp;&nbsp;${INSTALL_SYMLINK} -T "package=3Druntime" ../var/db/machine-i=
d \<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${DESTDIR}/etc/machine-id<br>
&nbsp;.if ${MK_UNBOUND} !=3D "no"<br>
&nbsp;&nbsp;&nbsp;&nbsp;if [ ! -e ${DESTDIR}/etc/unbound ]; then \<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${INSTALL_SYMLINK} -T "pack=
age=3Dunbound" \<br>
diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf<br>
index d10855e1e5fa..a1f6a3f69e8d 100644<br>
--- a/libexec/rc/rc.conf<br>
+++ b/libexec/rc/rc.conf<br>
@@ -694,6 +694,9 @@ harvest_mask=3D"511" &nbsp;# Entropy device harvests al=
l but the very invasive sources.<br>
&nbsp;osrelease_enable=3D"YES" # Update /var/run/os-release on boot (or NO)=
.<br>
&nbsp;osrelease_file=3D"/var/run/os-release" # File to update for os-releas=
e.<br>
&nbsp;osrelease_perms=3D"444" &nbsp;# Default permission for os-release fil=
e.<br>
+machine_id_enable=3D"YES" &nbsp;&nbsp;&nbsp;# Create /var/db/machine-id on=
 boot if missing (or NO).<br>
+machine_id_file=3D"/var/db/machine-id" &nbsp;&nbsp;# File to update for ma=
chine-id.<br>
+machine_id_perms=3D"444" # Default permissions for machine-id file.<br>
&nbsp;dmesg_enable=3D"YES" # Save dmesg(8) to /var/run/dmesg.boot<br>
&nbsp;watchdogd_enable=3D"NO" &nbsp;# Start the software watchdog daemon<br=
>
&nbsp;watchdogd_flags=3D"" # Flags to watchdogd (if enabled)<br>
diff --git a/libexec/rc/rc.d/Makefile b/libexec/rc/rc.d/Makefile<br>
index 0e43b1cd94dc..e990dea60721 100644<br>
--- a/libexec/rc/rc.d/Makefile<br>
+++ b/libexec/rc/rc.d/Makefile<br>
@@ -52,6 +52,7 @@ CONFS=3D &nbsp;&nbsp;&nbsp;DAEMON \<br>
&nbsp;&nbsp;&nbsp;&nbsp;local \<br>
&nbsp;&nbsp;&nbsp;&nbsp;localpkg \<br>
&nbsp;&nbsp;&nbsp;&nbsp;lockd \<br>
+ &nbsp;&nbsp;machine_id \<br>
&nbsp;&nbsp;&nbsp;&nbsp;mixer \<br>
&nbsp;&nbsp;&nbsp;&nbsp;motd \<br>
&nbsp;&nbsp;&nbsp;&nbsp;mountcritlocal \<br>
diff --git a/libexec/rc/rc.d/machine_id b/libexec/rc/rc.d/machine_id<br>
new file mode 100644<br>
index 000000000000..7cfd7b2d92f8<br>
--- /dev/null<br>
+++ b/libexec/rc/rc.d/machine_id<br>
@@ -0,0 +1,34 @@<br>
+#!/bin/sh<br>
+#<br>
+# $FreeBSD$<br>
+#<br>
+<br>
+# PROVIDE: machine_id<br>
+# REQUIRE: mountcritremote FILESYSTEMS<br>
+# BEFORE: &nbsp;LOGIN<br>
+<br>
+. /etc/rc.subr<br>
+<br>
+: ${machine_id_file:=3D/var/db/machine-id}<br>
+: ${machine_id_perms:=3D444}<br>
+name=3D"machine_id"<br>
+desc=3D"Update ${machine_id_file}"<br>
+rcvar=3D"machine_id_enable"<br>
+start_cmd=3D"machine_id_start"<br>
+stop_cmd=3D":"<br>
+<br>
+<br>
+machine_id_start()<br>
+{<br>
+ &nbsp;&nbsp;if [ ! -f ${machine_id_file} ] ; then<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;startmsg -n "Creating ${machine_id_fi=
le} "<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t=3D$(mktemp -t machine-id)<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/bin/uuidgen -r -o $t<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;install -C -o root -g wheel -m ${mach=
ine_id_perms} "$t" "${machine_id_file}"<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rm -f "$t"<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;startmsg 'done.'<br>
+ &nbsp;&nbsp;fi<br>
+}<br>
+<br>
+load_rc_config $name<br>
+run_rc_command "$1"<br>
diff --git a/sys/sys/param.h b/sys/sys/param.h<br>
index bb56fe1140cf..9b123a38a7a8 100644<br>
--- a/sys/sys/param.h<br>
+++ b/sys/sys/param.h<br>
@@ -76,7 +76,7 @@<br>
&nbsp;&nbsp;* cannot include sys/param.h and should only be updated here.<b=
r>
&nbsp;&nbsp;*/<br>
&nbsp;#undef __FreeBSD_version<br>
-#define __FreeBSD_version 1400075<br>
+#define __FreeBSD_version 1400076<br>
&nbsp;<br>
&nbsp;/*<br>
&nbsp;&nbsp;* __FreeBSD_kernel__ indicates that this system uses the kernel=
 of FreeBSD,<br>
=C3=82&nbsp;</div>

<hr></div>
</blockquote>
<br>
=C3=82&nbsp;</body></html>
------=_Part_45_1998427481.1671814393669--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?876513140.46.1671814393751>