⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unlang.5

📁 使用最广泛的radius的linux的源码
💻 5
📖 第 1 页 / 共 2 页
字号:
.\"     # DS - begin display.de DS.RS.nf.sp...\"     # DE - end display.de DE.fi.RE.sp...TH unlang 5 "16 Jan 2008" "" "FreeRADIUS Processing un-language".SH NAMEunlang \- FreeRADIUS Processing un\-language.SH DESCRIPTIONFreeRADIUS supports a simple processing language in its configurationfiles.  We call it an "un-language" because the intention is NOT tocreate yet another programming language.  If you need something morecomplicated than what is described here, we suggest using the Perl orPython modules rlm_perl, or rlm_python.The goal of the language is to allow simple policies to be writtenwith minimal effort.  Those policies are then applied when a requestis being processed..SH KEYWORDSThe keywords for the language are a combination of pre-definedkeywords, and references to loadable module names.  We document onlythe pre-defined keywords here.Subject to a few limitations described below, any keyword can appearin any context.  The language consists of a series of entries, eachone one line.  Each entry begins with a keyword.  Entries areorganized into lists.  Processing of the language is line by line,from the start of the list to the end.  Actions are executedper-keyword..IP module-nameA reference to the named module.  When processing reaches this point,the pre-compiled module is called.  The module may succeed or fail,and will return a status to "unlang" if so.  This status can be testedin a condition.  See the "Simple Conditions" text in the CONDITIONSsection, and MODULE RETURN CODES, below..DS	chap  # call the CHAP module.br	sql   # call the SQL module.br	....DE.IP if.brChecks for a particular condition.  If true, the block after thecondition is processed.  Otherwise, the block is ignored.  SeeCONDITIONS, below, for documentation on the format of the conditions..DS	if (condition) {.br		....br	}.DE.IP else.brDefine a block to be executed only if the previous "if" conditionreturned false..DS	else {.br		....br	}.DE.IP elsif.brDefine a block to be executed only if the previous "if" conditionreturned false, and if the specified condition evaluates to true..DS	elsif (condition) {.br		....br	}.DE.IP switch.brEvaluate the given string, and choose the first matching "case"statement inside of the current block.  If the string is surrounded bydouble quotes, it is expanded as described in the DATA TYPES section,below.No statement other than "case" can appear in a "switch" block..DS	switch "string" {.br		....br	}.DE.IP case.brDefine a static string to match a parent "switch" statement.  Thestrings given here are not expanded as is done with the parent"switch" statement.A "case" statement cannot appear outside of a "switch" block..DS	case string {.br		....br	}.DEA default entry can be defined by omitting the static string.  Thisentry will be used if no other "case" entry matches.  Only one defaultentry can exist in a "switch" section..DS	case {.br		....br	}.DE.IP update.brUpdate a particular attribute list, based on the attributes given inthe current block..DS	update <list> {.br		attribute = value.br		....br	}.DEThe <list> can be one of "request", "reply", "proxy-request","proxy-reply", or "control".  The "control" list is the list ofattributes maintainted internally by the server that controls how theserver processes the request.  Any attribute that does not go in apacket on the network will generally be placed in the "control" list.For backwards compatibility with older versions, "check" is acceptedas a synonym for "control".  The use of "check" is deprecated, andwill be removed in a future release.For EAP methods with tunneled authentication sessions (i.e. PEAP andEAP-TTLS), the inner tunnel session can also reference"outer.request", "outer.reply", and "outer.control".  Those referencesallow you to address the relevant list in the outer tunnel session.The only contents permitted in an "update" section are attributes andvalues.  The contents of the "update" section are described in theATTRIBUTES section below..IP redundantThis section contains a simple list of modules.  The first module iscalled when the section is being processed.  If the first modulesucceeds in its operation, then the server stops processing thesection, and returns to the parent section.If, however, the module fails, then the next module in the list istried, as described above.  The processing continues until one modulesucceeds, or until the list has been exhausted.Redundant sections can contain only a list of modules, and cannotcontain keywords that perform conditional operations (if, else, etc)or update an attribute list..DS	redundant {.br		sql1	# try this.br		sql2	# try this only if sql1 fails..br		....br	}.DE.IP load-balanceThis section contains a simple list of modules.  When the section isentered, one module is chosen at random to process the request.  Allof the modules in the list should be the same type (e.g. ldap or sql).All of the modules in the list should behave identically, otherwisethe load-balance section will return different results for the samerequest.Load-balance sections can contain only a list of modules, and cannotcontain keywords that perform conditional operations (if, else, etc)or update an attribute list..DS	load-balance {.br		ldap1	# 50% of requests go here.br		ldap2	# 50% of requests go here.br	}.DEIn general, we recommend using "redundant-load-balance" instead of"load-balance"..IP redundant-load-balanceThis section contains a simple list of modules.  When the section isentered, one module is chosen at random to process the request.  Ifthat module succeeds, then the server stops processing the section.If, however, the module fails, then one of the remaining modules ischosen at random to process the request.  This process repeats untilone module succeeds, or until the list has been exhausted.All of the modules in the list should be the same type (e.g. ldap orsql).  All of the modules in the list should behave identically,otherwise the load-balance section will return different results forthe same request.Load-balance sections can contain only a list of modules, and cannotcontain keywords that perform conditional operations (if, else, etc)or update an attribute list..DS	redundant-load-balance {.br		ldap1	# 50%, unless ldap2 is down, then 100%.br		ldap2	# 50%, unless ldap1 is down, then 100%.br	}.DE.SH CONDITIONSThe conditions are similar to C conditions in syntax, thoughquoted strings are supported, as with the Unix shell..IP Simpleconditions.br.DS	(foo).DEEvalutes to true if 'foo' is a non-empty string (single quotes, doublequotes, or back-quoted).  Also evaluates to true if 'foo' is anon-zero number.  Note that the language is poorly typed, so thestring "0000" can be interpreted as a numerical zero.  This issue canbe avoided by comparings strings to an empty string, rather than byevaluating the string by itself.If the word 'foo' is not a quoted string, then it can be taken as areference to a named attribute.  See "Referencing attribute lists",below, for examples of attribute references.  The condition evaluatesto true if the named attribute exists.Otherwise, if the word 'foo' is not a quoted string, and is not anattribute reference, then it is interpreted as a reference to a modulereturn code.  The condition evaluates to true if the most recentmodule return code matches the name given here.  Valid module returncodes are given in MODULE RETURN CODES, below..IP Negation.DS	(!foo).DEEvalutes to true if 'foo' evaluates to false, and vice-versa..PPShort-circuit operators.RS.br.DS	(foo || bar).br	(foo && bar).DE"&&" and "||" are short-circuit operators.  "&&" evaluates the firstcondition, and evaluates the second condition if and only if theresult of the first condition is true.  "||" is similar, but executesthe second command if and only if the result of the first condition isfalse..RE.IP Comparisons.DS	(foo == bar).DECompares 'foo' to 'bar', and evaluates to true if the comparison holdstrue.  Valid comparison operators are "==", "!=", "<", "<=", ">",">=", "=~", and "!~", all with their usual meanings.  Invalidcomparison operators are ":=" and "="..PPConditions may be nested to any depth, subject only to line lengthlimitations (8192 bytes)..SH DATA TYPESThere are only a few data types supported in the language.  Referenceto attributes, numbers, and strings.  Any data type can appear instand-alone condition, in which case they are evaluated as describedin "Simple conditions", above.  They can also appear (with someexceptions noted below) on the left-hand or on the right-hand side ofa comparison..IP NumbersNumbers are composed of decimal digits.  Floating point, hex, andoctal numbers are not supported.  The maximum value for a number ismachine-dependent, but is usually 32-bits, including one bit for asign value..PPword.RSText that is not enclosed in quotes is interpreted differentlydepending on where it occurs in a condition.  On the left hand side ofa condition, it is interpreted as a reference to an attribute.  On theright hand side, it is interpreted as a simple string, in the samemanner as a single-quoted string.Using attribute references permits limited type-specific comparisons,as seen in the examples below..DS

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -