help-gnu-radius
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gnu-radius] problems getting rewrite hook right


From: Sergey Poznyakoff
Subject: Re: [Help-gnu-radius] problems getting rewrite hook right
Date: Fri, 10 Nov 2006 10:28:18 +0200

Hi Charles,

> This is perfect!  I tried something similar myself, but I screwed
> something up.  Can you help me understand how this works?

Sure. Your analyze of its work is quite correct in all respects.

> > {
> >        integer a;
> 
> What's "a"?

Just a leftover :) Seems like I was planning to implement it some other
way, but then changed my mind. You can remove this declaration.

> In the bigger picture, I assume whenever we do a match in this rewrite
> language that each match is available as "\1", "\2", "\3", etc., right?

Yes, that's right.
 
> >      %[User-Name] = localpart;
> 
> I get this, but can you verify that in a rewrite rule I can basically
> alter any dictionary value I want to using this method?  And all the
> possible values to alter are found in the dictionary file, correct?
> Even ones I've added to the stock dictionary?

Yes, you can refer to any attributes using %[] notation. It does not
even matter whether the attribute you are referring to is present in the
request or not. If it is not present, the effect of the assignment is to
create it (you can also check for the presence of an attribute using
*%[name] notation). If there are several instances of an attribute in
the request, you can refer to the particular one using the notation
%[name](i) , where i is its ordinal number in the request.

> >         return domainpart;
> > }
> 
> Very basic question that indicates I dont' understand the language
> very well...  Why do I need the "return" statement?  Why don't I need
> it for "%[User-Name]"?

I supposed the function will be called from raddb/hints, as was first
shown in one of your postings, that is:

DEFAULT NULL    Auth-Dom = "=domain_split(%[User-Name])"

So, this way, the returned value is assigned to Auth-Dom attribute, and
the modification of User-Name is done internally.

By the way I am planning to implement returning multiple values, which
could be useful in this and the similar cases.

Of course, you could have assigned both attributes from within the
function:

        %[User-Name] = localpart;
        %[Auth-Dom] = domainpart;                   

In this case, it would probably be no use returning anything from the
function, so it could be redeclared as `integer domain_part()' (there is
no `void' data type in the language, so the convention is to use integer
instead) and called using Rewrite-Function attribute.
        
Regards,
Sergey




reply via email to

[Prev in Thread] Current Thread [Next in Thread]