summaryrefslogtreecommitdiff
path: root/bus
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2022-02-16 00:14:37 +0100
committerRalf Habacker <ralf.habacker@freenet.de>2022-02-16 14:00:13 +0100
commit564056e21e858b2402bd5d5a2eedb15380261732 (patch)
treefc2cc7baa9fe89630d9cce7dd74e0c5fb402c140 /bus
parent5efc97f03ca581df139b8ed4bca75b333d9e606e (diff)
downloaddbus-564056e21e858b2402bd5d5a2eedb15380261732.tar.gz
dbus-daemon: Implement signal 'ActivatableServicesChanged'
After any reload of the activatable service files the mentioned signal is emitted to the current bus to inform clients. The calls to signal emmission have not been implemented in the platform specific functions _dbus_daemon_report_reloaded() to avoid duplicate implementations. Fixes #376 Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
Diffstat (limited to 'bus')
-rw-r--r--bus/bus.c70
-rw-r--r--bus/driver.c8
2 files changed, 78 insertions, 0 deletions
diff --git a/bus/bus.c b/bus/bus.c
index ea508d72..9003860e 100644
--- a/bus/bus.c
+++ b/bus/bus.c
@@ -30,6 +30,7 @@
#include "activation.h"
#include "connection.h"
#include "containers.h"
+#include "dispatch.h"
#include "services.h"
#include "utils.h"
#include "policy.h"
@@ -1075,6 +1076,66 @@ bus_context_get_id (BusContext *context,
return _dbus_uuid_encode (&context->uuid, uuid);
}
+/**
+ * Send signal to the buses that the activatable services may be changed
+ *
+ * @param context bus context to use
+ * @param error the error to set, if NULL no error will be set
+ * @return #FALSE if an error occurred, the reason is returned in \p error
+ */
+static dbus_bool_t
+bus_context_send_activatable_services_changed (BusContext *context,
+ DBusError *error)
+{
+ DBusMessage *message;
+ BusTransaction *transaction;
+ dbus_bool_t retval = FALSE;
+
+ _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+
+ transaction = bus_transaction_new (context);
+ if (transaction == NULL)
+ {
+ BUS_SET_OOM (error);
+ return FALSE;
+ }
+
+ message = dbus_message_new_signal (DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS,
+ "ActivatableServicesChanged");
+
+ if (message == NULL)
+ {
+ BUS_SET_OOM (error);
+ goto out;
+ }
+
+ if (!dbus_message_set_sender (message, DBUS_SERVICE_DBUS))
+ {
+ BUS_SET_OOM (error);
+ goto out;
+ }
+
+ if (!bus_transaction_capture (transaction, NULL, NULL, message))
+ {
+ BUS_SET_OOM (error);
+ goto out;
+ }
+
+ retval = bus_dispatch_matches (transaction, NULL, NULL, message, error);
+
+out:
+ if (transaction != NULL)
+ {
+ if (retval)
+ bus_transaction_execute_and_free (transaction);
+ else
+ bus_transaction_cancel_and_free (transaction);
+ }
+ dbus_clear_message (&message);
+ return retval;
+}
+
dbus_bool_t
bus_context_reload_config (BusContext *context,
DBusError *error)
@@ -1116,6 +1177,15 @@ bus_context_reload_config (BusContext *context,
if (parser != NULL)
bus_config_parser_unref (parser);
+ {
+ DBusError local_error = DBUS_ERROR_INIT;
+
+ if (!bus_context_send_activatable_services_changed (context, &local_error))
+ bus_context_log (context, DBUS_SYSTEM_LOG_INFO, "Unable to send signal that configuration has been reloaded: %s", local_error.message);
+
+ dbus_error_free (&local_error);
+ }
+
_dbus_daemon_report_reloaded ();
return ret;
}
diff --git a/bus/driver.c b/bus/driver.c
index ef1b957f..8ea2955b 100644
--- a/bus/driver.c
+++ b/bus/driver.c
@@ -2737,6 +2737,8 @@ static InterfaceHandler interface_handlers[] = {
" </signal>\n"
" <signal name=\"NameAcquired\">\n"
" <arg type=\"s\"/>\n"
+ " </signal>\n"
+ " <signal name=\"ActivatableServicesChanged\">\n"
" </signal>\n",
/* Not in the Interfaces property because if you can get the properties
* of the o.fd.DBus interface, then you certainly have the o.fd.DBus
@@ -3158,6 +3160,12 @@ features_getter (BusContext *context,
&arr_iter))
return FALSE;
+ s = "ActivatableServicesChanged";
+
+ if (!dbus_message_iter_append_basic (&arr_iter, DBUS_TYPE_STRING, &s))
+ goto abandon;
+
+
if (bus_apparmor_enabled ())
{
s = "AppArmor";