The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
sasl.c
Go to the documentation of this file.
1/*
2 * This program 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: 59e1c2b83fda25f4b7304eff616286665844c077 $
19 * @file lib/ldap/bind.c
20 * @brief Asynchronous SASL bind functions for LDAP.
21 *
22 * @copyright 2017 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
23 */
24RCSID("$Id: 59e1c2b83fda25f4b7304eff616286665844c077 $")
25
27
28#include <freeradius-devel/ldap/base.h>
29#include <freeradius-devel/util/debug.h>
30#include <sasl/sasl.h>
31
32static void _ldap_sasl_bind_io_write(fr_event_list_t *el, int fd, UNUSED int flags, void *uctx);
33
34/** Error reading from or writing to the file descriptor
35 *
36 * @param[in] el the event occurred in.
37 * @param[in] fd the event occurred on.
38 * @param[in] flags from kevent.
39 * @param[in] fd_errno The error that occurred.
40 * @param[in] uctx Connection config and handle.
41 */
43 UNUSED int flags, UNUSED int fd_errno, void *uctx)
44{
45 fr_ldap_sasl_ctx_t *sasl_ctx = talloc_get_type_abort(uctx, fr_ldap_sasl_ctx_t);
46 fr_ldap_connection_t *c = sasl_ctx->c;
47
48 talloc_free(sasl_ctx);
49 fr_ldap_state_error(c); /* Restart the connection state machine */
50}
51
52/** Callback for fr_ldap_sasl_interactive_bind
53 *
54 * @param[in] handle used for the SASL bind.
55 * @param[in] flags data as provided to fr_ldap_sasl_interactive_bind.
56 * @param[in] uctx Our context data, containing the identity, password, realm and various other things.
57 * @param[in] sasl_callbacks Array of challenges to provide responses for.
58 * @return SASL_OK.
59 */
60static int _sasl_interact(UNUSED LDAP *handle, UNUSED unsigned flags, void *uctx, void *sasl_callbacks)
61{
62 fr_ldap_sasl_ctx_t *sasl_ctx = talloc_get_type_abort(uctx, fr_ldap_sasl_ctx_t);
63 sasl_interact_t *cb = sasl_callbacks;
64 sasl_interact_t *cb_p;
65
66 for (cb_p = cb; cb_p->id != SASL_CB_LIST_END; cb_p++) {
67 DEBUG3("SASL challenge : %s", cb_p->challenge);
68 DEBUG3("SASL prompt : %s", cb_p->prompt);
69
70 switch (cb_p->id) {
71 case SASL_CB_AUTHNAME:
72 /*
73 * For mechs like -Y EXTERNAL we don't have
74 * any information to provide to SASL.
75 */
76 if (!sasl_ctx->identity) {
77 null_result:
78 cb_p->result = NULL;
79 cb_p->len = 0;
80 break;
81 }
82 cb_p->result = sasl_ctx->identity;
83 cb_p->len = strlen(sasl_ctx->identity);
84 break;
85
86 case SASL_CB_PASS:
87 if (!sasl_ctx->password) goto null_result;
88
89 cb_p->result = sasl_ctx->password;
90 cb_p->len = strlen(sasl_ctx->password);
91 break;
92
93 case SASL_CB_USER:
94 if (!sasl_ctx->proxy && !sasl_ctx->identity) goto null_result;
95
96 cb_p->result = sasl_ctx->proxy ? sasl_ctx->proxy : sasl_ctx->identity;
97 cb_p->len = sasl_ctx->proxy ? strlen(sasl_ctx->proxy) : strlen(sasl_ctx->identity);
98 break;
99
100 case SASL_CB_GETREALM:
101 if (!sasl_ctx->realm) goto null_result;
102
103 cb_p->result = sasl_ctx->realm;
104 cb_p->len = strlen(sasl_ctx->realm);
105 break;
106
107 default:
108 break;
109 }
110 DEBUG3("SASL result : %s", cb_p->result ? (char const *)cb_p->result : "");
111 }
112 return SASL_OK;
113}
114
115/** Parse a sasl bind response from a server
116 *
117 * @param[in] el the event occurred in.
118 * @param[in] fd the event occurred on.
119 * @param[in] flags from kevent.
120 * @param[in] uctx bind_ctx containing credentials, and connection config/handle.
121 */
122static void _ldap_sasl_bind_io_read(fr_event_list_t *el, int fd, UNUSED int flags, void *uctx)
123{
124 fr_ldap_sasl_ctx_t *sasl_ctx = talloc_get_type_abort(uctx, fr_ldap_sasl_ctx_t);
125 fr_ldap_connection_t *c = sasl_ctx->c;
126 fr_ldap_rcode_t status;
127
128 /*
129 * Free the old result (if there is one)
130 */
131 if (sasl_ctx->result) {
132 ldap_msgfree(sasl_ctx->result);
133 sasl_ctx->result = NULL;
134 }
135
136 /*
137 * If LDAP parse result indicates there was an error
138 * then we're done.
139 */
140 status = fr_ldap_result(&sasl_ctx->result, NULL, c, sasl_ctx->msgid, LDAP_MSG_ALL,
141 sasl_ctx->identity, fr_time_delta_wrap(0));
142 switch (status) {
144 return;
145
148 {
149 struct berval *srv_cred;
150 int ret;
151
152 ret = ldap_parse_sasl_bind_result(c->handle, sasl_ctx->result, &srv_cred, 0);
153 if (ret != LDAP_SUCCESS) {
154 ERROR("SASL decode failed (bind failed): %s", ldap_err2string(ret));
155 error:
156 talloc_free(sasl_ctx);
157 fr_ldap_state_error(c); /* Restart the connection state machine */
158 return;
159 }
160
161 /*
162 * Observed as NULL when doing EXTERNAL
163 * authentication.
164 */
165 if (srv_cred) {
166 DEBUG3("SASL response : %pV",
167 fr_box_strvalue_len(srv_cred->bv_val, srv_cred->bv_len));
168 ber_bvfree(srv_cred);
169 }
170
171 /*
172 * If we need to continue, wait until the
173 * socket is writable, and then call
174 * ldap_sasl_interactive_bind again.
175 *
176 * sasl_ctx->rmech may be NULL if there's
177 * nothing else to do.
178 */
179 if (sasl_ctx->rmech) DEBUG3("Continuing SASL mech %s...", sasl_ctx->rmech);
180
181 ret = fr_event_fd_insert(sasl_ctx, NULL, el, fd,
182 NULL,
183 _ldap_sasl_bind_io_write, /* Need to write more SASL stuff */
185 sasl_ctx);
186 if (!fr_cond_assert(ret == 0)) goto error;
187 }
188 return;
189
190 default:
191 PERROR("SASL bind failed");
192 goto error;
193 }
194}
195
196/** Progress an interactive SASL bind
197 *
198 * @param[in] el the event occurred in.
199 * @param[in] fd the event occurred on.
200 * @param[in] flags from kevent.
201 * @param[in] uctx Connection config and handle.
202 */
203static void _ldap_sasl_bind_io_write(fr_event_list_t *el, int fd, UNUSED int flags, void *uctx)
204{
205 fr_ldap_sasl_ctx_t *sasl_ctx = talloc_get_type_abort(uctx, fr_ldap_sasl_ctx_t);
206 fr_ldap_connection_t *c = sasl_ctx->c;
207
208 int ret = 0;
209
210 LDAPControl *our_serverctrls[LDAP_MAX_CONTROLS];
211 LDAPControl *our_clientctrls[LDAP_MAX_CONTROLS];
212
213 fr_ldap_control_merge(our_serverctrls, our_clientctrls,
214 NUM_ELEMENTS(our_serverctrls),
215 NUM_ELEMENTS(our_clientctrls),
216 c, sasl_ctx->serverctrls, sasl_ctx->clientctrls);
217
218 DEBUG2("%s SASL mech(s): %s", (sasl_ctx->result == NULL ? "Starting" : "Continuing"), sasl_ctx->mechs);
219
220 ret = ldap_sasl_interactive_bind(c->handle, NULL, sasl_ctx->mechs,
221 our_serverctrls, our_clientctrls,
222 LDAP_SASL_AUTOMATIC,
223 _sasl_interact, sasl_ctx, sasl_ctx->result,
224 &sasl_ctx->rmech, &sasl_ctx->msgid);
225 switch (ret) {
226 /*
227 * If the handle was not connected, this operation
228 * can return either LDAP_X_CONNECTING or
229 * LDAP_SASL_BIND_IN_PROGRESS
230 * depending on how fast the connection came up
231 * and whether it was connectionless.
232 */
233 case LDAP_X_CONNECTING:
234 ret = ldap_get_option(c->handle, LDAP_OPT_DESC, &fd);
235 if (!fr_cond_assert(ret == LDAP_OPT_SUCCESS)) {
236 error:
237 talloc_free(sasl_ctx);
238 fr_ldap_state_error(c); /* Restart the connection state machine */
239 return;
240 }
241
242 ret = fr_event_fd_insert(sasl_ctx, NULL, el, fd,
243 NULL,
244 _ldap_sasl_bind_io_write, /* We'll be called again when the conn is open */
246 sasl_ctx);
247 if (!fr_cond_assert(ret == 0)) goto error;
248 break;
249
250 /*
251 * Want to read more SASL stuff...
252 */
253 case LDAP_SASL_BIND_IN_PROGRESS:
254 if (fd < 0) {
255 ret = ldap_get_option(c->handle, LDAP_OPT_DESC, &fd);
256 if ((ret != LDAP_OPT_SUCCESS) || (fd < 0)) goto error;
257 }
258 c->fd = fd;
259
260 /*
261 * libldap, up to at least 2.7.2, switches the socket to blocking mode
262 * while sending the first request after an async connect.
263 */
264 if (fr_nonblock(fd) < 0) {
265 PERROR("Failed setting LDAP connection non-blocking");
266 goto error;
267 }
268
269 ret = fr_event_fd_insert(sasl_ctx, NULL, el, fd,
271 NULL,
273 sasl_ctx);
274 if (!fr_cond_assert(ret == 0)) goto error;
275 break;
276
277 /*
278 * We're done, woohoo!
279 */
280 case LDAP_SUCCESS:
281 DEBUG2("SASL bind as \"%s\" to \"%s\" successful",
282 sasl_ctx->identity ? sasl_ctx->identity : "(anonymous)", c->config->server);
283 talloc_free(sasl_ctx);
285 break;
286
287 default:
288 ERROR("ldap sasl bind failed: %s", ldap_err2string(ret));
289 goto error;
290 }
291}
292
293/** Ensure any outstanding messages are freed
294 *
295 * @param[in] sasl_ctx to free.
296 * @return 0;
297 */
299{
300 if (sasl_ctx->result) ldap_msgfree(sasl_ctx->result);
301
302 return 0;
303}
304
305/** Install I/O handlers for the bind operation
306 *
307 * @param[in] c connection to StartTLS on.
308 * @param[in] mechs Space delimited list of sasl mechs to try.
309 * @param[in] identity SASL identity to bind with.
310 * @param[in] password Password credential to pass to SASL.
311 * @param[in] proxy identity. May be NULL.
312 * @param[in] realm SASL realm.
313 * @param[in] serverctrls Extra controls to pass to the server.
314 * @param[in] clientctrls Extra controls to pass to libldap.
315 * @return
316 * - 0 on success.
317 * - -1 on failure.
318 */
320 char const *mechs,
321 char const *identity,
322 char const *password,
323 char const *proxy,
324 char const *realm,
325 LDAPControl **serverctrls, LDAPControl **clientctrls)
326{
327 int fd = -1;
328 fr_ldap_sasl_ctx_t *sasl_ctx;
330
331 DEBUG2("Starting SASL bind operation");
332
333 MEM(sasl_ctx = talloc_zero(c, fr_ldap_sasl_ctx_t));
334 talloc_set_destructor(sasl_ctx, _sasl_ctx_free);
335
336 sasl_ctx->c = c;
337 sasl_ctx->mechs = mechs;
338 sasl_ctx->identity = identity;
339 sasl_ctx->password = password;
340 sasl_ctx->proxy = proxy;
341 sasl_ctx->realm = realm;
342 sasl_ctx->serverctrls = serverctrls;
343 sasl_ctx->clientctrls = clientctrls;
344
345 el = c->conn->el;
346
347 /*
348 * ldap_get_option can return LDAP_SUCCESS even if the fd is not yet available
349 * - hence the test for fd >= 0
350 */
351 if ((ldap_get_option(c->handle, LDAP_OPT_DESC, &fd) == LDAP_SUCCESS) && (fd >= 0)){
352 int ret;
353
354 ret = fr_event_fd_insert(sasl_ctx, NULL, el, fd,
355 NULL,
358 sasl_ctx);
359 if (!fr_cond_assert(ret == 0)) {
360 talloc_free(sasl_ctx);
361 return -1;
362 }
363 } else {
364 _ldap_sasl_bind_io_write(el, -1, 0, sasl_ctx);
365 }
366
367 return 0;
368}
369
370/** Send a SASL LDAP auth bind
371 *
372 * Shares the same callback as SASL admin binds
373 *
374 * @param[in] sasl_ctx containing SASL parameters / state for the bind.
375 * @param[out] msgid where to write the LDAP message ID.
376 * @param[in] ldap_conn on which the message should be sent.
377 */
379 fr_ldap_connection_t *ldap_conn)
380{
381 return ldap_sasl_interactive_bind(ldap_conn->handle, NULL, sasl_ctx->mechs,
382 NULL, NULL, LDAP_SASL_AUTOMATIC,
383 _sasl_interact, sasl_ctx, sasl_ctx->result,
384 &sasl_ctx->rmech, msgid);
385}
386
387/** Yield interpreter after enqueueing sasl auth bind
388 *
389 */
395
396/** Signal an outstanding SASL LDAP bind to cancel
397 *
398 * @param[in] request being processed. Unused.
399 * @param[in] action Signal to handle.
400 * @param[in] uctx bind auth ctx.
401 */
403{
404 fr_ldap_bind_auth_ctx_t *bind_auth_ctx = talloc_get_type_abort(uctx, fr_ldap_bind_auth_ctx_t);
405
406 RWARN("Cancelling SASL bind auth");
407 if (bind_auth_ctx->msgid > 0) fr_rb_remove(NULL, bind_auth_ctx->thread->binds, bind_auth_ctx);
408 trunk_request_signal_cancel(bind_auth_ctx->treq);
409}
410
411/** Handle the return code from parsed LDAP results to set the module rcode
412 *
413 * @param[out] p_result Where to write return code.
414 * @param[in] request being processed.
415 * @param[in] uctx bind auth ctx.
416 * @return unlang action.
417 */
419{
420 fr_ldap_bind_auth_ctx_t *bind_auth_ctx = talloc_get_type_abort(uctx, fr_ldap_bind_auth_ctx_t);
421 fr_ldap_sasl_ctx_t *sasl_ctx = bind_auth_ctx->sasl_ctx;
422 fr_ldap_rcode_t ret = bind_auth_ctx->ret;
423 fr_ldap_connection_t *ldap_conn = NULL;
424
425 switch (bind_auth_ctx->ret) {
427 RDEBUG2("Bind as user \"%s\" was successful", sasl_ctx->identity);
428 break;
429
431 RDEBUG2("Bind as user \"%s\" not permitted", sasl_ctx->identity);
432 break;
433
434 case LDAP_PROC_REJECT:
435 RDEBUG2("Bind as user \"%s\" rejected", sasl_ctx->identity);
436 break;
437
439 if (trunk_request_requeue(bind_auth_ctx->treq) != TRUNK_ENQUEUE_OK) {
440 ret = LDAP_PROC_ERROR;
441 break;
442 }
443
444 /*
445 * Once the next SASL exchange has completed repeat this function to
446 * process the results
447 */
449 /*
450 * Not strictly an LDAP error but if this happens we will want to reset
451 * the connection to get a known state.
452 */
453 ret = LDAP_PROC_ERROR;
454 break;
455 }
456 return UNLANG_ACTION_YIELD;
457
458 default:
459 break;
460 }
461
462 if (bind_auth_ctx->treq) {
463 if (bind_auth_ctx->treq->tconn) ldap_conn = talloc_get_type_abort(bind_auth_ctx->treq->tconn->conn->h,
465 /*
466 * Will free bind_auth_ctx
467 */
468 trunk_request_signal_complete(bind_auth_ctx->treq);
469 } else {
470 /*
471 * If there is no trunk request, the request failed, and we need to free the ctx
472 */
473 talloc_free(bind_auth_ctx);
474 }
475
476 switch (ret) {
479
482
483 case LDAP_PROC_REJECT:
485
486 case LDAP_PROC_BAD_DN:
488
491
492 default:
493 if (ldap_conn) {
494 RPERROR("LDAP connection returned an error - restarting the connection");
495 fr_ldap_state_error(ldap_conn);
496 }
497 return UNLANG_ACTION_FAIL;
498 }
499}
500
501/** Initiate an async SASL LDAP bind for authentication
502 *
503 * @param[out] p_result Where to write the result of the bind.
504 * @param[in] request this bind relates to.
505 * @param[in] thread whose connection the bind should be performed on.
506 * @param[in] mechs SASL mechanisms to use.
507 * @param[in] identity Identity to bind with.
508 * @param[in] password Password to bind with.
509 * @param[in] proxy Identity to proxy.
510 * @param[in] realm SASL realm if applicable.
511 * @return
512 * - 0 on success.
513 * - -1 on failure.
514*/
516 request_t *request, fr_ldap_thread_t *thread, char const *mechs,
517 char const *identity, char const *password, char const *proxy, char const *realm)
518{
519 fr_ldap_bind_auth_ctx_t *bind_auth_ctx;
520 trunk_request_t *treq;
522 trunk_enqueue_t ret;
523
524 if (!ttrunk) {
525 ERROR("Failed to get trunk connection for LDAP bind");
527 }
528
529 treq = trunk_request_alloc(ttrunk->trunk, request);
530 if (!treq) {
531 ERROR("Failed to allocate trunk request for LDAP bind");
533 }
534
535 MEM(bind_auth_ctx = talloc_zero(treq, fr_ldap_bind_auth_ctx_t));
536 *bind_auth_ctx = (fr_ldap_bind_auth_ctx_t) {
537 .treq = treq,
538 .request = request,
539 .thread = thread,
540 .ret = LDAP_PROC_NO_RESULT,
541 .type = LDAP_BIND_SASL
542 };
543
544 MEM(bind_auth_ctx->sasl_ctx = talloc(bind_auth_ctx, fr_ldap_sasl_ctx_t));
545 talloc_set_destructor(bind_auth_ctx->sasl_ctx, _sasl_ctx_free);
546 *bind_auth_ctx->sasl_ctx = (fr_ldap_sasl_ctx_t) {
547 .mechs = mechs,
548 .identity = identity,
549 .password = password,
550 .proxy = proxy,
551 .realm = realm,
552 };
553
554 ret = trunk_request_enqueue(&bind_auth_ctx->treq, ttrunk->trunk, request, bind_auth_ctx, NULL);
555
556 switch (ret) {
557 case TRUNK_ENQUEUE_OK:
559 break;
560
561 default:
562 ERROR("Failed to enqueue bind request");
563 trunk_request_free(&treq);
565 }
566
567 return unlang_function_push_with_result(p_result,
568 request,
573 bind_auth_ctx);
574}
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition action.h:35
@ UNLANG_ACTION_FAIL
Encountered an unexpected error.
Definition action.h:36
@ UNLANG_ACTION_YIELD
Temporarily pause execution until an event occurs.
Definition action.h:42
static uint8_t request[4]
#define USES_APPLE_DEPRECATED_API
Definition build.h:590
#define RCSID(id)
Definition build.h:603
#define UNUSED
Definition build.h:415
#define NUM_ELEMENTS(_t)
Definition build.h:437
#define fr_cond_assert(_x)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
Definition debug.h:177
#define MEM(x)
Definition debug.h:38
#define ERROR(fmt,...)
Definition dhcpclient.c:40
#define fr_event_fd_insert(...)
Definition event.h:247
#define unlang_function_push_with_result(_result_p, _request, _func, _repeat, _signal, _sigmask, _top_frame, _uctx)
Push a generic function onto the unlang stack that produces a result.
Definition function.h:146
#define unlang_function_repeat_set(_request, _repeat)
Set a new repeat function for an existing function frame.
Definition function.h:110
talloc_free(hp)
#define UNLANG_SUB_FRAME
Definition interpret.h:37
char const * proxy
Proxy identity, may be NULL in which case identity is used.
Definition base.h:496
fr_ldap_rcode_t ret
Return code of bind operation.
Definition base.h:611
int msgid
libldap msgid for this bind.
Definition base.h:604
char * server
Initial server to bind to.
Definition base.h:233
LDAP * handle
libldap handle.
Definition base.h:327
void fr_ldap_control_merge(LDAPControl *serverctrls_out[], LDAPControl *clientctrls_out[], size_t serverctrls_len, size_t clientctrls_len, fr_ldap_connection_t *conn, LDAPControl *serverctrls_in[], LDAPControl *clientctrls_in[])
Merge connection and call specific client and server controls.
Definition control.c:48
char const * identity
of the user.
Definition base.h:494
int fd
File descriptor for this connection.
Definition base.h:343
void fr_ldap_state_error(fr_ldap_connection_t *c)
Signal that there's been an error on the connection.
Definition state.c:153
LDAPMessage * result
Previous result.
Definition base.h:502
fr_ldap_config_t const * config
rlm_ldap connection configuration.
Definition base.h:338
fr_ldap_connection_t * c
to bind. Only used when binding as admin user.
Definition base.h:492
LDAPControl ** clientctrls
Controls to pass to the client (library).
Definition base.h:499
trunk_request_t * treq
Trunk request this bind is associated with.
Definition base.h:603
char const * realm
SASL realm (may be NULL).
Definition base.h:497
char const * mechs
SASL mechanisms to run.
Definition base.h:493
char const * password
of the user, may be NULL if no password is specified.
Definition base.h:495
fr_ldap_state_t fr_ldap_state_next(fr_ldap_connection_t *c)
Move between LDAP connection states.
Definition state.c:50
fr_ldap_thread_trunk_t * fr_thread_ldap_bind_trunk_get(fr_ldap_thread_t *thread)
Find the thread specific trunk to use for LDAP bind auths.
int msgid
Last msgid. Only used when binding as admin user.
Definition base.h:501
#define LDAP_MAX_CONTROLS
Maximum number of client/server controls.
Definition base.h:94
fr_ldap_rcode_t
Codes returned by fr_ldap internal functions.
Definition base.h:567
@ LDAP_PROC_CONTINUE
Operation is in progress.
Definition base.h:571
@ LDAP_PROC_SUCCESS
Operation was successful.
Definition base.h:572
@ LDAP_PROC_ERROR
Unrecoverable library/server error.
Definition base.h:574
@ LDAP_PROC_NOT_PERMITTED
Operation was not permitted, either current user was locked out in the case of binds,...
Definition base.h:579
@ LDAP_PROC_PENDING
fr_ldap_result() was polling and hasn't read the final message yet.
Definition base.h:568
@ LDAP_PROC_REJECT
Bind failed, user was rejected.
Definition base.h:583
@ LDAP_PROC_BAD_DN
Specified an invalid object in a bind or search DN.
Definition base.h:585
@ LDAP_PROC_NO_RESULT
Got no results.
Definition base.h:587
char const * rmech
Mech we're continuing with.
Definition base.h:503
LDAPControl ** serverctrls
Controls to pass to the server.
Definition base.h:498
trunk_t * trunk
Connection trunk.
Definition base.h:392
fr_ldap_thread_t * thread
This bind is being run by.
Definition base.h:602
connection_t * conn
Connection state handle.
Definition base.h:339
fr_rb_tree_t * binds
Tree of outstanding bind auths.
Definition base.h:373
Holds arguments for async bind auth requests.
Definition base.h:600
Tracks the state of a libldap connection handle.
Definition base.h:326
Holds arguments for the async SASL bind operation.
Definition base.h:491
Thread specific structure to manage LDAP trunk connections.
Definition base.h:366
Thread LDAP trunk structure.
Definition base.h:386
fr_ldap_rcode_t fr_ldap_result(LDAPMessage **result, LDAPControl ***ctrls, fr_ldap_connection_t const *conn, int msgid, int all, char const *dn, fr_time_delta_t timeout)
Parse response from LDAP server dealing with any errors.
Definition base.c:409
#define PERROR(_fmt,...)
Definition log.h:233
#define DEBUG3(_fmt,...)
Definition log.h:271
#define RWARN(fmt,...)
Definition log.h:314
#define RPERROR(fmt,...)
Definition log.h:319
Stores all information relating to an event list.
Definition event.c:375
int fr_nonblock(UNUSED int fd)
Definition misc.c:293
#define RDEBUG2(fmt,...)
#define DEBUG2(fmt,...)
int fr_rb_remove(void **removed, fr_rb_tree_t *tree, void const *data)
Remove an entry from the tree, without freeing the data.
Definition rb.c:718
#define RETURN_UNLANG_DISALLOW
Definition rcode.h:73
#define RETURN_UNLANG_INVALID
Definition rcode.h:72
#define RETURN_UNLANG_NOTFOUND
Definition rcode.h:74
#define RETURN_UNLANG_FAIL
Definition rcode.h:69
#define RETURN_UNLANG_REJECT
Definition rcode.h:68
#define RETURN_UNLANG_OK
Definition rcode.h:70
static USES_APPLE_DEPRECATED_API void _ldap_sasl_bind_io_write(fr_event_list_t *el, int fd, UNUSED int flags, void *uctx)
Progress an interactive SASL bind.
Definition sasl.c:203
static void ldap_async_sasl_bind_auth_cancel(request_t *request, UNUSED fr_signal_t action, void *uctx)
Signal an outstanding SASL LDAP bind to cancel.
Definition sasl.c:402
unlang_action_t fr_ldap_sasl_bind_auth_async(unlang_result_t *p_result, request_t *request, fr_ldap_thread_t *thread, char const *mechs, char const *identity, char const *password, char const *proxy, char const *realm)
Initiate an async SASL LDAP bind for authentication.
Definition sasl.c:515
static void _ldap_sasl_bind_io_error(UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, UNUSED int fd_errno, void *uctx)
Error reading from or writing to the file descriptor.
Definition sasl.c:42
static void _ldap_sasl_bind_io_read(fr_event_list_t *el, int fd, UNUSED int flags, void *uctx)
Parse a sasl bind response from a server.
Definition sasl.c:122
static int _sasl_interact(UNUSED LDAP *handle, UNUSED unsigned flags, void *uctx, void *sasl_callbacks)
Callback for fr_ldap_sasl_interactive_bind.
Definition sasl.c:60
static unlang_action_t ldap_async_sasl_bind_auth_results(unlang_result_t *p_result, request_t *request, void *uctx)
Handle the return code from parsed LDAP results to set the module rcode.
Definition sasl.c:418
int fr_ldap_sasl_bind_async(fr_ldap_connection_t *c, char const *mechs, char const *identity, char const *password, char const *proxy, char const *realm, LDAPControl **serverctrls, LDAPControl **clientctrls)
Install I/O handlers for the bind operation.
Definition sasl.c:319
static int _sasl_ctx_free(fr_ldap_sasl_ctx_t *sasl_ctx)
Ensure any outstanding messages are freed.
Definition sasl.c:298
int fr_ldap_sasl_bind_auth_send(fr_ldap_sasl_ctx_t *sasl_ctx, int *msgid, fr_ldap_connection_t *ldap_conn)
Send a SASL LDAP auth bind.
Definition sasl.c:378
static unlang_action_t ldap_async_sasl_bind_auth_start(UNUSED unlang_result_t *p_result, UNUSED request_t *request, UNUSED void *uctx)
Yield interpreter after enqueueing sasl auth bind.
Definition sasl.c:390
#define FR_SIGNAL_ALLOW(_signals)
Signal mask which blocks every signal except the ones in _signals.
Definition signal.h:58
fr_signal_t
Signals that can be generated/processed by request signal handlers.
Definition signal.h:38
@ FR_SIGNAL_CANCEL
Request has been cancelled.
Definition signal.h:40
#define fr_time_delta_wrap(_time)
Definition time.h:152
trunk_request_t * trunk_request_alloc(trunk_t *trunk, request_t *request)
(Pre-)Allocate a new trunk request
Definition trunk.c:2542
trunk_enqueue_t trunk_request_enqueue(trunk_request_t **treq_out, trunk_t *trunk, request_t *request, void *preq, void *rctx)
Enqueue a request that needs data written to the trunk.
Definition trunk.c:2657
trunk_enqueue_t trunk_request_requeue(trunk_request_t *treq)
Re-enqueue a request on the same connection.
Definition trunk.c:2746
void trunk_request_signal_cancel(trunk_request_t *treq)
Cancel a trunk request.
Definition trunk.c:2216
void trunk_request_free(trunk_request_t **treq_to_free)
If the trunk request is freed then update the target requests.
Definition trunk.c:2386
void trunk_request_signal_complete(trunk_request_t *treq)
Signal that a trunk request is complete.
Definition trunk.c:2158
Wraps a normal request.
Definition trunk.c:99
trunk_enqueue_t
Definition trunk.h:158
@ TRUNK_ENQUEUE_OK
Operation was successful.
Definition trunk.h:160
@ TRUNK_ENQUEUE_IN_BACKLOG
Request should be enqueued in backlog.
Definition trunk.h:159
static fr_event_list_t * el
#define fr_box_strvalue_len(_val, _len)
Definition value.h:340