#endif
struct cmp {
- int attribute;
- int otherattr;
+ unsigned int attribute;
+ unsigned int otherattr;
void *instance; /* module instance */
RAD_COMPARE_FUNC compare;
struct cmp *next;
/*
* Include substring matches.
*/
- regcomp(®, (char *)check->vp_strvalue,
- REG_EXTENDED);
+ compare = regcomp(®, check->vp_strvalue, REG_EXTENDED);
+ if (compare != 0) {
+ char buffer[256];
+ regerror(compare, ®, buffer, sizeof(buffer));
+
+ RDEBUG("Invalid regular expression %s: %s",
+ check->vp_strvalue, buffer);
+ return -1;
+ }
compare = regexec(®, value, REQUEST_MAX_REGEX + 1,
rxmatch, 0);
regfree(®);
/*
* Include substring matches.
*/
- regcomp(®, (char *)check->vp_strvalue,
- REG_EXTENDED);
+ compare = regcomp(®, (char *)check->vp_strvalue,
+ REG_EXTENDED);
+ if (compare != 0) {
+ char buffer[256];
+ regerror(compare, ®, buffer, sizeof(buffer));
+
+ RDEBUG("Invalid regular expression %s: %s",
+ check->vp_strvalue, buffer);
+ return -1;
+ }
compare = regexec(®, value, REQUEST_MAX_REGEX + 1,
rxmatch, 0);
regfree(®);
* Tagged attributes are equal if and only if both the
* tag AND value match.
*/
- if ((ret == 0) && check->flags.has_tag) {
+ if (check->flags.has_tag) {
ret = ((int) vp->flags.tag) - ((int) check->flags.tag);
if (ret != 0) return ret;
}
* FIXME: use new RB-Tree code.
*/
for (c = cmp; c; c = c->next)
- if (c->attribute == check->attribute) {
+ if ((c->attribute == check->attribute) &&
+ (check->vendor == 0)) {
return (c->compare)(c->instance, req, request, check,
check_pairs, reply_pairs);
}
/*
+ * Find a comparison function for two attributes.
+ */
+int radius_find_compare(unsigned int attribute)
+{
+ struct cmp *c;
+
+ for (c = cmp; c; c = c->next) {
+ if (c->attribute == attribute) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+
+/*
* See what attribute we want to compare with.
*/
-static int otherattr(int attr)
+static int otherattr(unsigned int attr)
{
struct cmp *c;
* For example, PW_GROUP in a check item needs to be compared
* with PW_USER_NAME in the incoming request.
*/
-int paircompare_register(int attr, int compare_attr, RAD_COMPARE_FUNC fun, void *instance)
+int paircompare_register(unsigned int attr, int compare_attr, RAD_COMPARE_FUNC fun, void *instance)
{
struct cmp *c;
/*
* Unregister a function.
*/
-void paircompare_unregister(int attr, RAD_COMPARE_FUNC fun)
+void paircompare_unregister(unsigned int attr, RAD_COMPARE_FUNC fun)
{
struct cmp *c, *last;
DEBUG("WARNING: Are you sure you don't mean Cleartext-Password?");
DEBUG("WARNING: See \"man rlm_pap\" for more information.");
}
- if (pairfind(request, PW_USER_PASSWORD) == NULL) {
+ if (pairfind(request, PW_USER_PASSWORD, 0) == NULL) {
continue;
}
break;
try_again:
if (other >= 0) {
for (; auth_item != NULL; auth_item = auth_item->next) {
- if (auth_item->attribute == other || other == 0)
+ if (auth_item->attribute == (unsigned int) other || other == 0)
break;
}
}
* Don't move 'fallthrough' over.
*/
if (i->attribute == PW_FALL_THROUGH) {
+ tailfrom = i;
continue;
}
pairparsevalue(i, buffer);
}
- found = pairfind(*to, i->attribute);
+ found = pairfind(*to, i->attribute, i->vendor);
switch (i->operator) {
/*
if (!i->vp_strvalue[0] ||
(strcmp((char *)found->vp_strvalue,
(char *)i->vp_strvalue) == 0)){
- pairdelete(to, found->attribute);
+ pairdelete(to, found->attribute, found->vendor);
/*
* 'tailto' may have been
vp = found->next;
memcpy(found, i, sizeof(*found));
found->next = vp;
+ tailfrom = i;
continue;
}
break;
* it causes the server to exit!
*/
VALUE_PAIR *radius_paircreate(REQUEST *request, VALUE_PAIR **vps,
- int attribute, int type)
+ unsigned int attribute, unsigned int vendor, int type)
{
VALUE_PAIR *vp;
request = request; /* -Wunused */
- vp = paircreate(attribute, type);
+ vp = paircreate(attribute, vendor, type);
if (!vp) {
radlog(L_ERR, "No memory!");
rad_assert("No memory" == NULL);
return vp;
}
+void debug_pair(VALUE_PAIR *vp)
+{
+ if (!vp || !debug_flag || !fr_log_fp) return;
+
+ fputc('\t', fr_log_fp);
+ vp_print(fr_log_fp, vp);
+ fputc('\n', fr_log_fp);
+}
+
+void debug_pair_list(VALUE_PAIR *vp)
+{
+ if (!vp || !debug_flag || !fr_log_fp) return;
+
+ while (vp) {
+ fputc('\t', fr_log_fp);
+ vp_print(fr_log_fp, vp);
+ fputc('\n', fr_log_fp);
+ vp = vp->next;
+ }
+ fflush(fr_log_fp);
+}