[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freeradius-devel
Subject:    Re: xlat in rlm_attr_filer
From:       Bjørn_Mork <bjorn () mork ! no>
Date:       2006-04-25 13:12:08
Message-ID: 87bqup94uv.fsf () obelix ! mork ! no
[Download RAW message or body]

"Alan DeKok" <aland@nitros9.org> writes:
> =?iso-8859-1?Q?Bj=F8rn_Mork?= <bjorn@mork.no> wrote:
>> But I found that rlm_attr_filter doesn't do xlat.  So I was wondering
>> why?  Is a patch welcome, or are there good reasons not to do this?
>
>   I don't think there's any good reason for this.
>
>   The patch shouldn't be too hard.

How about something like this?  It does add a bit of overhead by
making an xlatted copy of the complete checklist, but this allows us
to _test against_ xlatted values in addition to adding them.

Thoughts?  Unnecessary to xlat anything but the added attributes?


Bjørn


[Attachment #3 (text/x-patch)]

Index: src/modules/rlm_attr_filter/rlm_attr_filter.c
===================================================================
RCS file: /source/radiusd/src/modules/rlm_attr_filter/rlm_attr_filter.c,v
retrieving revision 1.30
diff -u -r1.30 rlm_attr_filter.c
--- src/modules/rlm_attr_filter/rlm_attr_filter.c	16 Mar 2006 16:47:42 -0000	1.30
+++ src/modules/rlm_attr_filter/rlm_attr_filter.c	25 Apr 2006 13:06:39 -0000
@@ -195,6 +195,7 @@
 	VALUE_PAIR	*output = NULL;
 	VALUE_PAIR	**output_tail;
 	VALUE_PAIR	*check_item;
+	VALUE_PAIR	*check_tmp;
 	PAIR_LIST	*pl;
 	int		found = 0;
 	int		pass, fail = 0;
@@ -235,7 +236,10 @@
 		       pl->lineno);
 		found = 1;
 
-		for (check_item = pl->check;
+		/* create a temporary check list which we can xlat */
+		check_tmp = paircopy(pl->check);
+		
+		for (check_item = check_tmp;
 		     check_item != NULL;
 		     check_item = check_item->next) {
 			if (check_item->attribute == PW_FALL_THROUGH) {
@@ -243,6 +247,20 @@
 				continue;
 			}
 
+			/* do xlat */
+			if (check_item->flags.do_xlat) {
+				int len;
+				char buffer[256];
+
+				DEBUG2(" attr_filter: Doing xlat of value \"%s\"", 
+				       check_item->vp_strvalue);
+
+				len = radius_xlat(buffer, sizeof(buffer), 
+						  check_item->vp_strvalue,
+						  request, NULL);
+				if (len) pairparsevalue(check_item, buffer);
+			}
+
 			/*
 			 *    If it is a SET operator, add the attribute to
 			 *    the output list without checking it.
@@ -272,7 +290,7 @@
 			 *	reset the check_item pointer to
 			 *	beginning of the list
 			 */
-			for (check_item = pl->check;
+			for (check_item = check_tmp;
 			     check_item != NULL;
 			     check_item = check_item->next) {
 				if (vp->attribute == check_item->attribute) {
@@ -291,6 +309,10 @@
 			}
 		}
 		
+
+		/* free the temporary check list */
+		pairfree(&check_tmp); 
+
 		/* If we shouldn't fall through, break */
 		if (!fall_through)
 			break;


- 
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic