From: Alan T. DeKok Date: Tue, 16 Aug 2022 21:31:00 +0000 (-0400) Subject: we don't need to mash everything to strings. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d227175ad3cf99db16180abf6e93db48220c591;p=thirdparty%2Ffreeradius-server.git we don't need to mash everything to strings. v4 supports bare %{foo...} which is better than "%{foo...}" --- diff --git a/raddb/policy.d/accounting b/raddb/policy.d/accounting index dd721539619..340f03d7167 100644 --- a/raddb/policy.d/accounting +++ b/raddb/policy.d/accounting @@ -82,16 +82,16 @@ insert_acct_class { # acct_counters64.preacct { if (!&Acct-Input-Gigawords) { - &request.Acct-Input-Octets64 := "%{%{Acct-Input-Octets}:-0}" + &request.Acct-Input-Octets64 := %{%{Acct-Input-Octets}:-0} } else { - &request.Acct-Input-Octets64 = "%{expr:(&Acct-Input-Gigawords << 32) | &Acct-Input-Octets}" + &request.Acct-Input-Octets64 = %{expr:(&Acct-Input-Gigawords << 32) | &Acct-Input-Octets} } if (!&Acct-Output-Gigawords) { - &request.Acct-Output-Octets64 := "%{%{Acct-Output-Octets}:-0}" + &request.Acct-Output-Octets64 := %{%{Acct-Output-Octets}:-0} } else { - &request.Acct-Output-Octets64 = "%{expr:(&Acct-Output-Gigawords << 32) | &Acct-Output-Octets}" + &request.Acct-Output-Octets64 = %{expr:(&Acct-Output-Gigawords << 32) | &Acct-Output-Octets} } } diff --git a/raddb/policy.d/canonicalisation b/raddb/policy.d/canonicalisation index 9d42a006312..1ddf324d648 100644 --- a/raddb/policy.d/canonicalisation +++ b/raddb/policy.d/canonicalisation @@ -18,14 +18,14 @@ nai_regexp = '^([^@]*)(@([-[:alnum:]]+\.[-[:alnum:].]+))?$' split_username_nai { if (&User-Name && (&User-Name =~ /${policy.nai_regexp}/)) { - &request.Stripped-User-Name := "%{1}" + &request.Stripped-User-Name := %{1} # Only add the Stripped-User-Domain attribute if # we have a domain. This means presence checks # for Stripped-User-Domain work. - if ("%{3}" != '') { - &request.Stripped-User-Domain = "%{3}" + if (%{3} != '') { + &request.Stripped-User-Domain = %{3} } # If any of the expansions result in a null @@ -52,11 +52,11 @@ mac-addr-regexp = '([0-9a-f]{2})[^0-9a-f]?([0-9a-f]{2})[^0-9a-f]?([0-9a-f]{2})[^ # rewrite_called_station_id { if (&Called-Station-Id && (&Called-Station-Id =~ /^${policy.mac-addr-regexp}([^0-9a-f](.+))?$/i)) { - &request.Called-Station-Id := "%{toupper:%{1}-%{2}-%{3}-%{4}-%{5}-%{6}}" + &request.Called-Station-Id := %{toupper:%{1}-%{2}-%{3}-%{4}-%{5}-%{6}} # SSID component? - if ("%{8}") { - &request.Called-Station-SSID := "%{8}" + if (%{8}) { + &request.Called-Station-SSID := %{8} } updated } @@ -74,7 +74,7 @@ rewrite_called_station_id { # rewrite_calling_station_id { if (&Calling-Station-Id && (&Calling-Station-Id =~ /^${policy.mac-addr-regexp}$/i)) { - &request.Calling-Station-Id := "%{toupper:%{1}-%{2}-%{3}-%{4}-%{5}-%{6}}" + &request.Calling-Station-Id := %{toupper:%{1}-%{2}-%{3}-%{4}-%{5}-%{6}} updated } diff --git a/raddb/policy.d/filter b/raddb/policy.d/filter index b5733e06bec..f160a902308 100644 --- a/raddb/policy.d/filter +++ b/raddb/policy.d/filter @@ -37,7 +37,7 @@ filter_username { # # reject mixed case e.g. "UseRNaMe" # - #if (&User-Name != "%{tolower:%{User-Name}}") { + #if (&User-Name != %{tolower:%{User-Name}}) { # reject #} @@ -148,7 +148,7 @@ filter_inner_identity { # Get the outer realm. # if (&outer.request.User-Name =~ /@([^@]+)$/) { - &request.Outer-Realm-Name = "%{1}" + &request.Outer-Realm-Name = %{1} # # When we have an outer realm name, the user portion @@ -183,7 +183,7 @@ filter_inner_identity { # Get the inner realm. # if (&User-Name =~ /@([^@]+)$/) { - &request.Inner-Realm-Name = "%{1}" + &request.Inner-Realm-Name = %{1} # # Note that we do EQUALITY checks for realm names. diff --git a/raddb/policy.d/time b/raddb/policy.d/time index f9dd0e50781..93847874db2 100644 --- a/raddb/policy.d/time +++ b/raddb/policy.d/time @@ -20,7 +20,7 @@ expiration { disallow } - elsif (!&reply.Session-Timeout || (&Session-Timeout > "%{expr:%{Expiration} - %l}")) { + elsif (!&reply.Session-Timeout || (&Session-Timeout > %{expr:%{Expiration} - %l})) { &reply.Session-Timeout := %{expr:%{Expiration} - %l} } }