mirror of
https://github.com/systemd/systemd.git
synced 2025-02-23 13:57:33 +03:00
kernel-install: respect $MACHINE_ID and ignore /etc/machine-id if on tmpfs
Confer https://github.com/systemd/systemd/pull/19006#issuecomment-800234022: On some systems it's the admin's explicit choice not to to have the machine ID leak into the ESP On some systems the machine ID is transient, generated at every boot, and hence should not be written to the ESP
This commit is contained in:
parent
733caba389
commit
dcd9d196a4
@ -161,8 +161,12 @@
|
||||
|
||||
<refsect1>
|
||||
<title>Environment variables</title>
|
||||
|
||||
<para>If <option>--verbose</option> is used, <varname>$KERNEL_INSTALL_VERBOSE=1</varname> will be set for
|
||||
the plugins. They may output additional logs in this case.</para>
|
||||
|
||||
<para>If <varname>MACHINE_ID=</varname> is set and not empty, it will be used as <replaceable>MACHINE-ID</replaceable>,
|
||||
overriding any automatic detection attempts. The value must be a valid machine ID (32 hexadecimal characters).</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
@ -214,9 +218,9 @@
|
||||
</term>
|
||||
<listitem>
|
||||
<para>The content of this file specifies the machine identification
|
||||
<replaceable>MACHINE-ID</replaceable>. If <filename>$BOOT/Default</filename> exists,
|
||||
or <filename>/etc/machine-id</filename> doesn't, <command>kernel-install</command>
|
||||
will use the literal <literal>Default</literal> as the machine ID instead.</para>
|
||||
<replaceable>MACHINE-ID</replaceable>. If <filename>/etc/machine-id</filename>
|
||||
cannot be read or is temporary (backed by a file on <constant>tmpfs</constant>),
|
||||
<command>kernel-install</command> will use <literal>Default</literal> instead.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
|
@ -85,20 +85,14 @@ fi
|
||||
KERNEL_VERSION="$1"
|
||||
KERNEL_IMAGE="$2"
|
||||
|
||||
# Reuse directory created without a machine ID present if it exists.
|
||||
if [[ -d /efi/Default ]] || [[ -d /boot/Default ]] || [[ -d /boot/efi/Default ]]; then
|
||||
MACHINE_ID="Default"
|
||||
elif [[ -f /etc/machine-id ]]; then
|
||||
read MACHINE_ID < /etc/machine-id
|
||||
else
|
||||
MACHINE_ID="Default"
|
||||
fi
|
||||
|
||||
if [[ ! $COMMAND ]] || [[ ! $KERNEL_VERSION ]]; then
|
||||
echo "Not enough arguments" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
[ -z "$MACHINE_ID" ] && [ -f /etc/machine-id ] && [ "$(stat -fc %T /etc/machine-id)" != "tmpfs" ] && read -r MACHINE_ID < /etc/machine-id
|
||||
[ -z "$MACHINE_ID" ] && MACHINE_ID="Default"
|
||||
|
||||
if [[ -d /efi/loader/entries ]] || [[ -d /efi/$MACHINE_ID ]]; then
|
||||
ENTRY_DIR_ABS="/efi/$MACHINE_ID/$KERNEL_VERSION"
|
||||
elif [[ -d /boot/loader/entries ]] || [[ -d /boot/$MACHINE_ID ]]; then
|
||||
@ -113,7 +107,7 @@ else
|
||||
ENTRY_DIR_ABS="/boot/$MACHINE_ID/$KERNEL_VERSION"
|
||||
fi
|
||||
|
||||
export KERNEL_INSTALL_MACHINE_ID=$MACHINE_ID
|
||||
export KERNEL_INSTALL_MACHINE_ID="$MACHINE_ID"
|
||||
|
||||
ret=0
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user