summarylogtreecommitdiffstats
path: root/0002_added_machine_id_firmware_option.patch
diff options
context:
space:
mode:
authorMerlin Jehli2024-04-04 20:19:03 +0200
committerMerlin Jehli2024-04-04 20:19:03 +0200
commite624858cc6060df7e4ca8ba0335d288b71d9b495 (patch)
tree402199488857b9d3d0dbfb2f07c04b6c3008e392 /0002_added_machine_id_firmware_option.patch
parent16dc596016af3ba29db6ab20cea9b039f11dd843 (diff)
downloadaur-e624858cc6060df7e4ca8ba0335d288b71d9b495.tar.gz
update
Diffstat (limited to '0002_added_machine_id_firmware_option.patch')
-rw-r--r--0002_added_machine_id_firmware_option.patch96
1 files changed, 96 insertions, 0 deletions
diff --git a/0002_added_machine_id_firmware_option.patch b/0002_added_machine_id_firmware_option.patch
new file mode 100644
index 000000000000..445fb3f6d212
--- /dev/null
+++ b/0002_added_machine_id_firmware_option.patch
@@ -0,0 +1,96 @@
+Subject: [PATCH] added systemd.machine_id=firmware option
+---
+Index: man/machine-id.xml
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+diff --git a/man/machine-id.xml b/man/machine-id.xml
+--- a/man/machine-id.xml (revision 99a1ef8c9cdcb0fc15265533dae2bbd8f2d7a3a5)
++++ b/man/machine-id.xml (revision fe3fa3d6a2a02f665ebca19088873165e24ad0db)
+@@ -102,7 +102,7 @@
+ value of the kernel command line option <varname>container_uuid</varname>, the KVM DMI
+ <filename>product_uuid</filename> or the devicetree <filename>vm,uuid</filename>
+ (on KVM systems), the Xen hypervisor <filename>uuid</filename>, and finally a randomly
+- generated UUID.</para>
++ generated UUID. <varname>systemd.machine_id=firmware</varname> can be set to generate the machine id from the firmware.</para>
+
+ <para>After the machine ID is established,
+ <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
+Index: src/core/main.c
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+diff --git a/src/core/main.c b/src/core/main.c
+--- a/src/core/main.c (revision 99a1ef8c9cdcb0fc15265533dae2bbd8f2d7a3a5)
++++ b/src/core/main.c (revision fe3fa3d6a2a02f665ebca19088873165e24ad0db)
+@@ -354,10 +354,11 @@
+ if (proc_cmdline_value_missing(key, value))
+ return 0;
+
+- r = id128_from_string_nonzero(value, &arg_machine_id);
+- if (r < 0)
+- log_warning_errno(r, "MachineID '%s' is not valid, ignoring: %m", value);
+-
++ if (!streq(value, "firmware")) {
++ r = id128_from_string_nonzero(value, &arg_machine_id);
++ if (r < 0)
++ log_warning_errno(r, "MachineID '%s' is not valid, ignoring: %m", value);
++ }
+ } else if (proc_cmdline_key_streq(key, "systemd.default_timeout_start_sec")) {
+
+ if (proc_cmdline_value_missing(key, value))
+Index: src/shared/machine-id-setup.c
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+diff --git a/src/shared/machine-id-setup.c b/src/shared/machine-id-setup.c
+--- a/src/shared/machine-id-setup.c (revision 99a1ef8c9cdcb0fc15265533dae2bbd8f2d7a3a5)
++++ b/src/shared/machine-id-setup.c (revision fe3fa3d6a2a02f665ebca19088873165e24ad0db)
+@@ -1,6 +1,7 @@
+ /* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+ #include <fcntl.h>
++#include <proc-cmdline.h>
+ #include <sched.h>
+ #include <sys/mount.h>
+ #include <unistd.h>
+@@ -48,6 +49,19 @@
+ return 0;
+ }
+
++static bool machine_id_firmware(void) {
++ _cleanup_free_ char *buf = NULL;
++ int r;
++
++ r = proc_cmdline_get_key("systemd.machine_id", PROC_CMDLINE_VALUE_OPTIONAL, &buf);
++ if (r < 0) {
++ log_warning_errno(r, "Failed to read systemd.machine_id from kernel command line, ignoring: %m");
++ return false;
++ }
++
++ return strcmp(buf, "firmware");
++}
++
+ static int generate_machine_id(const char *root, sd_id128_t *ret) {
+ _cleanup_close_ int fd = -EBADF;
+ int r;
+@@ -80,14 +94,14 @@
+ return 0;
+ }
+
+- } else if (IN_SET(detect_vm(), VIRTUALIZATION_KVM, VIRTUALIZATION_AMAZON, VIRTUALIZATION_QEMU, VIRTUALIZATION_XEN)) {
++ } else if (IN_SET(detect_vm(), VIRTUALIZATION_KVM, VIRTUALIZATION_AMAZON, VIRTUALIZATION_QEMU, VIRTUALIZATION_XEN) || machine_id_firmware()) {
+
+ /* If we are not running in a container, see if we are running in a VM that provides
+ * a system UUID via the SMBIOS/DMI interfaces. Such environments include QEMU/KVM
+ * with the -uuid on the qemu command line or the Amazon EC2 Nitro hypervisor. */
+
+ if (id128_get_product(ret) >= 0) {
+- log_info("Initializing machine ID from VM UUID.");
++ log_info("Initializing machine ID from SMBIOS/DMI UUID.");
+ return 0;
+ }
+ }