small problem with unlang (2.0.4)

Pshem Kowalczyk pshem.k at gmail.com
Wed May 7 07:07:52 CEST 2008


Hi,

I have the following entry in the config (post-proxy section on our
proxy server)
                if ("%{proxy-reply:Framed-IP-Address}" =~
/([0-9]+).([0-9]+).([0-9]+).([0-9]+)/){
                        if (\
                                ( "%{expr: %{1} * 16777216 + %{2} *
65536 + %{3} * 256 + %{4}}" >= 3417153537  &&  \
                                "%{expr: %{1} * 16777216 + %{2} *
65536 + %{3} * 256 + %{4}}" <= 3417153790  ) \
                        ) {
                        update reply {
                                Reply-Message := "IP in range"
                                }
                        }
                        else {
                                update reply {
                                        Reply-Message := "IP not in range"
                                }
                                attr_filter.strip-ip
                        }


During debugging I've noticed that the condition is always met, even
though it shouldn't (ip in question 103.109.246.254)

++++? if ("%{proxy-reply:Framed-IP-Address}" =~
/([0-9]+).([0-9]+).([0-9]+).([0-9]+)/)
        expand: %{proxy-reply:Framed-IP-Address} -> 103.109.246.254
? Evaluating ("%{proxy-reply:Framed-IP-Address}" =~
/([0-9]+).([0-9]+).([0-9]+).([0-9]+)/) -> TRUE
++++? if ("%{proxy-reply:Framed-IP-Address}" =~
/([0-9]+).([0-9]+).([0-9]+).([0-9]+)/) -> TRUE
++++- entering if ("%{proxy-reply:Framed-IP-Address}" =~
/([0-9]+).([0-9]+).([0-9]+).([0-9]+)/)
+++++? if (( "%{expr: %{1} * 16777216 + %{2} * 65536 + %{3} * 256 +
%{4}}" >= 3417153537  &&                            "%{expr: %{1} *
16777216 + %{2} * 65536 + %{3} * 256 + %{4}}" <= 3417153790  )
         )
        expand:  %{1} * 16777216 + %{2} * 65536 + %{3} * 256 + %{4} ->
 103 * 16777216 + 109 * 65536 + 246 * 256 + 254
        expand: %{expr: %{1} * 16777216 + %{2} * 65536 + %{3} * 256 +
%{4}} -> 1828779774
?? Evaluating ("%{expr: %{1} * 16777216 + %{2} * 65536 + %{3} * 256 +
%{4}}" >= 3417153537  ) -> FALSE
? Skipping ("%{expr: %{1} * 16777216 + %{2} * 65536 + %{3} * 256 +
%{4}}" <= 3417153790  )
+++++? if (( "%{expr: %{1} * 16777216 + %{2} * 65536 + %{3} * 256 +
%{4}}" >= 3417153537  &&                            "%{expr: %{1} *
16777216 + %{2} * 65536 + %{3} * 256 + %{4}}" <= 3417153790  )
         ) -> TRUE
+++++- entering if (( "%{expr: %{1} * 16777216 + %{2} * 65536 + %{3} *
256 + %{4}}" >= 3417153537  &&                           "%{expr: %{1}
* 16777216 + %{2} * 65536 + %{3} * 256 + %{4}}" <= 3417153790  )
           )
++++++[reply] returns updated


As you can see the first part of the check evaluates to FALSE and
freeradius skips the second part, but surprisingly the whole
expression evaluates to TRUE.
Have I written the condition incorrectly or is it an actual bug?

kind regards
Pshem



More information about the Freeradius-Users mailing list