📄 unlang.5
字号:
if (User-Name == "bob") {.br ....br if (Framed-IP-Address > 127.0.0.1) {.br ....br if (Service-Type == Login-User) { .DE.RE.IP "strings".RSDouble-quoted strings are expanded by inserting the value of anyvariables (see VARIABLES, below) before being evaluated. Ifthe result is a number it is evaluated in a numerical context.String length is limited by line-length, usually about 8000characters. A double quote character (") can be used in a string viathe normal back-slash escaping method. ("like \\"this\\" !").RE.IP 'strings'Single-quoted strings are evaluated as-is. Their values are notexpanded as with double-quoted strings above, and they are notinterpreted as attribute references..IP `strings`Back-quoted strings are evaluated by expanding the contents of thestring, as described above for double-quoted strings. The resultingcommand given inside of the string in a sub-shell, and taking theoutput as a string. This behavior is much the same as that of Unixshells.Note that for security reasons, the input string is split into commandand arguments before variable expansion is done.For performance reasons, we suggest that the use of back-quotedstrings be kept to a minimum. Executing external programs isrelatively expensive, and executing a large number of programs forevery request can quickly use all of the CPU time in a server. If youbelieve that you need to execute many programs, we suggest findingalternative ways to achieve the same result. In some cases, using areal language may be sufficient..IP /regex/iThese strings are valid only on the right-hand side of a comparison,and then only when the comparison operator is "=~" or "!~". They areregular expressions, as implemented by the local regular expressionlibrary on the system. This is usually Posix regular expressions.The trailing 'i' is optional, and indicates that the regularexpression match should be done in a case-insensitive fashion.If the comparison operator is "=~", then parantheses in the regularexpression will define variables containing the matching text, asdescribed below in the VARIABLES section..SH VARIABLESRun-time variables are referenced using the following syntax.DS %{Variable-Name}.DENote that unlike C, there is no way to declare variables, or to referto them outside of a string context. All references to variables MUSTbe contained inside of a double-quoted or back-quoted string.Many potential variables are defined in the dictionaries thataccompany the server. These definitions define only the name andtype, and do not define the value of the variable. When the serverreceives a packet, it uses the packet contents to look up entries inthe dictionary, and instantiates variables with a name taken from thedictionaries, and a value taken from the packet contents. Thisprocess means that if a variable does not exist, it is usually becauseit was not mentioned in a packet that the server received.Once the variable is instantiated, it is added to an appropriateattribute list, as described below. In many cases, attributes andvariables are inter-changeble, and are often talked about that way.However, variables can also refer to run-time calls to modules, whichmay perform operations like SQL SELECTs, and which may return theresult as the value of the variable..PPReferencing attribute lists.RSAttribute lists may be referenced via the following syntax.DS %{<list>:Attribute-Name}.DEWhere <list> is one of "request", "reply", "control", "proxy-request","proxy-reply", or "outer.request", "outer.reply", "outer.control","outer.proxy-request", or "outer.proxy-reply". just as with the"update" section, above. The "<list>:" prefix is optional, and ifomitted, is assumed to refer to the "request" list.When a variable is encountered, the given list is examined for anattribute of the given name. If found, the variable reference in thestring is replaced with the value of that attribute. Some examples are:.DS %{User-Name}.br %{request:User-Name} # same as above.br %{reply:User-Name}.br %{outer.reqest:User-Name} # from inside of a TTLS/PEAP tunnel.DE.RE.PPResults of regular expression matches.RSIf a regular expression match has previously been performed, then thespecial variable %{0} will contain a copy of the input string. Thevariables %{1} through %{8} will contain the substring matches,starting from the left-most parantheses, and onwards. If there aremore than 8 parantheses, the additional results will not be placedinto any variables..RE.PPObtaining results from databases.RSIt is useful to query a database for some information, and to use theresult in a condition. The following syntax will call a module, passit the given string, and replace the variable reference with theresulting string returned from the module..DS %{module: string ...}.DEThe syntax of the string is module-specific. Please read the moduledocumentation for additional details..RE.PPConditional Syntax.RSConditional syntax similar to that used in Unix shells may also beused..IP %{%{Foo}:-bar}If %{Foo} has a value, returns that value..brOtherwise, returns literal string "bar"..IP %{%{Foo}:-%{Bar}}If %{Foo} has a value, returns that value..brOtherwise, returns the expansion of %{Bar}.These conditional expansions can be nested to almost any depth, suchas with %{%{One}:-%{%{Two}:-%{Three}}}.RE.PPString lengths and arrays.RSSimilar to a Unix shell, there are ways to reference string lenths,and the second or more instance of an attribute in a list. If youneed this functionality, we recommend using a real language..IP %{#string}The number of characters in %{string}. If %{string} is notset, then the length is not set.e.g. %{#Junk-junk:-foo} will yeild the string "foo"..IP %{Attribute-Name[index]}Reference the N'th occurance of the given attribute. The syntax%{<list>:Attribute-Name[index]} may also be used. The indexes startat zero. This feature is NOT available for non-attribute dynamictranslations, like %{sql:...}.For example, %{User-Name[0]} is the same as %{User-Name}The variable %{Cisco-AVPair[2]} will reference the value of theTHIRD Cisco-AVPair attribute (if it exists) in the request packet,.IP %{Attribute-Name[#]}Returns the total number of attributes of that name in the relevantattribute list. The number will usually be between 0 and 200.For most requests, %{request:User-Name[#]} == 1.IP %{Attribute-Name[*]}Expands to a single string, with the value of each arraymember separated by a newline..IP %{#Attribute-Name[index]}Expands to the length of the string %{Attribute-Name[index]}..SH ATTRIBUTESThe attribute lists described above may be edited by listing one ormore attributes in an "update" section. Once the attributes have beendefined, they may be referenced as described above in the VARIABLESsection.The following syntax defines attributes in an "update" section. Eachattribute and value has to be all on one line in the configurationfile. There is no need for commas or semi-colons after the value..DS Attribute-Name = value.DE.PPAttribute names.RSThe Attribute-Name must be a name previously defined in a dictionary.If an undefined name is used, the server will return an error, andwill not start..RE.IP OperatorsThe operator used to assign the value of the attribute may be one ofthe following, with the given meaning..RS.IP =Add the attribute to the list, if and only if an attribute of the samename is already present in that list..IP := Add the attribute to the list. If any attribute of the same name isalready present in that list, its value is replaced with the value ofthe current attribute..IP +=Add the attribute to the tail of the list, even if attributes of thesame name are already present in the list..RE.PPEnforcement and Filtering Operators.RSThe following operators may also be used in addition to the oneslisted above. Their function is to perform enforcement or filteringon attributes in a list..IP -=Remove all matching attributes from the list. Both the attribute nameand value have to match in order for the attribute to be removed fromthe list..IP ==Remove all non-matching attributes from the list. Both the attributename and value have to match in order for the attribute to remain inthe list.Note that this operator is very different than the '=' operator listedabove!.IP <=Enforce that the integer value of the attribute is less than or equalto the value given here. If there is no attribute of the same name inthe list, the attribute is added with the given value, is with "+=".If an attribute in the list exists, and has value less than givenhere, it's value is unchanged. If an attribute in the list exists,and has a value greater than given here, then that value is replacedwith the one given here.This operator is valid only for attributes of integer type..IP >=Enforce that the integer value of the attribute is greater than orequal to the value given here. If there is no attribute of the samename in the list, the attribute is added with the given value, is with"+=". If an attribute in the list exists, and has value greater thangiven here, it's value is unchanged. If an attribute in the listexists, and has value less than given here, then that value isreplaced with the one given here.This operator is valid only for attributes of integer type..RE.IP Values.brThe format of the value is attribute-specific, and is usually astring, integer, IP address, etc. Prior to the attribute beinginstantiated, the value may be expanded as described above in the DATATYPES section, above. This flexibility means that, for example, youcan assign an IP address value to an attribute by specifying the IPaddress directly, or by having the address returned from a databasequery, or by having the address returned as the output of a programthat is executed.When string values are finally assigned to a variable, they can have amaximum length of 253 characters. This limit is due in part to bothprotocol and internal server requirements. That is, the strings inthe language can be nearly 8k in length, say for a long SQL query.However, the output of that SQL query should be no more than 253characters in length..SH OTHER KEYWORDSOther keywords in the language are taken from the names of modulesloaded by the server. These keywords are dependent on both themodules, and the local configuration.Some use keywords that are defined in the default configuration fileare:.IP failCause the request to be treated as if a database failure had occurred..IP noopDo nothing. This also serves as an instruction to the configurablefailover tracking that nothing was done in the current section..IP okInstructs the server that the request was processed properly. Thiskeyword can be used to over-ride earlier failures, if the localadministrator determines that the faiures are not catastrophic..IP rejectCauses the request to be immediately rejected.SH MODULE RETURN CODESWhen a module is called, it returns one of the following codes to"unlang", with the following meaning..DS notfound information was not found.br noop the module did nothing.br ok the module succeeded.br updated the module updated the request.br fail the module failed.br reject the module rejected the request.br userlock the user was locked out.br invalid the configuration was invalid.br handled the module has handled the request itself.DEThese return codes can be tested for in a condition, as describedabove in the CONDITIONS section..SH FILES/etc/raddb/radiusd.conf.SH "SEE ALSO".BR radiusd.conf (5),.BR dictionary (5).SH AUTHORAlan DeKok <aland@deployingradius.com>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -