summaryrefslogtreecommitdiffstats
path: root/src/responder/ifp/ifp_private.h
blob: 43519de6fef3033f1e47cecb787d6b02dc9c6e56 (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
/*
    Authors:
        Jakub Hrozek <jhrozek@redhat.com>
        Stephen Gallagher <sgallagh@redhat.com>

    Copyright (C) 2013 Red Hat

    InfoPipe responder: A private header

    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/>.
*/

#ifndef _IFPSRV_PRIVATE_H_
#define _IFPSRV_PRIVATE_H_

#include "responder/common/responder.h"
#include "responder/common/negcache.h"
#include "providers/data_provider.h"
#include "responder/ifp/ifp_iface_generated.h"

#define IFP_PATH "/org/freedesktop/sssd/infopipe"

struct sysbus_ctx {
    struct sbus_connection *conn;
    char *introspect_xml;
};

struct ifp_ctx {
    struct resp_ctx *rctx;
    struct sss_names_ctx *snctx;
    struct sss_nc_ctx *ncache;
    int neg_timeout;

    struct sysbus_ctx *sysbus;
    const char **user_whitelist;
    uint32_t wildcard_limit;
};

errno_t ifp_register_sbus_interface(struct sbus_connection *conn,
                                    void *handler_data);

void ifp_register_nodes(struct ifp_ctx *ctx, struct sbus_connection *conn);

/* This is a throwaway method to ease the review of the patch.
 * It will be removed later */
int ifp_ping(struct sbus_request *dbus_req, void *data);

int ifp_user_get_attr(struct sbus_request *dbus_req, void *data);

int ifp_user_get_groups(struct sbus_request *req,
                        void *data, const char *arg_user);

/* == Utility functions == */
struct ifp_req {
    struct sbus_request *dbus_req;
    struct ifp_ctx *ifp_ctx;
};

errno_t ifp_req_create(struct sbus_request *dbus_req,
                       struct ifp_ctx *ifp_ctx,
                       struct ifp_req **_ifp_req);

/* Returns an appropriate DBus error for specific ifp_req_create failures */
int ifp_req_create_handle_failure(struct sbus_request *dbus_req, errno_t err);

errno_t ifp_add_ldb_el_to_dict(DBusMessageIter *iter_dict,
                               struct ldb_message_element *el);
const char **
ifp_parse_user_attr_list(TALLOC_CTX *mem_ctx, const char *conf_str);

const char **
ifp_get_user_extra_attributes(TALLOC_CTX *mem_ctx, struct ifp_ctx *ifp_ctx);

bool ifp_attr_allowed(const char *whitelist[], const char *attr);
bool ifp_is_user_attr_allowed(struct ifp_ctx *ifp_ctx, const char *attr);

/* Used for list calls */
struct ifp_list_ctx {
    struct sbus_request *sbus_req;
    const char *filter;
    uint32_t limit;

    struct sss_domain_info *dom;
    struct ifp_ctx *ctx;

    const char **paths;
    size_t path_count;
};

struct ifp_list_ctx *ifp_list_ctx_new(struct sbus_request *sbus_req,
                                      struct ifp_ctx *ctx,
                                      const char *filter,
                                      uint32_t limit);

size_t ifp_list_ctx_remaining_capacity(struct ifp_list_ctx *list_ctx,
                                       size_t entries);

#endif /* _IFPSRV_PRIVATE_H_ */