core: also check boot ID and product UUID in ConditionHost=

Sometimes it's interesting to condition units not just on the
installation but on the physical device. Let's make ConditionHost=
useful for that kind of checks, and while we are at it, also allow it to
be used for condition checks on the boot id.

Overloading like this is safe, since UUIDs are globally unique after
all, and hence there should be no conflicts between the namespace of
boot ids, machine ids and product ids.

Finally, relax rules on uuid checking: if the specified string parses
as uuid or id, also check it against the hostname, for setups where
people name hosts after uuids. I wouldn't know why anyone would do that,
but also, why not? shouldn'rt hurt allowing them and should not create
ambiguity conflicts.
This commit is contained in:
Lennart Poettering
2025-02-20 18:13:38 +01:00
parent 9ef8138946
commit 25ec3fdfd3
2 changed files with 29 additions and 11 deletions
+7 -6
View File
@@ -1429,13 +1429,14 @@
<varlistentry>
<term><varname>ConditionHost=</varname></term>
<listitem><para><varname>ConditionHost=</varname> may be used to match against the hostname or
machine ID of the host. This either takes a hostname string (optionally with shell style globs)
which is tested against the locally set hostname as returned by
<listitem><para><varname>ConditionHost=</varname> may be used to match against the hostname,
machine ID, boot ID or product UUID of the host. This either takes a hostname string (optionally
with shell style globs) which is tested against the locally set hostname as returned by
<citerefentry><refentrytitle>gethostname</refentrytitle><manvolnum>2</manvolnum></citerefentry>, or
a machine ID formatted as string (see
<citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
The test may be negated by prepending an exclamation mark.</para>
a 128bit ID or UUID, formatted as string. The latter is compared against machine ID, boot ID and the
firmware product UUID if there is any. See
<citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
details about the machine ID. The test may be negated by prepending an exclamation mark.</para>
<xi:include href="version-info.xml" xpointer="v244"/>
</listitem>