small problem with unlang (2.0.4)
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
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 | 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) Every condidtion should be in its own brace pair: ~ if (\ ~ (( "%{expr: %{1} * 16777216 + %{2} * ~ 65536 + %{3} * 256 + %{4}}" >= 3417153537) && (\ ~ "%{expr: %{1} * 16777216 + %{2} * ~ 65536 + %{3} * 256 + %{4}}" <= 3417153790 )) \ ~ ) { Just a guess though, I'm not a pro in unlang myself (yet). Stefan -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn0 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iD8DBQFIIUCH+jm90f8eFWYRAquLAJ9Me8cySNvUAu4OmH3joThdagJdGgCdFFpA 238vUXkqpk1YDbPCob0Xa4w= =RtWc -----END PGP SIGNATURE-----
Thank you :-) brackets did the trick :-) kind regards Pshem 2008/5/7 Stefan Winter <stefan.winter@restena.lu>:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
| 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)
Every condidtion should be in its own brace pair:
~ if (\
~ (( "%{expr: %{1} * 16777216 + %{2} * ~ 65536 + %{3} * 256 + %{4}}" >= 3417153537) && (\ ~ "%{expr: %{1} * 16777216 + %{2} * ~ 65536 + %{3} * 256 + %{4}}" <= 3417153790 )) \ ~ ) {
Just a guess though, I'm not a pro in unlang myself (yet).
Stefan -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn0 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iD8DBQFIIUCH+jm90f8eFWYRAquLAJ9Me8cySNvUAu4OmH3joThdagJdGgCdFFpA 238vUXkqpk1YDbPCob0Xa4w= =RtWc -----END PGP SIGNATURE----- - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
participants (2)
-
Pshem Kowalczyk -
Stefan Winter