]> git.ipfire.org Git - thirdparty/systemd.git/commit
sysupdate: List default component only if transfer definition exists 42179/head
authorPhilip Withnall <pwithnall@gnome.org>
Tue, 19 May 2026 14:46:36 +0000 (15:46 +0100)
committerPhilip Withnall <pwithnall@gnome.org>
Fri, 22 May 2026 10:46:32 +0000 (11:46 +0100)
commit8de5a7b94d3af30b0686f14c4cc96a0575982aba
tree616f8d35fea461b9aeff0401cf9f55924e8b4d8a
parenta7a1bc8678050ae922d6de688bfa6ea5f241b44f
sysupdate: List default component only if transfer definition exists

`sysupdate --json=short components` lists the components known to
sysupdate; these are the components which something like `updatectl`
will try to update.

The `default` component represents the host, and is meant to be listed
if transfer definitions exist in (for example) `/etc/sysupdate.d`
corresponding to the host OS. This then corresponds to `TARGET_HOST` in
`updatectl` and causes it to try updating that target.

The logic for working out whether the `default` component was present
essentially boiled down to “does `{/run,/etc,/usr/lib}/sysupdate.d`
exist”, and it didn’t check whether a `.transfer` or `.conf` file
actually existed in the config directory.

This is quite the corner case, but becomes more evident on systems where
sysupdate is being used to update a portable service but not the main
OS. At that point, if `/etc/sysupdate.d` exists empty (for some reason),
`updatectl` falls over because it starts trying to update the host OS
without any configuration to do so.

So, modify `sysupdate` to more fully load the available configuration
when listing components, and query it a bit more deeply to check whether
a default component exists.

If `sysupdate` is called with various command line arguments to affect
how its configuration is loaded, do *not* say that a default component
exists, as these arguments essentially anull the possibility of a
default being used in that process.

Add an integration test based on the reproducer provided by the issue
reporter. This test has been tested to fail if the changes to
`sysupdate.c` aren’t applied — if so, the second call to `sysupdate
components` would return
`{"default":true,"components":["some-component"]}`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Fixes: https://github.com/systemd/systemd/issues/41501
src/sysupdate/sysupdate.c
test/units/TEST-72-SYSUPDATE.sh