30 RCSID(
"$Id: 8e5224bbcef33e06938684bb69e42626b0a43072 $")
34 #include <freeradius-devel/radiusd.h>
35 #include <freeradius-devel/rad_assert.h>
79 regmatch_t rxmatch[REQUEST_MAX_REGEX + 1];
80 size_t nmatch =
sizeof(rxmatch) /
sizeof(regmatch_t);
82 char *expr = NULL, *value = NULL;
83 char const *expr_p, *value_p;
86 expr_p = check->vp_strvalue;
92 value_p = vp->vp_strvalue;
97 if (!expr_p || !value_p) {
98 REDEBUG(
"Error stringifying operand for regular expression");
110 slen = regex_compile(request, &preg, expr_p, talloc_array_length(expr_p) - 1,
false,
false,
true,
true);
117 slen = regex_exec(preg, value_p, talloc_array_length(value_p) - 1, rxmatch, &nmatch);
128 regex_sub_to_request(request, &preg, value_p, talloc_array_length(value_p) - 1,
130 ret = (slen == 1) ? 0 : -1;
132 ret = (slen != 1) ? 0 : -1;
157 ret = ((int) vp->
tag) - ((int) check->
tag);
158 if (ret != 0)
goto finish;
164 switch (check->
da->
type) {
165 #ifdef WITH_ASCEND_BINARY
173 if (vp->vp_length != check->vp_length) {
177 ret = memcmp(vp->vp_strvalue, check->vp_strvalue,
182 ret = strcmp(vp->vp_strvalue,
187 ret = vp->vp_byte - check->vp_byte;
190 ret = vp->vp_short - check->vp_short;
193 ret = vp->vp_integer - check->vp_integer;
200 if (vp->vp_integer64 < check->vp_integer64) {
202 }
else if (vp->vp_integer64 > check->vp_integer64) {
210 if (vp->vp_signed < check->vp_signed) {
212 }
else if (vp->vp_signed > check->vp_signed) {
220 ret = vp->vp_date - check->vp_date;
224 ret = ntohl(vp->vp_ipaddr) - ntohl(check->vp_ipaddr);
228 ret = memcmp(&vp->vp_ipv6addr, &check->vp_ipv6addr,
sizeof(vp->vp_ipv6addr));
232 ret = memcmp(vp->vp_ipv6prefix, check->vp_ipv6prefix,
sizeof(vp->vp_ipv6prefix));
236 ret = memcmp(vp->vp_ifid, check->vp_ifid,
sizeof(vp->vp_ifid));
244 if (ret > 0)
return 1;
245 if (ret < 0)
return -1;
282 for (c = cmp; c; c = c->
next) {
285 check_pairs, reply_pairs);
307 for (c = cmp; c; c = c->
next) {
329 for (c = cmp; c; c = c->
next) {
357 memset(&flags, 0,
sizeof(flags));
378 DEBUG(
"Creating attribute %s", name);
424 struct cmp *c, *last;
427 for (c = cmp; c; c = c->
next) {
434 if (c == NULL)
return;
453 struct cmp *c, **tail;
456 while ((c = *tail) != NULL) {
509 case PW_CRYPT_PASSWORD:
513 case PW_SESSION_TYPE:
514 case PW_STRIP_USER_NAME:
526 case PW_USER_PASSWORD:
528 WARN(
"Found User-Password == \"...\"");
529 WARN(
"Are you sure you don't mean Cleartext-Password?");
530 WARN(
"See \"man rlm_pap\" for more information");
543 auth_item = req_list;
546 while (auth_item != NULL) {
547 if ((auth_item->
da == from) || (!from)) {
550 auth_item = auth_item->
next;
557 if (auth_item == NULL) {
587 check_item, check, rep_list);
589 switch (check_item->
op) {
592 RWDEBUG(
"Invalid operator '%s' for item %s: reverting to '=='",
598 if (compare != 0) result = -1;
602 if (compare == 0) result = -1;
606 if (compare >= 0) result = -1;
610 if (compare <= 0) result = -1;
614 if (compare > 0) result = -1;
618 if (compare < 0) result = -1;
624 if (compare != 0) result = -1;
633 if ((result != 0) && (!first_only)) {
634 auth_item = auth_item->
next;
659 char *expanded = NULL;
664 slen =
radius_axlat(&expanded, request, vp->xlat, NULL, NULL);
683 talloc_free(expanded);
687 talloc_free(expanded);
705 unsigned int attribute,
unsigned int vendor)
742 if (!vp || !request || !request->
log.func)
return;
747 RDEBUGX(level,
"%s%s", prefix ? prefix :
"&", buffer);
761 if (!vp || !request || !request->
log.func)
return;
772 RDEBUGX(level,
"%s%s", prefix ? prefix :
"&", buffer);
788 if (!vp || !request || !request->
log.func)
return;
798 ((vp->
da->
attr & 0xFFFF) > 0xff))
continue;
800 RDEBUGX(level,
"%s%s", prefix ? prefix :
"", buffer);
875 if (!fmt || !request || !request->
packet) {
889 p = talloc_vasprintf(request, fmt, aq);
ssize_t ssize_t ssize_t radius_axlat(char **out, REQUEST *request, char const *fmt, xlat_escape_t escape, void *escape_ctx) CC_HINT(nonnull(1
VALUE_PAIR has a single value.
int radius_xlat_do(REQUEST *request, VALUE_PAIR *vp)
Expands an attribute marked with fr_pair_mark_xlat.
int paircompare_register(fr_dict_attr_t const *attribute, fr_dict_attr_t const *from, bool first_only, RAD_COMPARE_FUNC func, void *instance)
Register a function as compare function.
void vmodule_failure_msg(REQUEST *request, char const *fmt, va_list ap)
Add a module failure message VALUE_PAIR to the request.
void module_failure_msg(REQUEST *request, char const *fmt,...)
char * fr_pair_value_asprint(TALLOC_CTX *ctx, VALUE_PAIR const *vp, char quote)
Print one attribute value to a string.
#define RINDENT()
Indent R* messages by one level.
void debug_pair(VALUE_PAIR *vp)
Print a single valuepair to stderr or error log.
Only displayed when debugging is enabled.
struct rad_request::@7 log
void * rad_malloc(size_t size)
Ascend binary format a packed data structure.
#define REMARKER(_m, _i, _e)
Output string with error marker, showing where format error occurred.
int8_t tag
Tag value used to group valuepairs.
const FR_NAME_NUMBER fr_tokens_table[]
#define pair_make_request(_a, _b, _c)
VALUE_PAIR * fr_cursor_init(vp_cursor_t *cursor, VALUE_PAIR *const *node)
Setup a cursor to iterate over attribute pairs.
int fr_dict_attr_add(fr_dict_t *dict, fr_dict_attr_t const *parent, char const *name, int attr, PW_TYPE type, fr_dict_attr_flags_t flags)
Add an attribute to the dictionary.
Values of the encryption flags.
int radius_callback_compare(REQUEST *request, VALUE_PAIR *req, VALUE_PAIR *check, VALUE_PAIR *check_pairs, VALUE_PAIR **reply_pairs)
Compare check and vp.
valuepair value must be xlat expanded when it's added to VALUE_PAIR tree.
VALUE_PAIR * fr_pair_afrom_num(TALLOC_CTX *ctx, unsigned int vendor, unsigned int attr)
Create a new valuepair.
Abstraction to allow iterating over different configurations of VALUE_PAIRs.
fr_dict_attr_flags_t flags
Flags.
int fr_pair_value_from_str(VALUE_PAIR *vp, char const *value, size_t inlen)
Convert string value to native attribute value.
static bool otherattr(fr_dict_attr_t const *attribute, fr_dict_attr_t const **from)
See what attribute we want to compare with.
void rdebug_pair(log_lvl_t level, REQUEST *request, VALUE_PAIR *vp, char const *prefix)
Print a single valuepair to stderr or error log.
int paircompare(REQUEST *request, VALUE_PAIR *req_list, VALUE_PAIR *check, VALUE_PAIR **rep_list)
Compare two pair lists except for the password information.
void fr_pair_value_snprintf(VALUE_PAIR *vp, char const *fmt,...)
Print data into an "string" data type.
void paircompare_unregister(fr_dict_attr_t const *attribute, RAD_COMPARE_FUNC func)
Unregister comparison function for an attribute.
void fr_pair_add(VALUE_PAIR **head, VALUE_PAIR *add)
Add a VP to the end of the list.
int tmpl_find_vp(VALUE_PAIR **out, REQUEST *request, vp_tmpl_t const *vpt)
Returns the first VP matching a vp_tmpl_t.
ssize_t tmpl_from_attr_str(vp_tmpl_t *vpt, char const *name, request_refs_t request_def, pair_lists_t list_def, bool allow_unknown, bool allow_undefined)
Parse a string into a TMPL_TYPE_ATTR_* or TMPL_TYPE_LIST type vp_tmpl_t.
int radius_get_vp(VALUE_PAIR **out, REQUEST *request, char const *name)
Return a VP from the specified request.
VALUE_PAIR * fr_pair_find_by_num(VALUE_PAIR *head, unsigned int vendor, unsigned int attr, int8_t tag)
Find the pair with the matching attribute.
int radius_compare_vps(UNUSED REQUEST *request, VALUE_PAIR *check, VALUE_PAIR *vp)
Compares check and vp by value.
unsigned int attr
Attribute number.
size_t fr_pair_snprint(char *out, size_t outlen, VALUE_PAIR const *vp)
Print one attribute and value to a string.
Attributes in incoming or internally proxied request.
#define TAG_EQ(_x, _y)
Check if tags are equal.
void fr_pair_fprint(FILE *fp, VALUE_PAIR const *vp)
Print one attribute and value to FP.
fr_dict_attr_t const * from
unsigned int vendor
Vendor that defines this attribute.
bool radlog_debug_enabled(log_type_t type, log_lvl_t lvl, REQUEST *request) CC_HINT(nonnull)
Whether a request specific debug message should be logged.
Stores an attribute, a value and various bits of other data.
void rad_const_free(void const *ptr)
#define REXDENT()
Exdent (unindent) R* messages by one level.
FR_TOKEN op
Operator to use when moving or inserting valuepair into a list.
char const * fr_strerror(void)
Get the last library error.
int tmpl_copy_vps(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, vp_tmpl_t const *vpt)
Copy pairs matching a vp_tmpl_t in the current REQUEST.
int radius_copy_vp(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, char const *name)
Copy VP(s) from the specified request.
static char const * prefix
char name[1]
Attribute name.
value_type_t type
Type of pointer in value union.
log_lvl_t rad_debug_lvl
Global debugging level.
VALUE_PAIR * fr_cursor_next(vp_cursor_t *cursor)
Advanced the cursor to the next VALUE_PAIR.
RADIUS_PACKET * packet
Incoming request.
void fr_strerror_printf(char const *,...) CC_HINT(format(printf
void rdebug_proto_pair_list(log_lvl_t level, REQUEST *request, VALUE_PAIR *vp, char const *prefix)
Print a list of protocol VALUE_PAIRs.
void fr_pair_value_strsteal(VALUE_PAIR *vp, char const *src)
Reparent an allocated char buffer to a VALUE_PAIR.
int radius_find_compare(fr_dict_attr_t const *attribute)
Find a comparison function for two attributes.
void rdebug_pair_list(log_lvl_t level, REQUEST *request, VALUE_PAIR *vp, char const *prefix)
Print a list of VALUE_PAIRs.
unsigned int has_tag
Tagged attribute.
int(* RAD_COMPARE_FUNC)(void *instance, REQUEST *, VALUE_PAIR *, VALUE_PAIR *, VALUE_PAIR *, VALUE_PAIR **)
char const * fr_int2str(FR_NAME_NUMBER const *table, int number, char const *def)
fr_dict_attr_t const * da
Dictionary attribute defines the attribute.
int paircompare_register_byname(char const *name, fr_dict_attr_t const *from, bool first_only, RAD_COMPARE_FUNC func, void *instance)
Register a function as compare function.
String of printable characters.
#define RDEBUGX(_l, fmt,...)
char const * module
Module the request is currently being processed by.
fr_dict_t * fr_dict_internal
Internal server dictionary.
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
A source or sink of value data.
VALUE_PAIR * radius_pair_create(TALLOC_CTX *ctx, VALUE_PAIR **vps, unsigned int attribute, unsigned int vendor)
Create a VALUE_PAIR and add it to a list of VALUE_PAIR s.
unsigned int compare
has a paircompare registered
fr_dict_attr_t const * attribute
void paircompare_unregister_instance(void *instance)
Unregister comparison function for a module.
fr_dict_attr_t const * fr_dict_attr_by_name(fr_dict_t *dict, char const *attr)
Locate a fr_dict_attr_t by its name.