sssd_dbus_interface.c revision b742179ac0790068380618ab72a06af18544f09c
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor Pavel Březina <pbrezina@redhat.com>
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor Copyright (C) 2014 Red Hat
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor This program is free software; you can redistribute it and/or modify
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor it under the terms of the GNU General Public License as published by
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor the Free Software Foundation; either version 3 of the License, or
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor (at your option) any later version.
2e545ce2450a9953665f701bb05350f0d3f26275nd This program is distributed in the hope that it will be useful,
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen but WITHOUT ANY WARRANTY; without even the implied warranty of
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor GNU General Public License for more details.
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor You should have received a copy of the GNU General Public License
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen along with this program. If not, see <http://www.gnu.org/licenses/>.
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzorstatic struct sbus_interface *
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzorsbus_iface_list_lookup(struct sbus_interface_list *list,
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor const char *iface)
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor if (strcmp(item->interface->vtable->meta->name, iface) == 0) {
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor /* already in list */
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor new_item = talloc_zero(list_ctx, struct sbus_interface_list);
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor * Object paths that represent all objects under the path:
1462ff536f1b939bb337766b2056109c29664c4erbowen * /org/object/path/~* (without tilda)
25f8d56998acb95d39c62c489d72b92d8d29b765humbedooh return false;
25f8d56998acb95d39c62c489d72b92d8d29b765humbedooh return path[len - 2] == '/' && path[len - 1] == '*';
65a611af7093423efb91e5794b8887a527d4cf63trawick * If the path represents a subtree object path, this function will
65a611af7093423efb91e5794b8887a527d4cf63trawick * remove /~* from the end.
65a611af7093423efb91e5794b8887a527d4cf63trawickstatic char *sbus_opath_get_base_path(TALLOC_CTX *mem_ctx,
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor /* replace / only if it is not a root path (only slash) */
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzorstatic char *sbus_opath_parent_subtree(TALLOC_CTX *mem_ctx,
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor const char *path)
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor /* first remove /~* from the end, stop when we have reached the root i.e.
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor * subtree == "/" */
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor /* Find the first separator and replace the part with asterisk. */
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor /* we cannot continue up */
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor /* this object path is invalid since it cannot end with slash */
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor DEBUG(SSSDBG_CRIT_FAILURE, "Invalid object path '%s'?\n", path);
1462ff536f1b939bb337766b2056109c29664c4erbowen /* because object path cannot end with / there is enough space for
1462ff536f1b939bb337766b2056109c29664c4erbowen * asterisk and terminating zero */
1462ff536f1b939bb337766b2056109c29664c4erbowen path = sbus_opath_get_base_path(NULL, item->key.str);
1462ff536f1b939bb337766b2056109c29664c4erbowen dbus_connection_unregister_object_path(conn->dbus.conn, path);
737a1f4117ce00c29a1b78b93db08e4a273ab2edtrawick return sss_hash_create_ex(mem_ctx, 10, _table, 0, 0, 0, 0,
1462ff536f1b939bb337766b2056109c29664c4erbowen DEBUG(SSSDBG_TRACE_FUNC, "Registering interface %s with path %s\n",
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor /* create new list item */
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor item = talloc_zero(tmp_ctx, struct sbus_interface_list);
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh /* first lookup existing list in hash table */
0d0ba3a410038e179b695446bb149cce6264e0abnd /* This object path has already some interface registered. We will
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh * check for existence of the interface currently being added and
07dc96d063d49299da433f84b5c5681da9bbdf68rbowen * add it if missing. */
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd list = talloc_get_type(value.ptr, struct sbus_interface_list);
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor DEBUG(SSSDBG_MINOR_FAILURE, "Trying to register the same interface"
goto done;
goto done;
goto done;
path_known = false;
goto done;
done:
return ret;
const char *object_path)
struct sbus_interface *
const char *object_path,
const char *iface_name)
int hret;
return NULL;
goto done;
goto done;
goto done;
done:
return iface;
const char *object_path,
int hret;
return ENOMEM;
goto done;
goto done;
goto done;
goto done;
done:
return ret;
static struct sbus_interface *
const char *object_path,
void *instance_data)
return NULL;
return NULL;
return intf;
static DBusHandlerResult
void *user_data);
static errno_t
const char *path)
return ENOMEM;
return EOK;
if (!dbret) {
return ENOMEM;
return EOK;
const char *object_path,
void *pvt)
bool path_known;
return EINVAL;
return ENOMEM;
&path_known);
return ret;
if (path_known) {
return EOK;
return ret;
return ret;
return ret;
return ret;
unsigned long count;
int hret;
goto done;
for (i = 0; i < count; i++) {
goto done;
done:
return ret;
static DBusHandlerResult
void *user_data)
const char *iface_name;
const char *method_name;
const char *path;
const char *sender;
goto fail;
goto fail;
return DBUS_HANDLER_RESULT_NEED_MEMORY;
return DBUS_HANDLER_RESULT_NEED_MEMORY;
return DBUS_HANDLER_RESULT_HANDLED;
fail: ;
return DBUS_HANDLER_RESULT_HANDLED;
void *pvt;