The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
rlm_winbind.c
Go to the documentation of this file.
1/*
2 * This program is is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or (at
5 * your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15 */
16
17/**
18 * $Id: 3992d7d7edaeb41b78556cc77873c1030c9dd0ca $
19 * @file rlm_winbind.c
20 * @brief Authenticates against Active Directory or Samba using winbind
21 *
22 * @author Matthew Newton (matthew@newtoncomputing.co.uk)
23 *
24 * @copyright 2016 The FreeRADIUS server project
25 * @copyright 2016 Matthew Newton (matthew@newtoncomputing.co.uk)
26 */
27RCSID("$Id: 3992d7d7edaeb41b78556cc77873c1030c9dd0ca $")
28
29#include <freeradius-devel/server/base.h>
30#include <freeradius-devel/server/module_rlm.h>
31#include <freeradius-devel/unlang/call_env.h>
32#include <freeradius-devel/unlang/xlat_func.h>
33#include <freeradius-devel/util/debug.h>
34
35#include "rlm_winbind.h"
36#include "auth_wbclient_pap.h"
37#include <grp.h>
38#include <wbclient.h>
39
40static const conf_parser_t group_config[] = {
41 { FR_CONF_OFFSET("add_domain", rlm_winbind_t, group_add_domain), .dflt = "yes" },
43};
44
49
50static const conf_parser_t module_config[] = {
51 { FR_CONF_POINTER("group", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) group_config },
54};
55
57
60 { .out = &dict_freeradius, .proto = "freeradius" },
61 { NULL }
62};
63
66
69 { .out = &attr_auth_type, .name = "Auth-Type", .type = FR_TYPE_UINT32, .dict = &dict_freeradius },
70 { .out = &attr_expr_bool_enum, .name = "Expr-Bool-Enum", .type = FR_TYPE_BOOL, .dict = &dict_freeradius },
71 { NULL }
72};
73
77
82
83/** Group comparison for Winbind-Group
84 *
85 * @param inst Instance of this module
86 * @param request The current request
87 * @param name Group name to be searched
88 * @param env Group check xlat call_env
89 *
90 * @return
91 * - 0 user is in group
92 * - 1 failure or user is not in group
93 */
94static bool winbind_check_group(rlm_winbind_t const *inst, request_t *request, char const *name,
96{
97 bool rcode = false;
98 winbind_ctx_t *wbctx;
99 struct wbcContext *wb_ctx;
100 wbcErr err;
101 uint32_t num_groups, i;
102 gid_t *wb_groups = NULL;
103
104 char const *domain = NULL;
105 size_t domain_len = 0;
106 char const *username;
107 char *username_buff = NULL;
108 size_t backslash = 0;
109
110 RINDENT();
111
112 /*
113 * Work out what username to check groups for, made up from
114 * either winbind_domain and either group_search_username or
115 * just User-Name.
116 */
117
118 /*
119 * Include the domain in the username?
120 */
121 if (inst->group_add_domain && env->domain.type == FR_TYPE_STRING){
122 domain = env->domain.vb_strvalue;
123 domain_len = env->domain.vb_length;
124 }
125
126 if (domain) {
127 username = username_buff = talloc_typed_asprintf(request, "%s\\%s", domain, env->username.vb_strvalue);
128 } else {
129 username = env->username.vb_strvalue;
130 RWDEBUG("Searching group with plain username, this will probably fail");
131 RWDEBUG("Ensure winbind domain is correctly set");
132 }
133
134 /*
135 * Get a libwbclient context
136 */
137 wbctx = winbind_slab_reserve(t->slab);
138 if (!wbctx) {
139 RERROR("Unable to get winbind context");
140 goto error;
141 }
142 wb_ctx = wbctx->ctx;
143
144 RDEBUG2("Trying to find user \"%s\" in group \"%s\"", username, name);
145
146 err = wbcCtxGetGroups(wb_ctx, username, &num_groups, &wb_groups);
147 switch (err) {
148 case WBC_ERR_SUCCESS:
149 if (!num_groups) {
150 RWDEBUG2("No groups returned");
151 goto finish;
152 }
153
154 RDEBUG2("Successfully retrieved user's groups");
155 break;
156
157 case WBC_ERR_WINBIND_NOT_AVAILABLE:
158 RERROR("Failed retrieving groups: Unable to contact winbindd"); /* Global error */
159 goto finish;
160
161 case WBC_ERR_DOMAIN_NOT_FOUND:
162 /* Yeah, weird. libwbclient returns this if the username is unknown */
163 REDEBUG("Failed retrieving groups: User or Domain not found");
164 goto finish;
165
166 case WBC_ERR_UNKNOWN_USER:
167 REDEBUG("Failed retrieving groups: User cannot be found");
168 goto finish;
169
170 default:
171 REDEBUG("Failed retrieving groups: %s", wbcErrorString(err));
172 goto finish;
173 }
174
175 /*
176 * See if any of the groups match
177 */
178
179 /*
180 * We try and find where the '\' is in the returned group, which saves
181 * looking for it each time. There seems to be no way to get a list of
182 * groups without the domain in them, but at least the backslash is
183 * always going to be in the same place.
184 *
185 * Maybe there should be an option to include the domain in the compared
186 * group name in case people have multiple domains?
187 */
188 if (domain_len > 0) backslash = domain_len - 1;
189
190 for (i = 0; i < num_groups; i++) {
191 struct group *group;
192 char *group_name;
193
194 /* Get the group name from the (fake winbind) gid */
195 err = wbcCtxGetgrgid(wb_ctx, wb_groups[i], &group);
196 if (err != WBC_ERR_SUCCESS) {
197 REDEBUG("Failed resolving GID %i: %s", wb_groups[i], wbcErrorString(err));
198 if (wb_groups[i] == UINT32_MAX) {
199 REDEBUG("GID appears to be winbind placeholder value, idmap likely failed");
200 }
201 continue;
202 }
203
204 RDEBUG3("Resolved GID %i to name \"%s\"", wb_groups[i], group->gr_name);
205
206 /* Find the backslash in the returned group name */
207 if ((backslash < strlen(group->gr_name)) && (group->gr_name[backslash] == '\\')) {
208 group_name = group->gr_name + backslash + 1;
209 } else if ((group_name = strchr(group->gr_name, '\\'))) {
210 group_name++;
211 backslash = group_name - (group->gr_name - 1);
212 } else {
213 group_name = group->gr_name;
214 }
215
216 /* See if the group matches */
217 RDEBUG3("Checking plain group name \"%s\"", group_name);
218 if (!strcasecmp(group_name, name)) {
219 RDEBUG2("Found matching group: %s", group_name);
220 rcode = true;
221 }
222 wbcFreeMemory(group);
223
224 /* Short-circuit to save unnecessary enumeration */
225 if (rcode) break;
226 }
227
228 if (!rcode) RWDEBUG2("No groups found that match");
229
230finish:
231 wbcFreeMemory(wb_groups);
232 winbind_slab_release(wbctx);
233
234error:
235 talloc_free(username_buff);
236 REXDENT();
237
238 return rcode;
239}
240
241
242/** Check if the user is a member of a particular winbind group
243 *
244@verbatim
245%winbind.group(<name>)
246@endverbatim
247 *
248 * @ingroup xlat_functions
249 */
251 xlat_ctx_t const *xctx,
252 request_t *request, fr_value_box_list_t *in)
253{
254 rlm_winbind_t const *inst = talloc_get_type_abort(xctx->mctx->mi->data, rlm_winbind_t);
255 winbind_group_xlat_call_env_t *env = talloc_get_type_abort(xctx->env_data, winbind_group_xlat_call_env_t);
256 rlm_winbind_thread_t *t = talloc_get_type_abort(xctx->mctx->thread, rlm_winbind_thread_t);
257 fr_value_box_t *arg = fr_value_box_list_head(in);
258 char const *p = arg->vb_strvalue;
259 fr_value_box_t *vb;
260
262
264 vb->vb_bool = winbind_check_group(inst, request, p, env, t);
266
267 return XLAT_ACTION_DONE;
268}
269
270
271/*
272 * Free winbind context
273 */
274static int _mod_ctx_free(winbind_ctx_t *wbctx)
275{
276 wbcCtxFree(wbctx->ctx);
277 return 0;
278}
279
280/*
281 * Create winbind context
282 */
283static int winbind_ctx_alloc(winbind_ctx_t *wbctx, UNUSED void *uctx)
284{
285 wbctx->ctx = wbcCtxCreate();
286 if (!wbctx->ctx) {
287 fr_strerror_printf("Unable to create winbind context");
288 return -1;
289 }
290 talloc_set_destructor(wbctx, _mod_ctx_free);
291 return 0;
292}
293
295 { .required = true, .type = FR_TYPE_STRING, .concat = true },
297};
298
299
300/** Instantiate this module
301 *
302 * @param[in] mctx data for this module
303 *
304 * @return
305 * - 0 instantiation succeeded
306 * - -1 instantiation failed
307 */
308static int mod_instantiate(module_inst_ctx_t const *mctx)
309{
310 rlm_winbind_t *inst = talloc_get_type_abort(mctx->mi->data, rlm_winbind_t);
311
312 inst->auth_type = fr_dict_enum_by_name(attr_auth_type, mctx->mi->name, -1);
313 if (!inst->auth_type) {
314 WARN("Failed to find 'authenticate %s {...}' section. Winbind authentication will likely not work",
315 mctx->mi->name);
316 }
317
318 return 0;
319}
320
321
322/** Authorize for libwbclient/winbind authentication
323 *
324 * Checks there is a password available so we can authenticate
325 * against winbind and, if so, sets Auth-Type to ourself.
326 *
327 * @param[out] p_result The result of the module call:
328 * - #RLM_MODULE_NOOP unable to use winbind authentication
329 * - #RLM_MODULE_OK Auth-Type has been set to winbind
330 * @param[in] mctx Module instance data.
331 * @param[in] request The current request.
332 */
333static unlang_action_t CC_HINT(nonnull) mod_authorize(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
334{
336 winbind_autz_call_env_t *env = talloc_get_type_abort(mctx->env_data, winbind_autz_call_env_t);
337 fr_pair_t *vp;
338
339 vp = fr_pair_find_by_da(&request->request_pairs, NULL, tmpl_attr_tail_da(env->password));
340 if (!vp) {
341 REDEBUG2("No %s found in the request; not doing winbind authentication.",
342 tmpl_attr_tail_da(env->password)->name);
344 }
345
346 if (!inst->auth_type) {
347 WARN("No 'authenticate %s {...}' section or 'Auth-Type = %s' set. Cannot setup Winbind authentication",
348 mctx->mi->name, mctx->mi->name);
350 }
351
353
355}
356
357
358/** Authenticate the user via libwbclient and winbind
359 *
360 * @param[out] p_result The result of the module call.
361 * @param[in] mctx Module instance data.
362 * @param[in] request The current request
363 */
364static unlang_action_t CC_HINT(nonnull) mod_authenticate(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
365{
366 winbind_auth_call_env_t *env = talloc_get_type_abort(mctx->env_data, winbind_auth_call_env_t);
367 rlm_winbind_thread_t *t = talloc_get_type_abort(mctx->thread, rlm_winbind_thread_t);
368
369 /*
370 * Make sure the supplied password isn't empty
371 */
372 if (env->password.vb_length == 0) {
373 REDEBUG("User-Password must not be empty");
375 }
376
377 /*
378 * Log the password
379 */
380 if (RDEBUG_ENABLED3) {
381 RDEBUG("Login attempt with password \"%pV\"", &env->password);
382 } else {
383 RDEBUG2("Login attempt with password");
384 }
385
386 /*
387 * Authenticate and return OK if successful. No need for
388 * many debug outputs or errors as the auth function is
389 * chatty enough.
390 */
391 if (do_auth_wbclient_pap(request, env, t) == 0) {
392 RDEBUG2("User authenticated successfully using winbind");
394 }
395
397}
398
407
408static int domain_call_env_parse(TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci,
409 UNUSED call_env_ctx_t const *cec, UNUSED call_env_parser_t const *rule)
410{
411 CONF_PAIR const *to_parse = cf_item_to_pair(ci);
412 tmpl_t *parsed_tmpl = NULL;
413 struct wbcInterfaceDetails *wb_info = NULL;
414
415 if (strlen(cf_pair_value(to_parse)) > 0) {
416 if (tmpl_afrom_substr(ctx, &parsed_tmpl,
417 &FR_SBUFF_IN(cf_pair_value(to_parse), talloc_array_length(cf_pair_value(to_parse)) - 1),
418 cf_pair_value_quote(to_parse),
419 NULL, t_rules) < 0) return -1;
420 } else {
421 /*
422 * If the domain has not been specified, try and find
423 * out what it is from winbind.
424 */
425 wbcErr err;
426 struct wbcContext *wb_ctx;
427
428 cf_log_warn(ci, "winbind domain unspecified; trying to get it from winbind");
429
430 wb_ctx = wbcCtxCreate();
431 if (!wb_ctx) {
432 /* this should be very unusual */
433 cf_log_err(ci, "Unable to get libwbclient context, cannot get domain");
434 goto no_domain;
435 }
436
437 err = wbcCtxInterfaceDetails(wb_ctx, &wb_info);
438 wbcCtxFree(wb_ctx);
439
440 if (err != WBC_ERR_SUCCESS) {
441 cf_log_err(ci, "libwbclient returned wbcErr code %d; unable to get domain name.", err);
442 cf_log_err(ci, "Is winbind running and does the winbind_privileged socket have");
443 cf_log_err(ci, "the correct permissions?");
444 goto no_domain;
445 }
446
447 if (!wb_info->netbios_domain) {
448 cf_log_err(ci, "winbind returned blank domain name");
449 goto no_domain;
450 }
451
452 tmpl_afrom_substr(ctx, &parsed_tmpl,
453 &FR_SBUFF_IN(wb_info->netbios_domain, strlen(wb_info->netbios_domain)),
454 T_SINGLE_QUOTED_STRING, NULL, t_rules);
455 if (!parsed_tmpl) {
456 cf_log_perr(ci, "Bad domain");
457 wbcFreeMemory(wb_info);
458 return -1;
459 }
460
461 cf_log_info(ci, "Using winbind_domain '%s'", parsed_tmpl->name);
462
463 no_domain:
464 wbcFreeMemory(wb_info);
465 }
466
467 *(void **)out = parsed_tmpl;
468 return parsed_tmpl ? 0 : -1;
469}
470
482
496
497/** Bootstrap this module
498 *
499 * @param[in] mctx data for this module
500 *
501 * @return
502 * - 0 success
503 * - -1 failure
504 */
505static int mod_bootstrap(module_inst_ctx_t const *mctx)
506{
507 CONF_SECTION *conf = mctx->mi->conf;
508 xlat_t *xlat;
509
510 /*
511 * Define the %winbind.group(name) xlat. The register
512 * function automatically adds the module instance name
513 * as a prefix.
514 */
515 xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "group", winbind_group_xlat, FR_TYPE_BOOL);
516 if (!xlat) {
517 cf_log_err(conf, "Failed registering group expansion");
518 return -1;
519 }
520
523
524 return 0;
525}
526
528{
529 rlm_winbind_t const *inst = talloc_get_type_abort(mctx->mi->data, rlm_winbind_t);
530 rlm_winbind_thread_t *t = talloc_get_type_abort(mctx->thread, rlm_winbind_thread_t);
531
532 t->inst = inst;
533 if (!(t->slab = winbind_slab_list_alloc(t, mctx->el, &inst->reuse, winbind_ctx_alloc, NULL, NULL, false, false))) {
534 ERROR("Connection handle pool instantiation failed");
535 return -1;
536 }
537
538 return 0;
539}
540
542{
543 rlm_winbind_thread_t *t = talloc_get_type_abort(mctx->thread, rlm_winbind_thread_t);
544 talloc_free(t->slab);
545 return 0;
546}
547
548/*
549 * The module name should be the only globally exported symbol.
550 * That is, everything else should be 'static'.
551 *
552 * If the module needs to temporarily modify it's instantiation
553 * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE.
554 * The server will then take care of ensuring that the module
555 * is single-threaded.
556 */
559 .common = {
560 .magic = MODULE_MAGIC_INIT,
561 .name = "winbind",
562 .inst_size = sizeof(rlm_winbind_t),
565 .bootstrap = mod_bootstrap,
566 .thread_inst_size = sizeof(rlm_winbind_thread_t),
567 .thread_instantiate = mod_thread_instantiate,
568 .thread_detach = mod_thread_detach,
569 },
570 .method_group = {
571 .bindings = (module_method_binding_t[]){
572 { .section = SECTION_NAME("authenticate", CF_IDENT_ANY), .method = mod_authenticate, .method_env = &winbind_auth_method_env },
573 { .section = SECTION_NAME("recv", CF_IDENT_ANY), .method = mod_authorize, .method_env = &winbind_autz_method_env },
575 }
576 }
577};
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition action.h:35
int do_auth_wbclient_pap(request_t *request, winbind_auth_call_env_t *env, rlm_winbind_thread_t *t)
PAP authentication direct to winbind via Samba's libwbclient library.
#define RCSID(id)
Definition build.h:483
#define UNUSED
Definition build.h:315
#define CALL_ENV_TERMINATOR
Definition call_env.h:231
#define FR_CALL_ENV_METHOD_OUT(_inst)
Helper macro for populating the size/type fields of a call_env_method_t from the output structure typ...
Definition call_env.h:235
call_env_parser_t const * env
Parsing rules for call method env.
Definition call_env.h:242
#define FR_CALL_ENV_SUBSECTION(_name, _name2, _flags, _subcs)
Specify a call_env_parser_t which defines a nested subsection.
Definition call_env.h:397
@ CALL_ENV_FLAG_ATTRIBUTE
Tmpl must contain an attribute reference.
Definition call_env.h:86
@ CALL_ENV_FLAG_PARSE_ONLY
The result of parsing will not be evaluated at runtime.
Definition call_env.h:85
@ CALL_ENV_FLAG_SECRET
The value is a secret, and should not be logged.
Definition call_env.h:91
@ CALL_ENV_FLAG_NONE
Definition call_env.h:74
@ CALL_ENV_FLAG_REQUIRED
Associated conf pair or section is required.
Definition call_env.h:75
#define FR_CALL_ENV_OFFSET(_name, _cast_type, _flags, _struct, _field)
Specify a call_env_parser_t which writes out runtime results to the specified field.
Definition call_env.h:335
#define FR_CALL_ENV_PARSE_ONLY_OFFSET(_name, _cast_type, _flags, _struct, _parse_field)
Specify a call_env_parser_t which writes out the result of the parsing phase to the field specified.
Definition call_env.h:384
Per method call config.
Definition call_env.h:175
#define CONF_PARSER_TERMINATOR
Definition cf_parse.h:642
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition cf_parse.h:268
#define FR_CONF_POINTER(_name, _type, _flags, _res_p)
conf_parser_t which parses a single CONF_PAIR producing a single global result
Definition cf_parse.h:323
#define FR_CONF_OFFSET_SUBSECTION(_name, _flags, _struct, _field, _subcs)
conf_parser_t which populates a sub-struct using a CONF_SECTION
Definition cf_parse.h:297
@ CONF_FLAG_SUBSECTION
Instead of putting the information into a configuration structure, the configuration file routines MA...
Definition cf_parse.h:412
Defines a CONF_PAIR to C data type mapping.
Definition cf_parse.h:579
Common header for all CONF_* types.
Definition cf_priv.h:49
Configuration AVP similar to a fr_pair_t.
Definition cf_priv.h:70
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:101
fr_token_t cf_pair_value_quote(CONF_PAIR const *pair)
Return the value (rhs) quoting of a pair.
Definition cf_util.c:1638
CONF_PAIR * cf_item_to_pair(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_PAIR.
Definition cf_util.c:664
char const * cf_pair_value(CONF_PAIR const *pair)
Return the value of a CONF_PAIR.
Definition cf_util.c:1594
#define cf_log_err(_cf, _fmt,...)
Definition cf_util.h:289
#define cf_log_info(_cf, _fmt,...)
Definition cf_util.h:291
#define cf_log_perr(_cf, _fmt,...)
Definition cf_util.h:296
#define cf_log_warn(_cf, _fmt,...)
Definition cf_util.h:290
#define CF_IDENT_ANY
Definition cf_util.h:78
static int fr_dcursor_append(fr_dcursor_t *cursor, void *v)
Insert a single item at the end of the list.
Definition dcursor.h:406
#define MEM(x)
Definition debug.h:36
#define ERROR(fmt,...)
Definition dhcpclient.c:41
static fr_slen_t err
Definition dict.h:824
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
Definition dict.h:268
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
Definition dict.h:281
fr_dict_enum_value_t * fr_dict_enum_by_name(fr_dict_attr_t const *da, char const *name, ssize_t len)
Definition dict_util.c:3395
static fr_slen_t in
Definition dict.h:824
Specifies an attribute which must be present for the module to function.
Definition dict.h:267
Specifies a dictionary which must be loaded/loadable for the module to function.
Definition dict.h:280
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition dl_module.h:63
static xlat_action_t winbind_group_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in)
Check if the user is a member of a particular winbind group.
#define REXDENT()
Exdent (unindent) R* messages by one level.
Definition log.h:443
#define RWDEBUG(fmt,...)
Definition log.h:361
#define RDEBUG_ENABLED3
True if request debug level 1-3 messages are enabled.
Definition log.h:335
#define RDEBUG3(fmt,...)
Definition log.h:343
#define RWDEBUG2(fmt,...)
Definition log.h:362
#define RERROR(fmt,...)
Definition log.h:298
#define REDEBUG2(fmt,...)
Definition log.h:372
#define RINDENT()
Indent R* messages by one level.
Definition log.h:430
talloc_free(reap)
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_BOOL
A truth value.
unsigned int uint32_t
#define fr_skip_whitespace(_p)
Skip whitespace ('\t', '\n', '\v', '\f', '\r', ' ')
Definition misc.h:59
int strcasecmp(char *s1, char *s2)
Definition missing.c:66
void * env_data
Per call environment data.
Definition module_ctx.h:44
module_instance_t const * mi
Instance of the module being instantiated.
Definition module_ctx.h:42
void * thread
Thread specific instance data.
Definition module_ctx.h:43
fr_event_list_t * el
Event list to register any IO handlers and timers against.
Definition module_ctx.h:68
void * thread
Thread instance data.
Definition module_ctx.h:67
module_instance_t const * mi
Instance of the module being instantiated.
Definition module_ctx.h:64
module_instance_t * mi
Instance of the module being instantiated.
Definition module_ctx.h:51
Temporary structure to hold arguments for module calls.
Definition module_ctx.h:41
Temporary structure to hold arguments for instantiation calls.
Definition module_ctx.h:50
Temporary structure to hold arguments for thread_instantiation calls.
Definition module_ctx.h:63
xlat_t * module_rlm_xlat_register(TALLOC_CTX *ctx, module_inst_ctx_t const *mctx, char const *name, xlat_func_t func, fr_type_t return_type)
Definition module_rlm.c:257
bool module_rlm_section_type_set(request_t *request, fr_dict_attr_t const *type_da, fr_dict_enum_value_t const *enumv)
Set the next section type if it's not already set.
Definition module_rlm.c:427
module_t common
Common fields presented by all modules.
Definition module_rlm.h:39
fr_pair_t * fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find the first pair with a matching da.
Definition pair.c:693
static const conf_parser_t config[]
Definition base.c:183
#define REDEBUG(fmt,...)
Definition radclient.h:52
#define RDEBUG2(fmt,...)
Definition radclient.h:54
#define RDEBUG(fmt,...)
Definition radclient.h:53
#define WARN(fmt,...)
Definition radclient.h:47
static rs_t * conf
Definition radsniff.c:53
#define RETURN_MODULE_REJECT
Definition rcode.h:55
#define RETURN_MODULE_NOOP
Definition rcode.h:62
#define RETURN_MODULE_INVALID
Definition rcode.h:59
#define RETURN_MODULE_OK
Definition rcode.h:57
rlm_rcode_t
Return codes indicating the result of the module call.
Definition rcode.h:40
static char const * name
static int instantiate(module_inst_ctx_t const *mctx)
Definition rlm_rest.c:1310
username
static int domain_call_env_parse(TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, UNUSED call_env_ctx_t const *cec, UNUSED call_env_parser_t const *rule)
static const call_env_method_t winbind_autz_method_env
static xlat_arg_parser_t const winbind_group_xlat_arg[]
static int winbind_ctx_alloc(winbind_ctx_t *wbctx, UNUSED void *uctx)
fr_dict_attr_autoload_t rlm_winbind_dict_attr[]
Definition rlm_winbind.c:68
static const call_env_method_t winbind_auth_method_env
static const conf_parser_t group_config[]
Definition rlm_winbind.c:40
static fr_dict_t const * dict_freeradius
Definition rlm_winbind.c:56
static fr_dict_attr_t const * attr_expr_bool_enum
Definition rlm_winbind.c:65
static unlang_action_t mod_authenticate(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Authenticate the user via libwbclient and winbind.
static int mod_bootstrap(module_inst_ctx_t const *mctx)
Bootstrap this module.
static fr_dict_attr_t const * attr_auth_type
Definition rlm_winbind.c:64
static conf_parser_t reuse_winbind_config[]
Definition rlm_winbind.c:45
static unlang_action_t mod_authorize(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Authorize for libwbclient/winbind authentication.
static int _mod_ctx_free(winbind_ctx_t *wbctx)
static const call_env_method_t winbind_group_xlat_call_env
static int mod_thread_instantiate(module_thread_inst_ctx_t const *mctx)
module_rlm_t rlm_winbind
static bool winbind_check_group(rlm_winbind_t const *inst, request_t *request, char const *name, winbind_group_xlat_call_env_t *env, rlm_winbind_thread_t *t)
Group comparison for Winbind-Group.
Definition rlm_winbind.c:94
static const conf_parser_t module_config[]
Definition rlm_winbind.c:50
fr_dict_autoload_t rlm_winbind_dict[]
Definition rlm_winbind.c:59
static int mod_thread_detach(module_thread_inst_ctx_t const *mctx)
static int mod_instantiate(module_inst_ctx_t const *mctx)
Instantiate this module.
fr_value_box_t password
Definition rlm_winbind.h:34
rlm_winbind_t const * inst
Instance of rlm_winbind.
Definition rlm_winbind.h:27
winbind_slab_list_t * slab
Slab list for winbind handles.
Definition rlm_winbind.h:28
struct wbcContext * ctx
Definition rlm_winbind.h:20
#define FR_SBUFF_IN(_start, _len_or_end)
#define SECTION_NAME(_name1, _name2)
Define a section name consisting of a verb and a noun.
Definition section.h:40
char const * name
Instance name e.g. user_database.
Definition module.h:335
CONF_SECTION * conf
Module's instance configuration.
Definition module.h:329
size_t inst_size
Size of the module's instance data.
Definition module.h:203
void * data
Module's instance data.
Definition module.h:271
void * boot
Data allocated during the boostrap phase.
Definition module.h:274
#define MODULE_BINDING_TERMINATOR
Terminate a module binding list.
Definition module.h:151
Named methods exported by a module.
Definition module.h:173
ssize_t tmpl_afrom_substr(TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t *in, fr_token_t quote, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules))
Convert an arbitrary string into a tmpl_t.
static fr_dict_attr_t const * tmpl_attr_tail_da(tmpl_t const *vpt)
Return the last attribute reference da.
Definition tmpl.h:812
Optional arguments passed to vp_tmpl functions.
Definition tmpl.h:341
#define FR_SLAB_CONFIG_CONF_PARSER
conf_parser_t entries to populate user configurable slab values
Definition slab.h:35
eap_aka_sim_process_conf_t * inst
fr_pair_t * vp
Stores an attribute, a value and various bits of other data.
Definition pair.h:68
char * talloc_typed_asprintf(TALLOC_CTX *ctx, char const *fmt,...)
Call talloc vasprintf, setting the type on the new chunk correctly.
Definition talloc.c:492
#define talloc_get_type_abort_const
Definition talloc.h:282
@ T_SINGLE_QUOTED_STRING
Definition token.h:122
@ T_BARE_WORD
Definition token.h:120
bool required
Argument must be present, and non-empty.
Definition xlat.h:148
#define XLAT_ARG_PARSER_TERMINATOR
Definition xlat.h:168
xlat_action_t
Definition xlat.h:37
@ XLAT_ACTION_DONE
We're done evaluating this level of nesting.
Definition xlat.h:43
Definition for a single argument consumend by an xlat function.
Definition xlat.h:147
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
Definition strerror.h:64
#define fr_value_box_alloc(_ctx, _type, _enumv)
Allocate a value box of a specific type.
Definition value.h:621
int nonnull(2, 5))
static size_t char ** out
Definition value.h:997
void * env_data
Expanded call env data.
Definition xlat_ctx.h:53
module_ctx_t const * mctx
Synthesised module calling ctx.
Definition xlat_ctx.h:52
An xlat calling ctx.
Definition xlat_ctx.h:49
int xlat_func_args_set(xlat_t *x, xlat_arg_parser_t const args[])
Register the arguments of an xlat.
Definition xlat_func.c:365
void xlat_func_call_env_set(xlat_t *x, call_env_method_t const *env_method)
Register call environment of an xlat.
Definition xlat_func.c:392