27 RCSID(
"$Id: 53a8f7dfa8b94462a3c3cd38a5089f719feaece4 $")
29 #include <freeradius-devel/io/listen.h>
30 #include <freeradius-devel/server/auth.h>
31 #include <freeradius-devel/server/module.h>
32 #include <freeradius-devel/server/protocol.h>
33 #include <freeradius-devel/server/rcode.h>
34 #include <freeradius-devel/server/state.h>
35 #include <freeradius-devel/unlang/call.h>
36 #include <freeradius-devel/util/debug.h>
38 #include <freeradius-devel/util/print.h>
39 #include <freeradius-devel/radius/defs.h>
41 #include <freeradius-devel/protocol/freeradius/freeradius.internal.h>
65 username = fr_pair_find_by_num(&request->request_pairs, 0, FR_STRIPPED_USER_NAME);
66 if (!
username)
username = fr_pair_find_by_num(&request->request_pairs, 0, FR_USER_NAME);
68 if (request->parent) {
69 parent_username = fr_pair_find_by_num(&request->parent->request_pairs, 0, FR_STRIPPED_USER_NAME);
70 if (!parent_username) parent_username = fr_pair_find_by_num(&request->parent->request_pairs, 0, FR_USER_NAME);
80 if (parent_username->
da->attr == FR_STRIPPED_USER_NAME) {
81 vp = fr_pair_find_by_num(&request->parent->request_pairs, 0, FR_USER_NAME);
90 if (strcmp(
vp->vp_strvalue,
username->vp_strvalue) != 0) {
91 char const *outer, *inner;
93 outer = strchr(
vp->vp_strvalue,
'@');
102 if ((outer !=
vp->vp_strvalue) &&
103 ((
vp->vp_length < 10) || (memcmp(
vp->vp_strvalue,
"anonymous@", 10) != 0))) {
104 RWDEBUG(
"Outer User-Name is not anonymized. User privacy is compromised.");
110 }
else if ((
vp->vp_length < 9) || (memcmp(
vp->vp_strvalue,
"anonymous", 9) != 0)) {
111 RWDEBUG(
"Outer User-Name is not anonymized. User privacy is compromised.");
118 inner = strchr(
username->vp_strvalue,
'@');
119 if (outer && inner) {
127 if (strcmp(outer, inner) != 0) {
128 size_t outer_len, inner_len;
130 outer_len =
vp->vp_length;
131 outer_len -= (outer -
vp->vp_strvalue);
134 inner_len -= (inner -
username->vp_strvalue);
140 if (inner_len > outer_len) {
143 suffix = inner + (inner_len - outer_len) - 1;
145 if ((*suffix !=
'.') ||
146 (strcmp(suffix + 1, outer) != 0)) {
147 RWDEBUG(
"Possible spoofing: Inner realm '%s' is not a "
148 "subdomain of the outer realm '%s'", inner, outer);
152 RWDEBUG(
"Possible spoofing: Inner realm and "
153 "outer realms are different");
159 RWDEBUG(
"Outer and inner identities are the same. User privacy is compromised.");
164 if (!request->async) {
165 #ifdef STATIC_ANALYZER
170 request->async = talloc_memdup(request, request->parent->async,
sizeof(
fr_async_t));
171 talloc_set_name_const(request->async, talloc_get_name(request->parent->async));
175 request->async->process(&
final,
176 MODULE_CTX(module_rlm_by_data(request->async->process_inst), NULL, NULL, NULL),
182 if (!request->reply->code ||
200 #ifdef WITH_IFINDEX_NAME_RESOLUTION
201 char if_name[IFNAMSIZ];
209 #ifdef WITH_IFINDEX_NAME_RESOLUTION
213 received ?
"Received" :
"Sent",
216 packet->
socket.inet.src_ipaddr.
af == AF_INET6 ?
"[" :
"",
218 packet->
socket.inet.src_ipaddr.
af == AF_INET6 ?
"]" :
"",
219 packet->
socket.inet.src_port,
220 packet->
socket.inet.dst_ipaddr.
af == AF_INET6 ?
"[" :
"",
222 packet->
socket.inet.dst_ipaddr.
af == AF_INET6 ?
"]" :
"",
223 packet->
socket.inet.dst_port,
224 #ifdef WITH_IFINDEX_NAME_RESOLUTION
225 packet->
socket.inet.ifindex ?
"via " :
"",
226 packet->
socket.inet.ifindex ? fr_ifname_from_ifindex(if_name, packet->
socket.inet.ifindex) :
"",
227 packet->
socket.inet.ifindex ?
" " :
"",
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
void common_packet_debug(request_t *request, fr_packet_t *packet, fr_pair_list_t *pairs, bool received)
unlang_action_t rad_virtual_server(rlm_rcode_t *p_result, request_t *request)
CONF_SECTION * unlang_call_current(request_t *request)
Return the last virtual server that was called.
char const * cf_section_name2(CONF_SECTION const *cs)
Return the second identifier of a CONF_SECTION.
#define fr_cond_assert(_x)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
@ FR_RADIUS_CODE_ACCESS_CHALLENGE
RFC2865 - Access-Challenge.
@ FR_RADIUS_CODE_ACCESS_REJECT
RFC2865 - Access-Reject.
Minimal data structure to use the new code.
void log_request_proto_pair_list(fr_log_lvl_t lvl, request_t *request, fr_pair_t const *parent, fr_pair_list_t const *vps, char const *prefix)
Print a list of protocol fr_pair_ts.
void log_request(fr_log_type_t type, fr_log_lvl_t lvl, request_t *request, char const *file, int line, char const *fmt,...)
Marshal variadic log arguments into a va_list and pass to normal logging functions.
void log_request_pair_list(fr_log_lvl_t lvl, request_t *request, fr_pair_t const *parent, fr_pair_list_t const *vps, char const *prefix)
Print a fr_pair_list_t.
@ L_DBG_LVL_1
Highest priority debug messages (-x).
@ L_DBG
Only displayed when debugging is enabled.
#define MODULE_CTX(_mi, _thread, _env_data, _rctx)
Wrapper to create a module_ctx_t as a compound literal.
#define RETURN_MODULE_REJECT
#define RETURN_MODULE_HANDLED
rlm_rcode_t
Return codes indicating the result of the module call.
@ RLM_MODULE_OK
The module is OK, continue.
Stores an attribute, a value and various bits of other data.
fr_dict_attr_t const *_CONST da
Dictionary attribute defines the attribute number, vendor and type of the pair.
unsigned int code
Packet code (type).
fr_socket_t socket
This packet was received on.
int id
Packet ID (used to link requests/responses).
size_t data_len
Length of packet data.
int af
AF_INET, AF_INET6, or AF_UNIX.
#define fr_box_ipaddr(_val)