summaryrefslogtreecommitdiff
path: root/src/responder/nss/nsssrv_private.h
blob: f1d47c3bc4a62fb816b7b262083e36c05383673d (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
/*
    SSSD

    nsssrv_private.h

    Authors:
        Stephen Gallagher <sgallagh@redhat.com>

    Copyright (C) 2010 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/>.
*/

#ifndef NSSSRV_PRIVATE_H_
#define NSSSRV_PRIVATE_H_

#include "dhash.h"

struct nss_cmd_ctx {
    struct cli_ctx *cctx;
    char *name;
    uint32_t id;

    bool immediate;
    bool check_next;
    bool enum_cached;

    int saved_dom_idx;
    int saved_cur;
};

struct dom_ctx {
    struct sss_domain_info *domain;
    struct ldb_result *res;
};

struct getent_ctx {
    struct dom_ctx *doms;
    int num;
    bool ready;
    struct setent_req_list *reqs;

    /* Netgroup-specific */
    hash_table_t *lookup_table;
    struct sysdb_netgroup_ctx **entries;
    char *name;
    char *domain;
    bool found;
};

struct nss_dom_ctx {
    struct nss_cmd_ctx *cmdctx;
    struct sss_domain_info *domain;

    /* For a case when we are discovering subdomains */
    const char *rawname;

    bool check_provider;

    /* cache results */
    struct ldb_result *res;

    /* Netgroup-specific */
    struct getent_ctx *netgr;

    /* Service-specific */
    const char *protocol;
};

struct setent_step_ctx {
    struct nss_ctx *nctx;
    struct nss_dom_ctx *dctx;
    struct getent_ctx *getent_ctx;
    struct resp_ctx *rctx;
    struct cli_ctx *cctx;
    bool check_next;

    bool returned_to_mainloop;

    /* Netgroup-specific */
    char *name;
};

#define NSS_CMD_FATAL_ERROR(cctx) do { \
    DEBUG(1,("Fatal error, killing connection!\n")); \
    talloc_free(cctx); \
    return; \
} while(0)

#define NSS_CMD_FATAL_ERROR_CODE(cctx, ret) do { \
    DEBUG(1,("Fatal error, killing connection!\n")); \
    talloc_free(cctx); \
    return ret; \
} while(0)

/* Finish the request */
int nss_cmd_done(struct nss_cmd_ctx *cmdctx, int ret);

errno_t nss_setent_add_ref(TALLOC_CTX *memctx,
                           struct getent_ctx *getent_ctx,
                           struct tevent_req *req);

void nss_setent_notify_error(struct getent_ctx *getent_ctx, errno_t ret);
void nss_setent_notify_done(struct getent_ctx *getent_ctx);

errno_t check_cache(struct nss_dom_ctx *dctx,
                    struct nss_ctx *nctx,
                    struct ldb_result *res,
                    int req_type,
                    const char *opt_name,
                    uint32_t opt_id,
                    sss_dp_callback_t callback,
                    void *pvt);

#endif /* NSSSRV_PRIVATE_H_ */