Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

amend policy insert_acct_class/acct_unique to work with multiple Class attributes #5337

Open
wants to merge 1 commit into
base: v3.2.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions raddb/policy.d/accounting
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class_value_prefix = 'ai:'
acct_unique {
#
# If we have a class attribute in the format
# 'auth_id:[0-9a-f]{32}' it'll have a local value
# 'ai:[0-9a-f]{32}' it'll have a local value
# (defined by insert_acct_class), this ensures
# uniqueness and suitability.
#
Expand All @@ -33,13 +33,19 @@ acct_unique {
# wireless environment).
#
update request {
&Tmp-String-9 := "${policy.class_value_prefix}"
&Tmp-String-9 := "${policy.class_value_prefix}"
}

if (("%{hex:&Class}" =~ /^%{hex:&Tmp-String-9}/) && \
("%{string:&Class}" =~ /^${policy.class_value_prefix}([0-9a-f]{32})/i)) {
# 64 length match is to maintain backwards compatible with original policy (prior to 3.2.5) that double hex encoded
if (&Class[*] =~ /^0x%{hex:&Tmp-String-9}([0-9a-f]{32}|[0-9a-f]{64})$/) {
update request {
&Acct-Unique-Session-Id := "%{md5:%{1},%{Acct-Session-ID}}"
&Tmp-Octets-9 = "0x%{1}"
}
update request {
&Acct-Unique-Session-Id := "%{md5:%{string:&Tmp-Octets-9},%{Acct-Session-ID}}"
}
update request {
&Tmp-Octets-9 !* ANY
}
}

Expand All @@ -64,8 +70,17 @@ acct_unique {
# Insert a (hopefully unique) value into class
#
insert_acct_class {
update request {
&Tmp-String-9 := "${policy.class_value_prefix}"
}

# if your NAS supports returning multiple Class attributes you may wish to change the '=' to a '+='
update reply {
&Class = "${policy.class_value_prefix}%{md5:%t,%{Packet-Src-Port},%{%{Packet-Src-IP-Address}:-%{Packet-Src-IPv6-Address}},%{NAS-IP-Address},%{Calling-Station-ID},%{User-Name},%{session-state:User-Name} }"
&Class = "0x%{hex:&Tmp-String-9}%{md5:%t,%{Packet-Src-Port},%{%{Packet-Src-IP-Address}:-%{Packet-Src-IPv6-Address}},%{NAS-IP-Address},%{Calling-Station-ID},%{User-Name},%{session-state:User-Name}}"
}

update request {
&Tmp-String-9 !* ANY
}
}

Expand Down
Loading