sysupdate: notify hook subscribers after a successful update
Define a new io.systemd.SysUpdate.Notify Varlink interface with a single OnCompletedUpdate() method, and after sysupdate successfully installs an update, invoke that method on every socket linked into /run/systemd/sysupdate/notify/ via varlink_execute_directory(). This gives other components a hook to react to applied updates (e.g. recompute a TPM policy, link a freshly downloaded kernel, refresh extensions). The notification carries the component name, the installed version and the list of updated resources (transfer id + on-disk path). Subscribers are free to ignore the parameters and just treat the call as a trigger. Setting SYSTEMD_SYSUPDATE_FORCE_NOTIFY=1 forces the notification to be sent even when no update was applied (in which case no resource list is included), so follow-up work can be triggered unconditionally. Fixes: #35988
This commit is contained in:
@@ -250,6 +250,7 @@ shared_sources = files(
|
||||
'varlink-io.systemd.Resolve.Monitor.c',
|
||||
'varlink-io.systemd.Shutdown.c',
|
||||
'varlink-io.systemd.StorageProvider.c',
|
||||
'varlink-io.systemd.SysUpdate.Notify.c',
|
||||
'varlink-io.systemd.Udev.c',
|
||||
'varlink-io.systemd.Unit.c',
|
||||
'varlink-io.systemd.UserDatabase.c',
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "varlink-io.systemd.SysUpdate.Notify.h"
|
||||
|
||||
static SD_VARLINK_DEFINE_STRUCT_TYPE(
|
||||
Resource,
|
||||
SD_VARLINK_DEFINE_FIELD(transfer, SD_VARLINK_STRING, 0),
|
||||
SD_VARLINK_DEFINE_FIELD(path, SD_VARLINK_STRING, SD_VARLINK_NULLABLE));
|
||||
|
||||
static SD_VARLINK_DEFINE_METHOD(
|
||||
OnCompletedUpdate,
|
||||
SD_VARLINK_DEFINE_INPUT(component, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
|
||||
SD_VARLINK_DEFINE_INPUT(version, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
|
||||
SD_VARLINK_DEFINE_INPUT_BY_TYPE(resources, Resource, SD_VARLINK_ARRAY|SD_VARLINK_NULLABLE));
|
||||
|
||||
SD_VARLINK_DEFINE_INTERFACE(
|
||||
io_systemd_SysUpdate_Notify,
|
||||
"io.systemd.SysUpdate.Notify",
|
||||
&vl_type_Resource,
|
||||
&vl_method_OnCompletedUpdate);
|
||||
@@ -0,0 +1,6 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include "sd-varlink-idl.h"
|
||||
|
||||
extern const sd_varlink_interface vl_interface_io_systemd_SysUpdate_Notify;
|
||||
Reference in New Issue
Block a user