#include "rlm_eap.h"
static const CONF_PARSER module_config[] = {
- { "default_eap_type", PW_TYPE_STRING_PTR,
- offsetof(rlm_eap_t, default_method_name), NULL, "md5" },
- { "timer_expire", PW_TYPE_INTEGER,
- offsetof(rlm_eap_t, timer_limit), NULL, "60"},
- { "ignore_unknown_eap_types", PW_TYPE_BOOLEAN,
- offsetof(rlm_eap_t, ignore_unknown_types), NULL, "no" },
- { "mod_accounting_username_bug", PW_TYPE_BOOLEAN,
- offsetof(rlm_eap_t, mod_accounting_username_bug), NULL, "no" },
- { "max_sessions", PW_TYPE_INTEGER,
- offsetof(rlm_eap_t, max_sessions), NULL, "2048"},
-
- { NULL, -1, 0, NULL, NULL } /* end the list */
+ { "default_eap_type", FR_CONF_OFFSET(PW_TYPE_STRING, rlm_eap_t, default_method_name), "md5" },
+ { "timer_expire", FR_CONF_OFFSET(PW_TYPE_INTEGER, rlm_eap_t, timer_limit), "60" },
+ { "ignore_unknown_eap_types", FR_CONF_OFFSET(PW_TYPE_BOOLEAN, rlm_eap_t, ignore_unknown_types), "no" },
+ { "mod_accounting_username_bug", FR_CONF_OFFSET(PW_TYPE_BOOLEAN, rlm_eap_t, mod_accounting_username_bug), "no" },
+ { "max_sessions", FR_CONF_OFFSET(PW_TYPE_INTEGER, rlm_eap_t, max_sessions), "2048" },
+
+ { NULL, -1, 0, NULL, NULL } /* end the list */
};
/*
#endif
rbtree_free(inst->session_tree);
- if (inst->handler_tree) rbtree_free(inst->handler_tree);
+ if (inst->handler_tree) {
+ rbtree_free(inst->handler_tree);
+ /*
+ * Must be NULL else when nodes are freed they try to
+ * delete themselves from the tree.
+ */
+ inst->handler_tree = NULL;
+ }
inst->session_tree = NULL;
eaplist_free(inst);
* EAP work.
*/
if (fr_ipaddr_cmp(&one->src_ipaddr, &two->src_ipaddr) != 0) {
- WDEBUG("EAP packets are arriving from two different upstream "
+ WARN("EAP packets are arriving from two different upstream "
"servers. Has there been a proxy fail-over?");
}
method = eap_name2type(name);
if (method == PW_EAP_INVALID) {
- cf_log_err_cs(cs, "Unknown EAP method %s", name);
+ cf_log_err_cs(cs, "No dictionary definition for EAP method %s", name);
return -1;
}
*/
method = eap_name2type(inst->default_method_name);
if (method == PW_EAP_INVALID) {
- cf_log_err_cs(cs, "Unknown default EAP method '%s'",
+ cf_log_err_cs(cs, "No dictionary definition for default EAP method '%s'",
inst->default_method_name);
return -1;
}
* Lookup sessions in the tree. We don't free them in
* the tree, as that's taken care of elsewhere...
*/
- inst->session_tree = rbtree_create(eap_handler_cmp, NULL, 0);
+ inst->session_tree = rbtree_create(NULL, eap_handler_cmp, NULL, 0);
if (!inst->session_tree) {
ERROR("rlm_eap (%s): Cannot initialize tree", inst->xlat_name);
return -1;
}
+ fr_link_talloc_ctx_free(inst, inst->session_tree);
if (fr_debug_flag) {
- inst->handler_tree = rbtree_create(eap_handler_ptr_cmp, NULL, 0);
+ inst->handler_tree = rbtree_create(NULL, eap_handler_ptr_cmp, NULL, 0);
if (!inst->handler_tree) {
ERROR("rlm_eap (%s): Cannot initialize tree", inst->xlat_name);
return -1;
}
+ fr_link_talloc_ctx_free(inst, inst->handler_tree);
#ifdef HAVE_PTHREAD_H
if (pthread_mutex_init(&(inst->handler_mutex), NULL) < 0) {
- ERROR("rlm_eap (%s): Failed initializing mutex: %s", inst->xlat_name, strerror(errno));
+ ERROR("rlm_eap (%s): Failed initializing mutex: %s", inst->xlat_name, fr_syserror(errno));
return -1;
}
#endif
#ifdef HAVE_PTHREAD_H
if (pthread_mutex_init(&(inst->session_mutex), NULL) < 0) {
- ERROR("rlm_eap (%s): Failed initializing mutex: %s", inst->xlat_name, strerror(errno));
+ ERROR("rlm_eap (%s): Failed initializing mutex: %s", inst->xlat_name, fr_syserror(errno));
return -1;
}
#endif
/*
* For backwards compatibility.
*/
-static rlm_rcode_t mod_authenticate(void *instance, REQUEST *request)
+static rlm_rcode_t CC_HINT(nonnull) mod_authenticate(void *instance, REQUEST *request)
{
rlm_eap_t *inst;
eap_handler_t *handler;
/*
* If we're doing horrible tunneling work, remember it.
*/
- if ((request->options & RAD_REQUEST_OPTION_PROXY_EAP) != 0) {
- RDEBUG2(" Not-EAP proxy set. Not composing EAP");
+ if ((request->log.lvl & RAD_REQUEST_OPTION_PROXY_EAP) != 0) {
+ RDEBUG2("No EAP proxy set. Not composing EAP");
/*
* Add the handle to the proxied list, so that we
* can retrieve it in the post-proxy stage, and
*/
pairdelete(&request->proxy->vps, PW_FREERADIUS_PROXIED_TO, VENDORPEC_FREERADIUS, TAG_ANY);
- RDEBUG2(" Tunneled session will be proxied. Not doing EAP.");
+ RDEBUG2("Tunneled session will be proxied. Not doing EAP");
return RLM_MODULE_HANDLED;
}
#endif
* says that we MUST include a User-Name attribute in the
* Access-Accept.
*/
- if ((request->reply->code == PW_AUTHENTICATION_ACK) &&
+ if ((request->reply->code == PW_CODE_ACCESS_ACCEPT) &&
request->username) {
VALUE_PAIR *vp;
* terminated string in Access-Accept.
*/
if (inst->mod_accounting_username_bug) {
- char const *old = vp->vp_strvalue;
- char *new = talloc_zero_array(vp, char, vp->length + 1);
+ char const *old = vp->vp_strvalue;
+ char *new = talloc_zero_array(vp, char, vp->length + 1);
- memcpy(new, old, vp->length);
- vp->vp_strvalue = new;
- vp->length++;
+ memcpy(new, old, vp->length);
+ vp->vp_strvalue = new;
+ vp->length++;
- rad_const_free(old);
+ rad_const_free(old);
}
}
* to check for user existence & get their configured values.
* It Handles EAP-START Messages, User-Name initilization.
*/
-static rlm_rcode_t mod_authorize(void *instance, REQUEST *request)
+static rlm_rcode_t CC_HINT(nonnull) mod_authorize(void *instance, REQUEST *request)
{
rlm_eap_t *inst;
int status;
* If we're proxying EAP, then there may be magic we need
* to do.
*/
-static rlm_rcode_t mod_post_proxy(void *inst, REQUEST *request)
+static rlm_rcode_t CC_HINT(nonnull) mod_post_proxy(void *inst, REQUEST *request)
{
size_t i;
size_t len;
vp_cursor_t cursor;
/*
- * Just in case the admin lists EAP in post-proxy-type Fail.
- */
- if (!request->proxy_reply) return RLM_MODULE_NOOP;
-
- /*
* If there was a handler associated with this request,
* then it's a tunneled request which was proxied...
*/
* says that we MUST include a User-Name attribute in the
* Access-Accept.
*/
- if ((request->reply->code == PW_AUTHENTICATION_ACK) &&
+ if ((request->reply->code == PW_CODE_ACCESS_ACCEPT) &&
request->username) {
/*
* Doesn't exist, add it in.
}
/*
+ * This is allowed.
+ */
+ if (!request->proxy_reply) return RLM_MODULE_NOOP;
+
+ /*
* There may be more than one Cisco-AVPair.
* Ensure we find the one with the LEAP attribute.
*/
- paircursor(&cursor, &request->proxy_reply->vps);
+ fr_cursor_init(&cursor, &request->proxy_reply->vps);
for (;;) {
/*
* Hmm... there's got to be a better way to
* This is vendor Cisco (9), Cisco-AVPair
* attribute (1)
*/
- vp = pairfindnext(&cursor, 1, 9, TAG_ANY);
+ vp = fr_cursor_next_by_num(&cursor, 1, 9, TAG_ANY);
if (!vp) {
return RLM_MODULE_NOOP;
}
/*
* The format is very specific.
*/
- if (vp->length != 17 + 34) {
- RDEBUG2("Cisco-AVPair with leap:session-key has incorrect length %d: Expected %d",
+ if (vp->length != (17 + 34)) {
+ RDEBUG2("Cisco-AVPair with leap:session-key has incorrect length %zu: Expected %d",
vp->length, 17 + 34);
return RLM_MODULE_NOOP;
}
/*
* Decrypt the session key, using the proxy data.
+ *
+ * Note that the session key is *binary*, and therefore
+ * may contain embedded zeros. So we have to use memdup.
*/
- i = 34; /* starts off with 34 octets */
- p = talloc_strdup(vp, vp->vp_strvalue);
- len = rad_tunnel_pwdecode((uint8_t *)p + 17, &i,
- request->home_server->secret,
- request->proxy->vector);
+ i = 34;
+ p = talloc_memdup(vp, vp->vp_octets, vp->length);
+ talloc_set_type(p, uint8_t);
+ len = rad_tunnel_pwdecode((uint8_t *)p + 17, &i, request->home_server->secret, request->proxy->vector);
/*
* FIXME: Assert that i == 16.
rad_tunnel_pwencode(p + 17, &len,
request->client->secret,
request->packet->vector);
-// talloc_free(vp->vp_strvalue);
- vp->vp_strvalue = p;
- vp->type = VT_DATA;
+ pairstrsteal(vp, p);
return RLM_MODULE_UPDATED;
}
#endif
-static rlm_rcode_t mod_post_auth(void *instance, REQUEST *request)
+static rlm_rcode_t CC_HINT(nonnull) mod_post_auth(void *instance, REQUEST *request)
{
rlm_eap_t *inst = instance;
VALUE_PAIR *vp;
module_t rlm_eap = {
RLM_MODULE_INIT,
"eap",
- RLM_TYPE_CHECK_CONFIG_SAFE, /* type */
+ 0, /* type */
sizeof(rlm_eap_t),
module_config,
mod_instantiate, /* instantiation */