diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-09-19 10:15:26 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-09-20 16:52:02 +0200 |
commit | 2e7e76af99548aa52ea378a4475c0be44763435a (patch) | |
tree | 0e928d8b53a38b15f382fa40032effb97effdcae /src/shared/bus-util.c | |
parent | b8b20f5a6a71a7796377d52d05812cc251d30c7b (diff) | |
download | systemd-2e7e76af99548aa52ea378a4475c0be44763435a.tar.gz systemd-2e7e76af99548aa52ea378a4475c0be44763435a.tar.bz2 systemd-2e7e76af99548aa52ea378a4475c0be44763435a.zip |
bus-util: drop now-unused functions
Diffstat (limited to 'src/shared/bus-util.c')
-rw-r--r-- | src/shared/bus-util.c | 162 |
1 files changed, 0 insertions, 162 deletions
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c index ddc8364511..808df9b154 100644 --- a/src/shared/bus-util.c +++ b/src/shared/bus-util.c @@ -1761,168 +1761,6 @@ int bus_open_system_watch_bind_with_description(sd_bus **ret, const char *descri return 0; } -struct request_name_data { - unsigned n_ref; - - const char *name; - uint64_t flags; - void *userdata; -}; - -static void request_name_destroy_callback(void *userdata) { - struct request_name_data *data = userdata; - - assert(data); - assert(data->n_ref > 0); - - log_debug("%s n_ref=%u", __func__, data->n_ref); - - data->n_ref--; - if (data->n_ref == 0) - free(data); -} - -static int reload_dbus_handler(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { - struct request_name_data *data = userdata; - const sd_bus_error *e; - int r; - - assert(data); - assert(data->name); - assert(data->n_ref > 0); - - e = sd_bus_message_get_error(m); - if (e) { - log_error_errno(sd_bus_error_get_errno(e), "Failed to reload DBus configuration: %s", e->message); - return 1; - } - - /* Here, use the default request name handler to avoid an infinite loop of reloading and requesting. */ - r = sd_bus_request_name_async(sd_bus_message_get_bus(m), NULL, data->name, data->flags, NULL, data->userdata); - if (r < 0) - log_error_errno(r, "Failed to request name: %m"); - - return 1; -} - -static int request_name_handler_may_reload_dbus(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { - struct request_name_data *data = userdata; - uint32_t ret; - int r; - - assert(m); - assert(data); - - if (sd_bus_message_is_method_error(m, NULL)) { - const sd_bus_error *e = sd_bus_message_get_error(m); - _cleanup_(sd_bus_slot_unrefp) sd_bus_slot *slot = NULL; - - if (!sd_bus_error_has_name(e, SD_BUS_ERROR_ACCESS_DENIED)) { - log_debug_errno(sd_bus_error_get_errno(e), - "Unable to request name, failing connection: %s", - e->message); - - bus_enter_closing(sd_bus_message_get_bus(m)); - return 1; - } - - log_debug_errno(sd_bus_error_get_errno(e), - "Unable to request name, will retry after reloading DBus configuration: %s", - e->message); - - /* If a service enables DynamicUser= and dbus.service started before the dynamic user is realized, - * then the DBus policy about the service has not been enabled yet. So, let's try to reload DBus - * configuration, and after that request the name again. Note that it seems that no privileges are - * necessary to call the following method. */ - - r = sd_bus_call_method_async( - sd_bus_message_get_bus(m), - &slot, - "org.freedesktop.DBus", - "/org/freedesktop/DBus", - "org.freedesktop.DBus", - "ReloadConfig", - reload_dbus_handler, - data, NULL); - if (r < 0) { - log_error_errno(r, "Failed to reload DBus configuration: %m"); - bus_enter_closing(sd_bus_message_get_bus(m)); - return 1; - } - - data->n_ref ++; - assert_se(sd_bus_slot_set_destroy_callback(slot, request_name_destroy_callback) >= 0); - - r = sd_bus_slot_set_floating(slot, true); - if (r < 0) - return r; - - return 1; - } - - r = sd_bus_message_read(m, "u", &ret); - if (r < 0) - return r; - - switch (ret) { - - case BUS_NAME_ALREADY_OWNER: - log_debug("Already owner of requested service name, ignoring."); - return 1; - - case BUS_NAME_IN_QUEUE: - log_debug("In queue for requested service name."); - return 1; - - case BUS_NAME_PRIMARY_OWNER: - log_debug("Successfully acquired requested service name."); - return 1; - - case BUS_NAME_EXISTS: - log_debug("Requested service name already owned, failing connection."); - bus_enter_closing(sd_bus_message_get_bus(m)); - return 1; - } - - log_debug("Unexpected response from RequestName(), failing connection."); - bus_enter_closing(sd_bus_message_get_bus(m)); - return 1; -} - -int bus_request_name_async_may_reload_dbus(sd_bus *bus, sd_bus_slot **ret_slot, const char *name, uint64_t flags, void *userdata) { - _cleanup_free_ struct request_name_data *data = NULL; - _cleanup_(sd_bus_slot_unrefp) sd_bus_slot *slot = NULL; - int r; - - data = new(struct request_name_data, 1); - if (!data) - return -ENOMEM; - - *data = (struct request_name_data) { - .n_ref = 1, - .name = name, - .flags = flags, - .userdata = userdata, - }; - - r = sd_bus_request_name_async(bus, &slot, name, flags, request_name_handler_may_reload_dbus, data); - if (r < 0) - return r; - - assert_se(sd_bus_slot_set_destroy_callback(slot, request_name_destroy_callback) >= 0); - TAKE_PTR(data); - - if (ret_slot) - *ret_slot = TAKE_PTR(slot); - else { - r = sd_bus_slot_set_floating(slot, true); - if (r < 0) - return r; - } - - return 0; -} - int bus_reply_pair_array(sd_bus_message *m, char **l) { _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; char **k, **v; |