Cisco-AVPair regex

Kylián Martin kylianm at plzen.eu
Fri Feb 23 16:32:58 CET 2018


> -----Original Message-----
> From: Freeradius-Users [mailto:freeradius-users-
> bounces+kylianm=plzen.eu at lists.freeradius.org] On Behalf Of Matthew
> Newton
> Sent: Friday, February 23, 2018 2:19 PM
> To: freeradius-users at lists.freeradius.org
> Subject: Re: Cisco-AVPair regex
> 
> On Fri, 2018-02-23 at 11:56 +0000, Kylián Martin wrote:
> > Here is the unlang snippet
> >
> > device_regex = '^(http-tlv=){1}([\\][0-9]{1,3}){1,5}(.*)$'
> >
> > regex_device_type {
> >         if (&Cisco-AVPair) {
> >                 foreach &Cisco-AVPair {
> >                         if ("%{string:%{Foreach-Variable-0}}" =~
> > /{policy.device_regex}/i) {
> 
> You're matching the text '{policy.device_regex}', not the defined
> string.
> 
> Use ${policy.device_regex}
> 
>   if ("%{string:%{Foreach-Variable-0}}" =~ /${policy.device_regex}/i) {
> 
You're right, thank you. That’s something I forgot to put back after some tries.
But still got the trouble while expanding the AVPs...

(12)   Cisco-AVPair = "dhcp-option=\000\014\000\003iP6"
(12)   Cisco-AVPair = "http-tlv=\000\001\000\031iPhone7,2/11.2.2 (15C202)"

(12)     policy regex_device_type {
(12)       if (&Cisco-AVPair) {
(12)       if (&Cisco-AVPair)  -> TRUE
(12)       if (&Cisco-AVPair)  {
(12)         foreach &Cisco-AVPair
(12)           if ("%{string:%{Foreach-Variable-0}}" =~ /^(http-tlv=){1}([\\][0-9]{1,3}){1,5}(.*)$/i) {
(12)           EXPAND Foreach-Variable-0
(12)              --> audit-session-id=1ef1a8c0000538f82e22905a
(12)           EXPAND %{string:%{Foreach-Variable-0}}
(12)              -->
(12)           if ("%{string:%{Foreach-Variable-0}}" =~ /^(http-tlv=){1}([\\][0-9]{1,3}){1,5}(.*)$/i)  -> FALSE
(12)           if ("%{string:%{Foreach-Variable-0}}" =~ /^(http-tlv=){1}([\\][0-9]{1,3}){1,5}(.*)$/i) {
(12)           EXPAND Foreach-Variable-0
(12)              --> dhcp-option=
(12)           EXPAND %{string:%{Foreach-Variable-0}}
(12)              -->
(12)           if ("%{string:%{Foreach-Variable-0}}" =~ /^(http-tlv=){1}([\\][0-9]{1,3}){1,5}(.*)$/i)  -> FALSE
(12)           if ("%{string:%{Foreach-Variable-0}}" =~ /^(http-tlv=){1}([\\][0-9]{1,3}){1,5}(.*)$/i) {
(12)           EXPAND Foreach-Variable-0
(12)              --> http-tlv=
(12)           EXPAND %{string:%{Foreach-Variable-0}}
(12)              -->
(12)           if ("%{string:%{Foreach-Variable-0}}" =~ /^(http-tlv=){1}([\\][0-9]{1,3}){1,5}(.*)$/i)  -> FALSE
(12)         } # foreach &Cisco-AVPair = updated
(12)       } # if (&Cisco-AVPair)  = updated
(12)     } # policy regex_device_type = updated

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



More information about the Freeradius-Users mailing list