2 * Copyright (C) 2015-2018 "IoT.bzh"
3 * Author José Bollo <jose.bollo@iot.bzh>
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #if defined(WITH_DBUS_TRANSPARENCY)
21 #define NO_PLUGIN_VERBOSE_MACRO
29 #include <systemd/sd-bus.h>
30 #include <json-c/json.h>
32 #include <afb/afb-event-x2.h>
34 #include "afb-systemd.h"
36 #include "afb-session.h"
37 #include "afb-msg-json.h"
39 #include "afb-apiset.h"
40 #include "afb-api-dbus.h"
41 #include "afb-context.h"
47 static const char DEFAULT_PATH_PREFIX[] = "/org/agl/afb/api/";
54 * The path given are of the form
55 * system:/org/agl/afb/api/...
57 * user:/org/agl/afb/api/...
61 struct sd_bus *sdbus; /* the bus */
62 char *path; /* path of the object for the API */
63 char *name; /* name/interface of the object */
64 char *api; /* api name of the interface */
67 struct sd_bus_slot *slot_broadcast;
68 struct sd_bus_slot *slot_event;
69 struct dbus_event *events;
70 struct dbus_memo *memos;
73 struct sd_bus_slot *slot_call;
74 struct afb_evt_listener *listener; /* listener for broadcasted events */
75 struct origin *origins;
76 struct afb_apiset *apiset;
81 /******************* common part **********************************/
84 * create a structure api_dbus connected on either the system
85 * bus if 'system' is not null or on the user bus. The connection
86 * is established for either emiting/receiving on 'path' being of length
89 static struct api_dbus *make_api_dbus_3(int system, const char *path, size_t pathlen)
95 /* allocates the structure */
96 api = calloc(1, sizeof *api + 1 + pathlen + pathlen);
102 /* init the structure's strings */
104 /* path is copied after the struct */
105 api->path = (void*)(api+1);
106 strcpy(api->path, path);
108 /* api name is at the end of the path */
109 api->api = strrchr(api->path, '/');
110 if (api->api == NULL) {
115 if (!afb_api_is_valid_name(api->api)) {
120 /* the name/interface is copied after the path */
121 api->name = &api->path[pathlen + 1];
122 strcpy(api->name, &path[1]);
123 ptr = strchr(api->name, '/');
126 ptr = strchr(ptr, '/');
130 sdbus = (system ? afb_systemd_get_system_bus : afb_systemd_get_user_bus)();
144 * create a structure api_dbus connected on either the system
145 * bus if 'system' is not null or on the user bus. The connection
146 * is established for either emiting/receiving on 'path'.
147 * If 'path' is not absolute, it is prefixed with DEFAULT_PATH_PREFIX.
149 static struct api_dbus *make_api_dbus_2(int system, const char *path)
154 /* check the length of the path */
161 /* if the path is absolute, creation now */
163 return make_api_dbus_3(system, path, len);
165 /* compute the path prefixed with DEFAULT_PATH_PREFIX */
166 assert(strlen(DEFAULT_PATH_PREFIX) > 0);
167 assert(DEFAULT_PATH_PREFIX[strlen(DEFAULT_PATH_PREFIX) - 1] == '/');
168 len += strlen(DEFAULT_PATH_PREFIX);
169 ptr = alloca(len + 1);
170 strcpy(stpcpy(ptr, DEFAULT_PATH_PREFIX), path);
172 /* creation for prefixed path */
173 return make_api_dbus_3(system, ptr, len);
177 * create a structure api_dbus connected either emiting/receiving
179 * The path can be prefixed with "system:" or "user:" to select
180 * either the user or the system D-Bus. If none is set then user's
182 * If remaining 'path' is not absolute, it is prefixed with
183 * DEFAULT_PATH_PREFIX.
185 static struct api_dbus *make_api_dbus(const char *path)
190 /* retrieves the prefix "scheme-like" part */
191 ptr = strchr(path, ':');
193 return make_api_dbus_2(0, path);
195 /* check the prefix part */
196 preflen = (size_t)(ptr - path);
197 if (strncmp(path, "system", preflen) == 0)
198 return make_api_dbus_2(1, ptr + 1);
200 if (strncmp(path, "user", preflen) == 0)
201 return make_api_dbus_2(0, ptr + 1);
203 /* TODO: connect to a foreign D-Bus? */
208 static void destroy_api_dbus(struct api_dbus *api)
213 /******************* client part **********************************/
216 * structure for recording query data
219 struct dbus_memo *next; /* the next memo */
220 struct api_dbus *api; /* the dbus api */
221 struct afb_xreq *xreq; /* the request */
222 uint64_t msgid; /* the message identifier */
227 struct dbus_event *next;
228 struct afb_event_x2 *event;
233 /* allocates and init the memorizing data */
234 static struct dbus_memo *api_dbus_client_memo_make(struct api_dbus *api, struct afb_xreq *xreq)
236 struct dbus_memo *memo;
238 memo = malloc(sizeof *memo);
240 afb_xreq_unhooked_addref(xreq);
244 memo->next = api->client.memos;
245 api->client.memos = memo;
250 /* free and release the memorizing data */
251 static void api_dbus_client_memo_destroy(struct dbus_memo *memo)
253 struct dbus_memo **prv;
255 prv = &memo->api->client.memos;
256 while (*prv != NULL) {
264 afb_xreq_unhooked_unref(memo->xreq);
268 /* search a memorized request */
269 static struct dbus_memo *api_dbus_client_memo_search(struct api_dbus *api, uint64_t msgid)
271 struct dbus_memo *memo;
273 memo = api->client.memos;
274 while (memo != NULL && memo->msgid != msgid)
280 /* callback when received answer */
281 static int api_dbus_client_on_reply(sd_bus_message *message, void *userdata, sd_bus_error *ret_error)
284 struct dbus_memo *memo;
285 const char *json, *error, *info;
287 /* retrieve the recorded data */
291 rc = sd_bus_message_read(message, "sss", &json, &error, &info);
293 /* failing to have the answer */
294 afb_xreq_reply(memo->xreq, NULL, "error", "dbus error");
296 /* report the answer */
297 afb_xreq_reply(memo->xreq, *json ? json_tokener_parse(json) : NULL, *error ? error : NULL, *info ? info : NULL);
299 api_dbus_client_memo_destroy(memo);
303 /* on call, propagate it to the dbus service */
304 static void api_dbus_client_call(void *closure, struct afb_xreq *xreq)
306 struct api_dbus *api = closure;
309 struct dbus_memo *memo;
310 struct sd_bus_message *msg;
313 /* create the recording data */
314 memo = api_dbus_client_memo_make(api, xreq);
316 afb_xreq_reply(memo->xreq, NULL, "error", "out of memory");
320 /* creates the message */
322 rc = sd_bus_message_new_method_call(api->sdbus, &msg, api->name, api->path, api->name, xreq->request.called_verb);
326 creds = xreq_on_behalf_cred_export(xreq);
327 rc = sd_bus_message_append(msg, "ssus",
328 afb_xreq_raw(xreq, &size),
329 afb_session_uuid(xreq->context.session),
330 (uint32_t)xreq->context.flags,
336 rc = sd_bus_call_async(api->sdbus, NULL, msg, api_dbus_client_on_reply, memo, (uint64_t)-1);
340 rc = sd_bus_message_get_cookie(msg, &memo->msgid);
345 /* if there was an error report it directly */
347 afb_xreq_reply(memo->xreq, NULL, "error", "dbus error");
348 api_dbus_client_memo_destroy(memo);
350 sd_bus_message_unref(msg);
353 /* receives broadcasted events */
354 static int api_dbus_client_on_broadcast_event(sd_bus_message *m, void *userdata, sd_bus_error *ret_error)
356 struct json_object *object;
357 const char *event, *data;
358 int rc = sd_bus_message_read(m, "ss", &event, &data);
360 ERROR("unreadable broadcasted event");
362 object = json_tokener_parse(data);
363 afb_evt_broadcast(event, object);
368 /* search the eventid */
369 static struct dbus_event *api_dbus_client_event_search(struct api_dbus *api, int id, const char *name)
371 struct dbus_event *ev;
373 ev = api->client.events;
374 while (ev != NULL && (ev->id != id || 0 != strcmp(afb_evt_event_x2_fullname(ev->event), name)))
380 /* adds an eventid */
381 static void api_dbus_client_event_create(struct api_dbus *api, int id, const char *name)
383 struct dbus_event *ev;
385 /* check conflicts */
386 ev = api_dbus_client_event_search(api, id, name);
392 /* no conflict, try to add it */
393 ev = malloc(sizeof *ev);
395 ev->event = afb_evt_event_x2_create(name);
396 if (ev->event == NULL)
401 ev->next = api->client.events;
402 api->client.events = ev;
406 ERROR("can't create event %s, out of memory", name);
409 /* removes an eventid */
410 static void api_dbus_client_event_drop(struct api_dbus *api, int id, const char *name)
412 struct dbus_event *ev, **prv;
414 /* retrieves the event */
415 ev = api_dbus_client_event_search(api, id, name);
417 ERROR("event %s not found", name);
421 /* decrease the reference count */
425 /* unlinks the event */
426 prv = &api->client.events;
431 /* destroys the event */
432 afb_evt_event_x2_unref(ev->event);
437 static void api_dbus_client_event_push(struct api_dbus *api, int id, const char *name, const char *data)
439 struct json_object *object;
440 struct dbus_event *ev;
442 /* retrieves the event */
443 ev = api_dbus_client_event_search(api, id, name);
445 ERROR("event %s not found", name);
449 /* destroys the event */
450 object = json_tokener_parse(data);
451 afb_evt_event_x2_push(ev->event, object);
454 /* subscribes an event */
455 static void api_dbus_client_event_subscribe(struct api_dbus *api, int id, const char *name, uint64_t msgid)
458 struct dbus_event *ev;
459 struct dbus_memo *memo;
461 /* retrieves the event */
462 ev = api_dbus_client_event_search(api, id, name);
464 ERROR("event %s not found", name);
468 /* retrieves the memo */
469 memo = api_dbus_client_memo_search(api, msgid);
471 ERROR("message not found");
475 /* subscribe the request to the event */
476 rc = afb_xreq_subscribe(memo->xreq, ev->event);
478 ERROR("can't subscribe: %m");
481 /* unsubscribes an event */
482 static void api_dbus_client_event_unsubscribe(struct api_dbus *api, int id, const char *name, uint64_t msgid)
485 struct dbus_event *ev;
486 struct dbus_memo *memo;
488 /* retrieves the event */
489 ev = api_dbus_client_event_search(api, id, name);
491 ERROR("event %s not found", name);
495 /* retrieves the memo */
496 memo = api_dbus_client_memo_search(api, msgid);
498 ERROR("message not found");
502 /* unsubscribe the request from the event */
503 rc = afb_xreq_unsubscribe(memo->xreq, ev->event);
505 ERROR("can't unsubscribe: %m");
508 /* receives calls for event */
509 static int api_dbus_client_on_manage_event(sd_bus_message *m, void *userdata, sd_bus_error *ret_error)
511 const char *eventname, *data;
515 struct api_dbus *api;
518 /* check if expected message */
520 if (0 != strcmp(api->name, sd_bus_message_get_interface(m)))
521 return 0; /* not the expected interface */
522 if (0 != strcmp("event", sd_bus_message_get_member(m)))
523 return 0; /* not the expected member */
524 if (sd_bus_message_get_expect_reply(m))
525 return 0; /* not the expected type of message */
527 /* reads the message */
528 rc = sd_bus_message_read(m, "yisst", &order, &eventid, &eventname, &data, &msgid);
530 ERROR("unreadable event");
534 /* what is the order ? */
535 switch ((char)order) {
536 case '+': /* creates the event */
537 api_dbus_client_event_create(api, eventid, eventname);
539 case '-': /* drops the event */
540 api_dbus_client_event_drop(api, eventid, eventname);
542 case '!': /* pushs the event */
543 api_dbus_client_event_push(api, eventid, eventname, data);
545 case 'S': /* subscribe event for a request */
546 api_dbus_client_event_subscribe(api, eventid, eventname, msgid);
548 case 'U': /* unsubscribe event for a request */
549 api_dbus_client_event_unsubscribe(api, eventid, eventname, msgid);
552 /* unexpected order */
553 ERROR("unexpected order '%c' received", (char)order);
559 static struct afb_api_itf dbus_api_itf = {
560 .call = api_dbus_client_call
563 /* adds a afb-dbus-service client api */
564 int afb_api_dbus_add_client(const char *path, struct afb_apiset *declare_set, struct afb_apiset *call_set)
567 struct api_dbus *api;
568 struct afb_api_item afb_api;
571 /* create the dbus client api */
572 api = make_api_dbus(path);
576 /* connect to broadcasted events */
577 rc = asprintf(&match, "type='signal',path='%s',interface='%s',member='broadcast'", api->path, api->name);
580 ERROR("out of memory");
583 rc = sd_bus_add_match(api->sdbus, &api->client.slot_broadcast, match, api_dbus_client_on_broadcast_event, api);
587 ERROR("can't add dbus match %s for %s", api->path, api->name);
591 /* connect to event management */
592 rc = sd_bus_add_object(api->sdbus, &api->client.slot_event, api->path, api_dbus_client_on_manage_event, api);
595 ERROR("can't add dbus object %s for %s", api->path, api->name);
599 /* record it as an API */
600 afb_api.closure = api;
601 afb_api.itf = &dbus_api_itf;
602 afb_api.group = NULL;
603 if (afb_apiset_add(declare_set, api->api, afb_api) < 0)
609 destroy_api_dbus(api);
614 /******************* event structures for server part **********************************/
616 static void afb_api_dbus_server_event_add(void *closure, const char *event, int eventid);
617 static void afb_api_dbus_server_event_remove(void *closure, const char *event, int eventid);
618 static void afb_api_dbus_server_event_push(void *closure, const char *event, int eventid, struct json_object *object);
619 static void afb_api_dbus_server_event_broadcast(void *closure, const char *event, int eventid, struct json_object *object);
621 /* the interface for events broadcasting */
622 static const struct afb_evt_itf evt_broadcast_itf = {
623 .broadcast = afb_api_dbus_server_event_broadcast,
626 /* the interface for events pushing */
627 static const struct afb_evt_itf evt_push_itf = {
628 .push = afb_api_dbus_server_event_push,
629 .add = afb_api_dbus_server_event_add,
630 .remove = afb_api_dbus_server_event_remove
633 /******************* origin description part for server *****************************/
637 /* link to next different origin */
640 /* the server dbus-api */
641 struct api_dbus *api;
643 /* count of references */
646 /* credentials of the origin */
647 struct afb_cred *cred;
653 /* get the credentials for the message */
654 static void init_origin_creds(struct origin *origin)
663 rc = sd_bus_get_name_creds(origin->api->sdbus, origin->name,
664 SD_BUS_CREDS_PID|SD_BUS_CREDS_UID|SD_BUS_CREDS_GID|SD_BUS_CREDS_SELINUX_CONTEXT,
669 afb_cred_unref(origin->cred);
670 sd_bus_creds_get_uid(c, &uid);
671 sd_bus_creds_get_gid(c, &gid);
672 sd_bus_creds_get_pid(c, &pid);
673 sd_bus_creds_get_selinux_context(c, &context);
674 origin->cred = afb_cred_create(uid, gid, pid, context);
675 sd_bus_creds_unref(c);
679 static struct origin *afb_api_dbus_server_origin_get(struct api_dbus *api, const char *sender)
681 struct origin *origin;
683 /* searchs for an existing origin */
684 origin = api->server.origins;
685 while (origin != NULL) {
686 if (0 == strcmp(origin->name, sender)) {
690 origin = origin->next;
693 /* not found, create it */
694 origin = malloc(strlen(sender) + sizeof *origin);
699 origin->refcount = 1;
700 strcpy(origin->name, sender);
701 init_origin_creds(origin);
702 origin->next = api->server.origins;
703 api->server.origins = origin;
708 static void afb_api_dbus_server_origin_unref(struct origin *origin)
710 if (!--origin->refcount) {
713 prv = &origin->api->server.origins;
714 while(*prv != origin)
717 afb_cred_unref(origin->cred);
724 /* link to next different origin */
725 struct origin *origin;
727 /* the listener of events */
728 struct afb_evt_listener *listener;
731 static void afb_api_dbus_server_listener_free(struct listener *listener)
733 afb_evt_listener_unref(listener->listener);
734 afb_api_dbus_server_origin_unref(listener->origin);
738 static struct listener *afb_api_dbus_server_listener_get(struct api_dbus *api, const char *sender, struct afb_session *session)
741 struct listener *listener;
742 struct origin *origin;
745 origin = afb_api_dbus_server_origin_get(api, sender);
749 /* retrieves the stored listener */
750 listener = afb_session_get_cookie(session, origin);
751 if (listener != NULL) {
753 afb_api_dbus_server_origin_unref(origin);
757 /* creates the listener */
758 listener = malloc(sizeof *listener);
759 if (listener == NULL)
762 listener->origin = origin;
763 listener->listener = afb_evt_listener_create(&evt_push_itf, origin);
764 if (listener->listener != NULL) {
765 rc = afb_session_set_cookie(session, origin, listener, (void*)afb_api_dbus_server_listener_free);
768 afb_evt_listener_unref(listener->listener);
772 afb_api_dbus_server_origin_unref(origin);
776 /******************* dbus request part for server *****************/
779 * Structure for a dbus request
782 struct afb_xreq xreq; /**< the xreq of the request */
783 sd_bus_message *message; /**< the incoming request message */
784 const char *request; /**< the readen request as string */
785 struct json_object *json; /**< the readen request as object */
786 struct listener *listener; /**< the listener for events */
789 /* decrement the reference count of the request and free/release it on falling to null */
790 static void dbus_req_destroy(struct afb_xreq *xreq)
792 struct dbus_req *dreq = CONTAINER_OF_XREQ(struct dbus_req, xreq);
794 afb_context_disconnect(&dreq->xreq.context);
795 json_object_put(dreq->json);
796 sd_bus_message_unref(dreq->message);
800 /* get the object of the request */
801 static struct json_object *dbus_req_json(struct afb_xreq *xreq)
803 struct dbus_req *dreq = CONTAINER_OF_XREQ(struct dbus_req, xreq);
808 void dbus_req_raw_reply(struct afb_xreq *xreq, struct json_object *obj, const char *error, const char *info)
810 struct dbus_req *dreq = CONTAINER_OF_XREQ(struct dbus_req, xreq);
813 rc = sd_bus_reply_method_return(dreq->message, "sss",
814 obj ? json_object_to_json_string_ext(obj, JSON_C_TO_STRING_PLAIN) : "",
818 ERROR("sending the reply failed");
821 static void afb_api_dbus_server_event_send(struct origin *origin, char order, const char *event, int eventid, const char *data, uint64_t msgid);
823 static int dbus_req_subscribe(struct afb_xreq *xreq, struct afb_event_x2 *event)
825 struct dbus_req *dreq = CONTAINER_OF_XREQ(struct dbus_req, xreq);
829 rc = afb_evt_event_x2_add_watch(dreq->listener->listener, event);
830 sd_bus_message_get_cookie(dreq->message, &msgid);
831 afb_api_dbus_server_event_send(dreq->listener->origin, 'S', afb_evt_event_x2_fullname(event), afb_evt_event_x2_id(event), "", msgid);
835 static int dbus_req_unsubscribe(struct afb_xreq *xreq, struct afb_event_x2 *event)
837 struct dbus_req *dreq = CONTAINER_OF_XREQ(struct dbus_req, xreq);
841 sd_bus_message_get_cookie(dreq->message, &msgid);
842 afb_api_dbus_server_event_send(dreq->listener->origin, 'U', afb_evt_event_x2_fullname(event), afb_evt_event_x2_id(event), "", msgid);
843 rc = afb_evt_event_x2_remove_watch(dreq->listener->listener, event);
847 const struct afb_xreq_query_itf afb_api_dbus_xreq_itf = {
848 .json = dbus_req_json,
849 .reply = dbus_req_raw_reply,
850 .unref = dbus_req_destroy,
851 .subscribe = dbus_req_subscribe,
852 .unsubscribe = dbus_req_unsubscribe,
855 /******************* server part **********************************/
857 static void afb_api_dbus_server_event_send(struct origin *origin, char order, const char *event, int eventid, const char *data, uint64_t msgid)
860 struct api_dbus *api;
861 struct sd_bus_message *msg;
866 rc = sd_bus_message_new_method_call(api->sdbus, &msg, origin->name, api->path, api->name, "event");
870 rc = sd_bus_message_append(msg, "yisst", (uint8_t)order, (int32_t)eventid, event, data, msgid);
874 rc = sd_bus_send(api->sdbus, msg, NULL); /* NULL for cookie implies no expected reply */
879 ERROR("error while send event %c%s(%d) to %s", order, event, eventid, origin->name);
881 sd_bus_message_unref(msg);
884 static void afb_api_dbus_server_event_add(void *closure, const char *event, int eventid)
886 afb_api_dbus_server_event_send(closure, '+', event, eventid, "", 0);
889 static void afb_api_dbus_server_event_remove(void *closure, const char *event, int eventid)
891 afb_api_dbus_server_event_send(closure, '-', event, eventid, "", 0);
894 static void afb_api_dbus_server_event_push(void *closure, const char *event, int eventid, struct json_object *object)
896 const char *data = json_object_to_json_string_ext(object, JSON_C_TO_STRING_PLAIN);
897 afb_api_dbus_server_event_send(closure, '!', event, eventid, data, 0);
898 json_object_put(object);
901 static void afb_api_dbus_server_event_broadcast(void *closure, const char *event, int eventid, struct json_object *object)
904 struct api_dbus *api;
907 rc = sd_bus_emit_signal(api->sdbus, api->path, api->name, "broadcast",
908 "ss", event, json_object_to_json_string_ext(object, JSON_C_TO_STRING_PLAIN));
910 ERROR("error while broadcasting event %s", event);
911 json_object_put(object);
914 /* called when the object for the service is called */
915 static int api_dbus_server_on_object_called(sd_bus_message *message, void *userdata, sd_bus_error *ret_error)
921 struct dbus_req *dreq;
922 struct api_dbus *api = userdata;
924 struct afb_session *session;
925 struct listener *listener;
927 /* check the interface */
928 if (strcmp(sd_bus_message_get_interface(message), api->name) != 0)
932 method = sd_bus_message_get_member(message);
934 /* create the request */
935 dreq = calloc(1 , sizeof *dreq);
940 rc = sd_bus_message_read(message, "ssus", &dreq->request, &uuid, &flags, &creds);
942 sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_SIGNATURE, "invalid signature");
946 /* connect to the context */
947 afb_xreq_init(&dreq->xreq, &afb_api_dbus_xreq_itf);
948 if (afb_context_connect(&dreq->xreq.context, uuid, NULL) < 0)
950 session = dreq->xreq.context.session;
952 /* get the listener */
953 listener = afb_api_dbus_server_listener_get(api, sd_bus_message_get_sender(message), session);
954 if (listener == NULL)
957 /* fulfill the request and emit it */
958 dreq->xreq.context.flags = flags;
959 dreq->xreq.cred = afb_cred_mixed_on_behalf_import(listener->origin->cred, uuid, creds && creds[0] ? creds : NULL);
960 dreq->message = sd_bus_message_ref(message);
961 dreq->json = json_tokener_parse(dreq->request);
962 if (dreq->json == NULL && strcmp(dreq->request, "null")) {
963 /* lazy error detection of json request. Is it to improve? */
964 dreq->json = json_object_new_string(dreq->request);
966 dreq->listener = listener;
967 dreq->xreq.request.called_api = api->api;
968 dreq->xreq.request.called_verb = method;
969 afb_xreq_process(&dreq->xreq, api->server.apiset);
973 sd_bus_reply_method_errorf(message, SD_BUS_ERROR_NO_MEMORY, "out of memory");
979 /* create the service */
980 int afb_api_dbus_add_server(const char *path, struct afb_apiset *declare_set, struct afb_apiset *call_set)
983 struct api_dbus *api;
985 /* get the dbus api object connected */
986 api = make_api_dbus(path);
990 /* request the service object name */
991 rc = sd_bus_request_name(api->sdbus, api->name, 0);
994 ERROR("can't register name %s", api->name);
998 /* connect the service to the dbus object */
999 rc = sd_bus_add_object(api->sdbus, &api->server.slot_call, api->path, api_dbus_server_on_object_called, api);
1002 ERROR("can't add dbus object %s for %s", api->path, api->name);
1005 INFO("afb service over dbus installed, name %s, path %s", api->name, api->path);
1007 api->server.listener = afb_evt_listener_create(&evt_broadcast_itf, api);
1008 api->server.apiset = afb_apiset_addref(call_set);
1011 sd_bus_release_name(api->sdbus, api->name);
1013 destroy_api_dbus(api);