How to set multiple reply values via a single SQL query?

Arran Cudbard-Bell a.cudbardb at freeradius.org
Tue Mar 3 22:27:21 CET 2015


> On 3 Mar 2015, at 15:52, Alan DeKok <aland at deployingradius.com> wrote:
> 
> On Mar 3, 2015, at 3:41 PM, James Wood <james.wood at purplewifi.com> wrote:
>> How can I split this in the FreeRadius conf in to the three separate variables using # as the delimiter?
> 
>  Regular expressions.  Put the data into a temporary attribute:
> 
> 	update control {
> 		Tmp-String-0 := “”"
> 	}
> 
> 	if (Tmp-String-0 =~ /^([^#]+)#([^#]+)([^#]+)/) {
> 		update reply {
> 			Session-Timeout := “%{1}”
> 			Idle-Timeout := “%{2}”
> 			Filter-Id := “%{3}"
> 		}
> 	}
> 
>  That should work…

or

update control {
	Tmp-String-0 := "%{sql:SELECT CONCAT(`Session-Timeout`, '#', `Idle-Timeout`, '#', `Filter-Id`) FROM settings…}"
}
if ("%{explode:&control:Tmp-String-0 #}" > 0) {
	update reply {
		Session-Timeout := &control:Tmp-String-0[0]
		Idle-Timeout := &control:Tmp-String-0[1]
		Filter-Id := &control:Tmp-String-0[2]
	}
}

or

update control {
	Tmp-String-0 := "%{sql:SELECT CONCAT('Session-Timeout=',`Session-Timeout`, '#Idle-Timeout=', `Idle-Timeout`, '#Filter-Id=', `Filter-Id`) FROM settings…}"
}
if ("%{explode:&control:Tmp-String-0 #}" > 0) {
	foreach &control:Tmp-String-0 {
		if ("%{Foreach-Variable-0}" =~ /^([^=]+)=(.*)$/) {
			update reply {
				"%{1}" := "%{2}"
			}
		}
	}
}

above examples are 3.0.7 only.

We really need to sort those mapping sections out.

Arran Cudbard-Bell <a.cudbardb at freeradius.org>
FreeRADIUS development team

FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 872 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20150303/942b9315/attachment.sig>


More information about the Freeradius-Users mailing list