ifp_iface.c revision 8fe171bf5a7a570591418e6548105f1d5a0097b3
842ae4bd224140319ae7feec1872b93dfd491143fielding/*
842ae4bd224140319ae7feec1872b93dfd491143fielding Authors:
842ae4bd224140319ae7feec1872b93dfd491143fielding Pavel Březina <pbrezina@redhat.com>
842ae4bd224140319ae7feec1872b93dfd491143fielding
842ae4bd224140319ae7feec1872b93dfd491143fielding Copyright (C) 2015 Red Hat
842ae4bd224140319ae7feec1872b93dfd491143fielding
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz This program is free software; you can redistribute it and/or modify
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd it under the terms of the GNU General Public License as published by
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz the Free Software Foundation; either version 3 of the License, or
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd (at your option) any later version.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd This program is distributed in the hope that it will be useful,
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd but WITHOUT ANY WARRANTY; without even the implied warranty of
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz GNU General Public License for more details.
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz You should have received a copy of the GNU General Public License
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz along with this program. If not, see <http://www.gnu.org/licenses/>.
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz*/
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz#include <dbus/dbus.h>
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz#include "sbus/sssd_dbus.h"
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz#include "responder/ifp/ifp_iface_generated.h"
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz#include "responder/ifp/ifp_domains.h"
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz#include "responder/ifp/ifp_components.h"
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz#include "responder/ifp/ifp_users.h"
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes#include "responder/ifp/ifp_groups.h"
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantzstruct iface_ifp iface_ifp = {
42a58c2174dae6edfc97af967add2f50baa85800jim { &iface_ifp_meta, 0 },
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz .Ping = ifp_ping,
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz /* components */
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz .ListComponents = ifp_list_components,
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz .ListResponders = ifp_list_responders,
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz .ListBackends = ifp_list_backends,
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz .FindMonitor = ifp_find_monitor,
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz .FindResponderByName = ifp_find_responder_by_name,
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz .FindBackendByName = ifp_find_backend_by_name,
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz .GetUserAttr = ifp_user_get_attr,
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz .GetUserGroups = ifp_user_get_groups,
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz .ListDomains = ifp_list_domains,
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz .FindDomainByName = ifp_find_domain_by_name,
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz};
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholesstruct iface_ifp_components iface_ifp_components = {
97cc46935ec496b83fef9d6feb094d706c895b3bsf { &iface_ifp_components_meta, 0 },
97cc46935ec496b83fef9d6feb094d706c895b3bsf .Enable = ifp_component_enable,
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz .Disable = ifp_component_disable,
194c1e226415b5f34251d249ffe2f8b96c835637minfrin .ChangeDebugLevel = ifp_component_change_debug_level,
194c1e226415b5f34251d249ffe2f8b96c835637minfrin .ChangeDebugLevelTemporarily = ifp_component_change_debug_level_tmp,
194c1e226415b5f34251d249ffe2f8b96c835637minfrin .get_name = ifp_component_get_name,
194c1e226415b5f34251d249ffe2f8b96c835637minfrin .get_debug_level = ifp_component_get_debug_level,
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz .get_enabled = ifp_component_get_enabled,
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz .get_type = ifp_component_get_type,
db027b0af55a7fa31f2e1659368d606a8b860bb0chrisd /* FIXME: This should be part of Components.Backends interface, onece
18b5268e013574026b2503b1641baf3299045f45sf * SSSD supports multiple interfaces per object path. */
db027b0af55a7fa31f2e1659368d606a8b860bb0chrisd .get_providers = ifp_backend_get_providers
db027b0af55a7fa31f2e1659368d606a8b860bb0chrisd};
194c1e226415b5f34251d249ffe2f8b96c835637minfrin
194c1e226415b5f34251d249ffe2f8b96c835637minfrinstruct iface_ifp_domains iface_ifp_domains = {
194c1e226415b5f34251d249ffe2f8b96c835637minfrin { &iface_ifp_domains_meta, 0 },
194c1e226415b5f34251d249ffe2f8b96c835637minfrin .get_name = ifp_dom_get_name,
194c1e226415b5f34251d249ffe2f8b96c835637minfrin .get_provider = ifp_dom_get_provider,
194c1e226415b5f34251d249ffe2f8b96c835637minfrin .get_primary_servers = ifp_dom_get_primary_servers,
194c1e226415b5f34251d249ffe2f8b96c835637minfrin .get_backup_servers = ifp_dom_get_backup_servers,
194c1e226415b5f34251d249ffe2f8b96c835637minfrin .get_min_id = ifp_dom_get_min_id,
194c1e226415b5f34251d249ffe2f8b96c835637minfrin .get_max_id = ifp_dom_get_max_id,
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes .get_realm = ifp_dom_get_realm,
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes .get_forest = ifp_dom_get_forest,
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes .get_login_format = ifp_dom_get_login_format,
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz .get_fully_qualified_name_format = ifp_dom_get_fqdn_format,
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz .get_enumerable = ifp_dom_get_enumerable,
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz .get_use_fully_qualified_names = ifp_dom_get_use_fqdn,
b1f989ad92bf5918c4f48babb99238d5201da6fccovener .get_subdomain = ifp_dom_get_subdomain,
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz .get_parent_domain = ifp_dom_get_parent_domain
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes};
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes
e8f95a682820a599fe41b22977010636be5c2717jimstruct iface_ifp_users iface_ifp_users = {
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes { &iface_ifp_users_meta, 0 },
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz .FindByName = ifp_users_find_by_name,
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz .FindByID = ifp_users_find_by_id,
97cc46935ec496b83fef9d6feb094d706c895b3bsf .ListByName = ifp_users_list_by_name,
97cc46935ec496b83fef9d6feb094d706c895b3bsf .ListByDomainAndName = ifp_users_list_by_domain_and_name
97cc46935ec496b83fef9d6feb094d706c895b3bsf};
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes
db027b0af55a7fa31f2e1659368d606a8b860bb0chrisdstruct iface_ifp_users_user iface_ifp_users_user = {
18b5268e013574026b2503b1641baf3299045f45sf { &iface_ifp_users_user_meta, 0 },
db027b0af55a7fa31f2e1659368d606a8b860bb0chrisd .UpdateGroupsList = ifp_users_user_update_groups_list,
db027b0af55a7fa31f2e1659368d606a8b860bb0chrisd .get_name = ifp_users_user_get_name,
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes .get_uidNumber = ifp_users_user_get_uid_number,
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes .get_gidNumber = ifp_users_user_get_gid_number,
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes .get_gecos = ifp_users_user_get_gecos,
194c1e226415b5f34251d249ffe2f8b96c835637minfrin .get_homeDirectory = ifp_users_user_get_home_directory,
194c1e226415b5f34251d249ffe2f8b96c835637minfrin .get_loginShell = ifp_users_user_get_login_shell,
194c1e226415b5f34251d249ffe2f8b96c835637minfrin .get_groups = ifp_users_user_get_groups,
194c1e226415b5f34251d249ffe2f8b96c835637minfrin .get_extraAttributes = ifp_users_user_get_extra_attributes
194c1e226415b5f34251d249ffe2f8b96c835637minfrin};
194c1e226415b5f34251d249ffe2f8b96c835637minfrin
194c1e226415b5f34251d249ffe2f8b96c835637minfrinstruct iface_ifp_groups iface_ifp_groups = {
194c1e226415b5f34251d249ffe2f8b96c835637minfrin { &iface_ifp_groups_meta, 0 },
194c1e226415b5f34251d249ffe2f8b96c835637minfrin .FindByName = ifp_groups_find_by_name,
194c1e226415b5f34251d249ffe2f8b96c835637minfrin .FindByID = ifp_groups_find_by_id,
194c1e226415b5f34251d249ffe2f8b96c835637minfrin .ListByName = ifp_groups_list_by_name,
194c1e226415b5f34251d249ffe2f8b96c835637minfrin .ListByDomainAndName = ifp_groups_list_by_domain_and_name
194c1e226415b5f34251d249ffe2f8b96c835637minfrin};
194c1e226415b5f34251d249ffe2f8b96c835637minfrin
194c1e226415b5f34251d249ffe2f8b96c835637minfrinstruct iface_ifp_groups_group iface_ifp_groups_group = {
194c1e226415b5f34251d249ffe2f8b96c835637minfrin { &iface_ifp_groups_group_meta, 0 },
194c1e226415b5f34251d249ffe2f8b96c835637minfrin .UpdateMemberList = ifp_groups_group_update_member_list,
194c1e226415b5f34251d249ffe2f8b96c835637minfrin .get_name = ifp_groups_group_get_name,
194c1e226415b5f34251d249ffe2f8b96c835637minfrin .get_gidNumber = ifp_groups_group_get_gid_number,
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes .get_users = ifp_groups_group_get_users,
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes .get_groups = ifp_groups_group_get_groups
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes};
194c1e226415b5f34251d249ffe2f8b96c835637minfrin
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholesstruct iface_map {
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes const char *path;
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes struct sbus_vtable *vtable;
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes};
97cc46935ec496b83fef9d6feb094d706c895b3bsf
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholesstatic struct iface_map iface_map[] = {
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes { IFP_PATH, &iface_ifp.vtable },
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz { IFP_PATH_DOMAINS_TREE, &iface_ifp_domains.vtable },
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz { IFP_PATH_COMPONENTS_TREE, &iface_ifp_components.vtable },
2e242dca7111f99d54dd144b7b8418d88d560032chrisd { IFP_PATH_USERS, &iface_ifp_users.vtable },
2e242dca7111f99d54dd144b7b8418d88d560032chrisd { IFP_PATH_USERS_TREE, &iface_ifp_users_user.vtable },
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd { IFP_PATH_GROUPS, &iface_ifp_groups.vtable },
2e242dca7111f99d54dd144b7b8418d88d560032chrisd { IFP_PATH_GROUPS_TREE, &iface_ifp_groups_group.vtable },
2e242dca7111f99d54dd144b7b8418d88d560032chrisd { NULL, NULL },
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd};
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantzerrno_t ifp_register_sbus_interface(struct sbus_connection *conn, void *pvt)
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz{
36ef8f77bffe75d1aa327882be1b5bdbe2ff567asf errno_t ret;
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz int i;
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz for (i = 0; iface_map[i].path != NULL; i++) {
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz ret = sbus_conn_register_iface(conn, iface_map[i].vtable,
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz iface_map[i].path, pvt);
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz if (ret != EOK) {
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz return ret;
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz }
b4a287513d176e4355dd56ea47b27228e0e5d75fjerenkrantz }
return EOK;
}