sssd 2.12.0
data_provider.h
1/*
2 SSSD
3
4 Data Provider, private header file
5
6 Copyright (C) Simo Sorce <ssorce@redhat.com> 2008
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#ifndef __DATA_PROVIDER_H__
23#define __DATA_PROVIDER_H__
24
25#include "config.h"
26
27#include <stdint.h>
28#include <sys/un.h>
29#include <errno.h>
30#include <stdbool.h>
31#ifdef USE_KEYRING
32#include <sys/types.h>
33#include <keyutils.h>
34#endif
35#include <talloc.h>
36#include <tevent.h>
37#include <ldb.h>
38#include <dbus/dbus.h>
39
40#include "util/util.h"
41#include "confdb/confdb.h"
42#include "sss_client/sss_cli.h"
43#include "util/authtok.h"
44#include "util/sss_pam_data.h"
45#include "providers/data_provider_req.h"
46
47#define DATA_PROVIDER_VERSION 0x0001
48
61
107
108 /* end of group pamHandler */
112
113#define DP_ERR_DECIDE -1
114#define DP_ERR_OK 0
115#define DP_ERR_OFFLINE 1
116#define DP_ERR_TIMEOUT 2
117#define DP_ERR_FATAL 3
118
119#define BE_FILTER_NAME 1
120#define BE_FILTER_IDNUM 2
121#define BE_FILTER_ENUM 3
122#define BE_FILTER_SECID 4
123#define BE_FILTER_UUID 5
124#define BE_FILTER_CERT 6
125#define BE_FILTER_WILDCARD 7
126#define BE_FILTER_ADDR 8
127
128#define DP_SEC_ID "secid"
129#define DP_CERT "cert"
130/* sizeof() counts the trailing \0 so we must subtract 1 for the string
131 * length */
132#define DP_SEC_ID_LEN (sizeof(DP_SEC_ID) - 1)
133#define DP_CERT_LEN (sizeof(DP_CERT) - 1)
134
135#define DP_WILDCARD "wildcard"
136#define DP_WILDCARD_LEN (sizeof(DP_WILDCARD) - 1)
137
138#define EXTRA_NAME_IS_UPN "U"
139#define EXTRA_INPUT_MAYBE_WITH_VIEW "V"
140
141/* from dp_auth_util.c */
142#define SSS_SERVER_INFO 0x80000000
143
144#define SSS_KRB5_INFO 0x40000000
145#define SSS_LDAP_INFO 0x20000000
146#define SSS_PROXY_INFO 0x10000000
147
148#define SSS_KRB5_INFO_TGT_LIFETIME (SSS_SERVER_INFO|SSS_KRB5_INFO|0x01)
149#define SSS_KRB5_INFO_UPN (SSS_SERVER_INFO|SSS_KRB5_INFO|0x02)
150
151bool dp_pack_pam_request(DBusMessage *msg, struct pam_data *pd);
152bool dp_unpack_pam_request(DBusMessage *msg, TALLOC_CTX *mem_ctx,
153 struct pam_data **new_pd, DBusError *dbus_error);
154
155bool dp_pack_pam_response(DBusMessage *msg, struct pam_data *pd);
156bool dp_unpack_pam_response(DBusMessage *msg, struct pam_data *pd,
157 DBusError *dbus_error);
158
159void dp_id_callback(DBusPendingCall *pending, void *ptr);
160
161/* Helpers */
162
163#define NULL_STRING { .string = NULL }
164#define NULL_BLOB { .blob = { NULL, 0 } }
165#define NULL_NUMBER { .number = 0 }
166#define BOOL_FALSE { .boolean = false }
167#define BOOL_TRUE { .boolean = true }
168
169enum dp_opt_type {
170 DP_OPT_STRING,
171 DP_OPT_BLOB,
172 DP_OPT_NUMBER,
173 DP_OPT_BOOL
174};
175
176struct dp_opt_blob {
177 uint8_t *data;
178 size_t length;
179};
180
181union dp_opt_value {
182 const char *cstring;
183 char *string;
184 struct dp_opt_blob blob;
185 int number;
186 bool boolean;
187};
188
189struct dp_option {
190 const char *opt_name;
191 enum dp_opt_type type;
192 union dp_opt_value def_val;
193 union dp_opt_value val;
194};
195
196#define DP_OPTION_TERMINATOR { NULL, 0, NULL_STRING, NULL_STRING }
197
198void dp_option_inherit_match(char **inherit_opt_list,
199 int option,
200 struct dp_option *parent_opts,
201 struct dp_option *subdom_opts);
202
203void dp_option_inherit(int option,
204 struct dp_option *parent_opts,
205 struct dp_option *subdom_opts);
206
207int dp_get_options(TALLOC_CTX *memctx,
208 struct confdb_ctx *cdb,
209 const char *conf_path,
210 struct dp_option *def_opts,
211 int num_opts,
212 struct dp_option **_opts);
213
214int dp_copy_options(TALLOC_CTX *memctx,
215 struct dp_option *src_opts,
216 int num_opts,
217 struct dp_option **_opts);
218
219int dp_copy_defaults(TALLOC_CTX *memctx,
220 struct dp_option *src_opts,
221 int num_opts,
222 struct dp_option **_opts);
223
224const char *_dp_opt_get_cstring(struct dp_option *opts,
225 int id, const char *location);
226char *_dp_opt_get_string(struct dp_option *opts,
227 int id, const char *location);
228struct dp_opt_blob _dp_opt_get_blob(struct dp_option *opts,
229 int id, const char *location);
230int _dp_opt_get_int(struct dp_option *opts,
231 int id, const char *location);
232bool _dp_opt_get_bool(struct dp_option *opts,
233 int id, const char *location);
234#define dp_opt_get_cstring(o, i) _dp_opt_get_cstring(o, i, __FUNCTION__)
235#define dp_opt_get_string(o, i) _dp_opt_get_string(o, i, __FUNCTION__)
236#define dp_opt_get_blob(o, i) _dp_opt_get_blob(o, i, __FUNCTION__)
237#define dp_opt_get_int(o, i) _dp_opt_get_int(o, i, __FUNCTION__)
238#define dp_opt_get_bool(o, i) _dp_opt_get_bool(o, i, __FUNCTION__)
239
240int _dp_opt_set_string(struct dp_option *opts, int id,
241 const char *s, const char *location);
242int _dp_opt_set_blob(struct dp_option *opts, int id,
243 struct dp_opt_blob b, const char *location);
244int _dp_opt_set_int(struct dp_option *opts, int id,
245 int i, const char *location);
246int _dp_opt_set_bool(struct dp_option *opts, int id,
247 bool b, const char *location);
248#define dp_opt_set_string(o, i, v) _dp_opt_set_string(o, i, v, __FUNCTION__)
249#define dp_opt_set_blob(o, i, v) _dp_opt_set_blob(o, i, v, __FUNCTION__)
250#define dp_opt_set_int(o, i, v) _dp_opt_set_int(o, i, v, __FUNCTION__)
251#define dp_opt_set_bool(o, i, v) _dp_opt_set_bool(o, i, v, __FUNCTION__)
252
253/* Generic Data Provider options */
254
255/* Resolver DP options */
256enum dp_res_opts {
257 DP_RES_OPT_FAMILY_ORDER,
258 DP_RES_OPT_RESOLVER_TIMEOUT,
259 DP_RES_OPT_RESOLVER_OP_TIMEOUT,
260 DP_RES_OPT_RESOLVER_SERVER_TIMEOUT,
261 DP_RES_OPT_RESOLVER_USE_SEARCH_LIST,
262 DP_RES_OPT_DNS_DOMAIN,
263 DP_RES_OPT_FAILOVER_PRIMARY_TIMEOUT,
264
265 DP_RES_OPTS /* attrs counter */
266};
267
268#endif /* __DATA_PROVIDER_ */