Modifying incoming packets with unlang
David le Roux
david.leroux at miller.co.uk
Mon Mar 28 11:10:45 UTC 2022
Thank you, I wouldn't have got that far in a very long time!
David le Roux
-----Original Message-----
From: Freeradius-Users <freeradius-users-bounces+david.leroux=miller.co.uk at lists.freeradius.org> On Behalf Of Matthew Newton
Sent: 28 March 2022 11:53
To: freeradius-users at lists.freeradius.org
Subject: Re: Modifying incoming packets with unlang
On 28/03/2022 10:49, David le Roux wrote:
> I am migrating from an old raddb instance and one of the changes is that freeradius no longer uses the attr_rewrite module and instead relies on unlang.
> attr_rewrite copyusertocertcn {
> attribute = Cert-CN
> new_attribute = yes
> searchfor = ""
> searchin = packet
> replacewith = "%{User-Name}"
update request {
&Cert-CN := &User-Name
}
> attr_rewrite removehostportion {
> attribute = Cert-CN
> searchin = packet
> searchfor = "(host/)(.*)"
> replacewith = "%{2}"
> ignore_case = no
> new_attribute = no
> }
if (&Cert-CN =~ /^host\/(.*)$/) {
update request {
&Cert-CN := "%{1}"
}
}
Or, possibly better all in one depending on your needs, something like
if (&User-Name =~ /^host\/(.*)$/) {
update request {
&Cert-CN := "%{1}"
}
}
(which will leave Cert-CN unset if User-Name doesn't start with "host/")
--
Matthew
-
List info/subscribe/unsubscribe? See https://gbr01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.freeradius.org%2Flist%2Fusers.html&data=04%7C01%7Cdavid.leroux%40miller.co.uk%7C1fa9c163c06a469c84ae08da10a93d8f%7Ca5609eb2409545a8bb4668573bbb0f92%7C1%7C0%7C637840616310423601%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=S8VjW103iqu9RpU245YN0LLtlzmu0oGlRgY3E4SuASY%3D&reserved=0
________________________________
Miller Homes Limited Registered in Scotland - SC255429
2 Lochside View, Edinburgh Park, Edinburgh, EH12 9DH
Disclaimer: The Information in this e-mail is confidential and for use by the addressee(s) only. It may also be privileged. If you are not the intended recipient please notify us immediately on +44 (0) 870 336 5000 and delete the message from your computer: you may not copy or forward it, or use or disclose its contents to any other person. We do not accept any liability or responsibility for: (1) changes made to this email after it was sent, or (2) viruses transmitted through this email or any attachment.
Miller Homes Limited <https://www.millerhomes.co.uk>
More information about the Freeradius-Users
mailing list