Matching a prefix in huntgroups file

Brian Candler b.candler at pobox.com
Fri Nov 11 15:37:17 CET 2016


On 11/11/2016 13:42, Alan DeKok wrote:
>    How do you know that a particular string is a host name,*before*  it's parsed?

You don't. That is: I don't think the *parser* needs to decide whether a 
string is a hostname or not!

A concrete example:

     Framed-IP-Address := foo.example.com     # let's say this is 
DISALLOWED.

     Framed-IP-Address := "foo.example.com"   # allowed. RHS has type 
'string'.

The question is then not one of parsing, but of assignment semantics. If 
the LHS has type "ipaddr", and the RHS has type "string", then the 
string is converted into an ipaddr via hostname resolution. This is 
unconditional: you don't have to inspect the string to decide whether it 
looks like a hostname or not.

I personally don't mind the implicit cast from string to ipaddr (*), but 
you could instead require it to be explicit:

     Framed-IP-Address := <ipaddr>"foo.example.com"

If the RHS is a constant string literal then this could still be 
resolved at parse/compile time. But the potential is also there to do 
late resolution: e.g.

     Framed-IP-Address := <ipaddr>"%{User-Name}.example.com"

Regards,

Brian.

(*) It's not really any different to the current FR behaviour, which 
allows these implicitly:

     Framed-IP-Address := foo.example.com   # treated as hostname, 
resolved to IP
     Reply-Message := foo.example.com   # treated as string
     Framed-IP-Address += 1.2.3.4    # IP
     Reply-Message += 1.2.3.4    # string


More information about the Freeradius-Users mailing list