Setting Service-Type (perl module)

Rowley, Mathew Mathew_Rowley at cable.comcast.com
Wed Oct 27 00:03:15 CEST 2010


Please disregard this. The problem was that the key/values for the radius
attributes were written to a file, and when read, not stripped.




On 10/26/10 2:37 PM, "Rowley, Mathew" <Mathew_Rowley at cable.comcast.com>
wrote:

>I am having the strangest behavior with the perl module when trying to set
>Service-Type.  First, I have a hash of radius attributes and their values
>(%AVP) that I want to set.  Initially I did:
>
>        foreach my $key (keys %AVP)
>        {
>                push @{$RAD_REPLY{"$key"}}, $AVP{$key};
>        }
>
>
>And it would fail when trying to set 'Service-Type'. So, I then thought
>instead of pushing it on to RAD_REPLY, id just set it:
>
>        foreach my $key (keys %AVP)
>        {
>                $RAD_REPLY{"$key"} = $AVP{$key};
>        }
>
>
>
>Still failed. Then I tried to statically set it:
>
>        foreach my $key (keys %AVP)
>        {
>                $RAD_REPLY{"$key"} = $AVP{$key};
>        }
>        $RAD_REPLY{'Service-Type'} = "Administrative-User";
>
>
>That seemed to work (before and after the foreach loop). The only fix I
>currently have is to do:
>
>1        foreach my $key (keys %AVP)
>2        {
>3                if($key == 'Service-Type' && $AVP{$key} ==
>'Administrative-User'){
>4                        $RAD_REPLY{'Service-Type'} =
>"Administrative-User";
>5                } else {
>6                        $RAD_REPLY{$key} = $AVP{$key};
>7                }
>8        }
>
>
>
>Which makes absolutely no sense to me for a few reasons:
>
>1. Line 3 checks static values, and sets those exact same static values...
>Why wouldn¹t it work with variables for the RAD_REPLY key/value?
>2. Line 6 will still work with multiple attributes with the same $key
>(meaning, there can be 10 "Cisco-AVPair" and it will add them all instead
>of just replacing the last one)
>
>
>Anyone have some insight?  Thanks.
>
>
>
>
>On 10/26/10 1:57 PM, "Rowley, Mathew" <Mathew_Rowley at cable.comcast.com>
>wrote:
>
>>Thanks ­ I am also not sure that the users file is actually being
>>processed. In the debug output I see:
>>
>>Tue Oct 26 15:36:17 2010 : Debug: usersfile =
>>"/opt/freeradius/etc/raddb/users"
>>
>>But I don¹t see any of the users content from the debug output like I see
>>from the other files.
>>
>>The config files have all been jumbled due to someone else doing
>>configurations ­ is there a configuration I need to force processing of
>>the users file?
>>
>>
>>
>>From: Alexandre Chapellon
>><alexandre.chapellon at mana.pf<mailto:alexandre.chapellon at mana.pf>>
>>Organization: MANA SAS
>>Reply-To: FreeRadius users mailing list
>><freeradius-users at lists.freeradius.org<mailto:freeradius-users at lists.free
>>r
>>adius.org>>
>>Date: Tue, 26 Oct 2010 09:45:04 -1000
>>To: FreeRadius users mailing list
>><freeradius-users at lists.freeradius.org<mailto:freeradius-users at lists.free
>>r
>>adius.org>>
>>Subject: Re: Setting Service-Type
>>
>>A solution would be to use the operator ":=" instead of "=" in users file
>>with the default entry (should work using unlang too).
>>
>>http://wiki.freeradius.org/Operators
>>
>>
>>Le mardi 26 octobre 2010 à 19:23 +0000, Rowley, Mathew a écrit :
>>
>>I have a perl module that I want to set the Service-Type attribute, but
>>am getting this error:
>>
>>Tue Oct 26 14:54:25 2010 : Debug: rlm_perl: ERROR: Failed to create pair
>>Service-Type = Administrative-User
>>
>>I am thinking its due to the request having the Service-Type already set.
>>Does anyone know if its possible to override that?
>>
>>I have also tried to just statically set the Service-Type in the users
>>file via:
>>DEFAULT
>>Service-Type = Administrative-User
>>
>>Nothing seems to set it. The request looks like:
>>rad_recv: Access-Request packet from host 10.252.152.93 port 32769,
>>id=43, length=79
>>User-Name = "user"
>>User-Password = "pass"
>>Service-Type = NAS-Prompt-User
>>NAS-IP-Address = 10.252.152.93
>>NAS-Identifier = "Security_lab"
>>
>>Anyone have ideas on how I can change the Service-Type?
>>
>>
>>-
>>List info/subscribe/unsubscribe? See
>>http://www.freeradius.org/list/users.html
>>
>>--
>>Follow us on: twitter
>>https://www.twitter.com/manainternet<https://www.twitter.com/manainternet
>>>
>>- List info/subscribe/unsubscribe? See
>>http://www.freeradius.org/list/users.html
>>
>>-
>>List info/subscribe/unsubscribe? See
>>http://www.freeradius.org/list/users.html
>





More information about the Freeradius-Users mailing list