summaryrefslogtreecommitdiffstats
path: root/src/responder/ifp/ifp_iface.c
blob: 1878263c2b4dd20b4d3f5931d56eb39e952bad50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
    Authors:
        Pavel Březina <pbrezina@redhat.com>

    Copyright (C) 2015 Red Hat

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <dbus/dbus.h>

#include "sbus/sssd_dbus.h"
#include "responder/ifp/ifp_iface_generated.h"
#include "responder/ifp/ifp_domains.h"
#include "responder/ifp/ifp_components.h"
#include "responder/ifp/ifp_users.h"

struct iface_ifp iface_ifp = {
    { &iface_ifp_meta, 0 },
    .Ping = ifp_ping,

    /* components */
    .ListComponents = ifp_list_components,
    .ListResponders = ifp_list_responders,
    .ListBackends = ifp_list_backends,
    .FindMonitor = ifp_find_monitor,
    .FindResponderByName = ifp_find_responder_by_name,
    .FindBackendByName = ifp_find_backend_by_name,

    .GetUserAttr = ifp_user_get_attr,
    .GetUserGroups = ifp_user_get_groups,
    .ListDomains = ifp_list_domains,
    .FindDomainByName = ifp_find_domain_by_name,
};

struct iface_ifp_components iface_ifp_components = {
    { &iface_ifp_components_meta, 0 },
    .Enable = ifp_component_enable,
    .Disable = ifp_component_disable,
    .ChangeDebugLevel = ifp_component_change_debug_level,
    .ChangeDebugLevelTemporarily = ifp_component_change_debug_level_tmp,
    .get_name = ifp_component_get_name,
    .get_debug_level = ifp_component_get_debug_level,
    .get_enabled = ifp_component_get_enabled,
    .get_type = ifp_component_get_type,
    /* FIXME: This should be part of Components.Backends interface, onece
     * SSSD supports multiple interfaces per object path. */
    .get_providers = ifp_backend_get_providers
};

struct iface_ifp_domains iface_ifp_domains = {
    { &iface_ifp_domains_meta, 0 },
    .get_name = ifp_dom_get_name,
    .get_provider = ifp_dom_get_provider,
    .get_primary_servers = ifp_dom_get_primary_servers,
    .get_backup_servers = ifp_dom_get_backup_servers,
    .get_min_id = ifp_dom_get_min_id,
    .get_max_id = ifp_dom_get_max_id,
    .get_realm = ifp_dom_get_realm,
    .get_forest = ifp_dom_get_forest,
    .get_login_format = ifp_dom_get_login_format,
    .get_fully_qualified_name_format = ifp_dom_get_fqdn_format,
    .get_enumerable = ifp_dom_get_enumerable,
    .get_use_fully_qualified_names = ifp_dom_get_use_fqdn,
    .get_subdomain = ifp_dom_get_subdomain,
    .get_parent_domain = ifp_dom_get_parent_domain
};

struct iface_ifp_users iface_ifp_users = {
    { &iface_ifp_users_meta, 0 },
    .FindByName = ifp_users_find_by_name,
    .FindByID = ifp_users_find_by_id,
    .ListByName = ifp_users_list_by_name,
    .ListByDomainAndName = ifp_users_list_by_domain_and_name
};

struct iface_ifp_users_user iface_ifp_users_user = {
    { &iface_ifp_users_user_meta, 0 },
    .UpdateGroupsList = ifp_users_user_update_groups_list,
    .get_name = ifp_users_user_get_name,
    .get_uidNumber = ifp_users_user_get_uid_number,
    .get_gidNumber = ifp_users_user_get_gid_number,
    .get_gecos = ifp_users_user_get_gecos,
    .get_homeDirectory = ifp_users_user_get_home_directory,
    .get_loginShell = ifp_users_user_get_login_shell,
    .get_groups = ifp_users_user_get_groups,
    .get_extraAttributes = ifp_users_user_get_extra_attributes
};

struct iface_map {
    const char *path;
    struct sbus_vtable *vtable;
};

static struct iface_map iface_map[] = {
    { IFP_PATH, &iface_ifp.vtable },
    { IFP_PATH_DOMAINS_TREE, &iface_ifp_domains.vtable },
    { IFP_PATH_COMPONENTS_TREE, &iface_ifp_components.vtable },
    { IFP_PATH_USERS, &iface_ifp_users.vtable },
    { IFP_PATH_USERS_TREE, &iface_ifp_users_user.vtable },
    { NULL, NULL },
};

errno_t ifp_register_sbus_interface(struct sbus_connection *conn, void *pvt)
{
    errno_t ret;
    int i;

    for (i = 0; iface_map[i].path != NULL; i++) {
        ret = sbus_conn_register_iface(conn, iface_map[i].vtable,
                                       iface_map[i].path, pvt);
        if (ret != EOK) {
            return ret;
        }
    }

    return EOK;
}