Module-Failure-Message goes in request, not in reply
[freeradius.git] / man / man5 / rlm_policy.5
1 .\"     # DS - begin display
2 .de DS
3 .RS
4 .nf
5 .sp
6 ..
7 .\"     # DE - end display
8 .de DE
9 .fi
10 .RE
11 .sp
12 ..
13 .TH rlm_policy 5 "7 December 2004" "" "FreeRADIUS Module"
14 .SH NAME
15 rlm_policy \- FreeRADIUS Module
16 .SH DESCRIPTION
17 The \fBrlm_policy\fP module implements a simple "policy" language.
18 .PP
19 The policy language implemented by this module is simple, and specific
20 to RADIUS.  It does not implement variables, arrays, loops, goto's, or
21 any other feature of a real language.  If those features are needed
22 for your system, we suggest using \fBrlm_perl\fP.
23 .PP
24 What the policy module implements is a simple way to look for
25 attributes in the request packet (or other places), and to add
26 attributes to the reply packet (or other places) based on those
27 decisions.  Where the module shines is that it is significantly more
28 flexible than the old-style \fBusers\fP file.
29 .PP
30 The module has one configuration item:
31 .IP filename
32 The file where the policy is stored.
33
34 .SH POLICY LANGUAGE
35 .SS Named policies
36 The policy is composed of a series of named policies.  The following
37 example defines a policy named "foo".
38 .PP
39 .DS
40         policy foo {
41 .br
42                 ...
43 .br
44         }
45 .DE
46 .PP
47 Policy names MAY NOT be the same as attributes in the dictionary.
48 Defining a policy with the same name as a dictionary attribute will
49 cause an error message to be printed, and the policy will not be
50 loaded.
51 .PP
52 When the policy module is listed in a module section like "authorize",
53 the module calls a policy named "authorize".  The "post-auth",
54 etc. sections behave the same.  These names cannot be changed.
55 .PP
56 .DS
57         include "policy.txt"
58 .DE
59 .PP
60 The filename must be in a double-quoted string, and is assumed to be
61 relative to the location of the current file.  If the filename ends
62 with a '/', then it is assumed to be a directory, and all files in
63 that directory will be read.
64 .PP
65 .DS
66         include "dir/"
67 .DE
68 .PP
69 All file in "dir/" will be read and included into the policy
70 definition.  Any dot files (".", "..", etc.) will not be included,
71 however.
72 .PP
73 .SS Including multiple files
74 The main file referred to from the \fIradiusd.conf\fP may include one
75 or more other files, as in the following example.
76 .PP
77 .SS Referencing a named policy
78 The following example references a named policy
79 .DS
80         foo()
81 .DE
82 While the brackets are required, no arguments may be passed.
83 .PP
84 .SS Conditions
85 "if" statements are supported.
86 .PP
87         if (expression) {
88 .br
89                 ...
90 .br
91         }
92 .DE
93 .PP
94 and "else"
95 .PP
96         if (expression) {
97 .br
98                 ...
99 .br
100         } else {
101 .br
102                 ...
103 .br
104         }
105 .DE
106 .PP
107 also, "else if"
108 .PP
109         if (expression) {
110 .br
111                 ...
112 .br
113         } else if (expression) {
114 .br
115                 ...
116 .br
117         }
118 .DE
119 .PP
120 .SS Expressions within "if" statements
121 Always have to have brackets around them.  Sorry.
122 .PP
123 The following kinds of expressions may be used, with their meanings.
124 .IP (attribute-reference)
125 TRUE if the referenced attribute exists, FALSE otherwise.  See below
126 for details on attribute references.
127 .IP (!(expression))
128 FALSE if the expression returned TRUE, and TRUE if the nested expression
129 returned FALSE.
130 .IP "(attribute-reference == value)"
131 Compares the attribute to the value.  The operators here can be "==",
132 "!=", "=~", "!~", "<", "<=", ">", and ">=".
133 .IP "(string1 == string2)"
134 A special case of the above.  The "string1" is dynamically expanded at
135 run time, while "string2" is not.  The operators here can be "==",
136 "!=", "=~",and "!~".  Of these, the most useful is "=~', which lets
137 you do things like ("%{ldap:query...}" =~ "foo=(.*) ").  The results
138 of the regular expression match are put into %{1}, and can be used
139 later.  See "doc/variables.txt" for more information.
140 .IP "((expression1) || (expression2))"
141 Short-circuit "or".  If expression1 is TRUE, expression2 is not
142 evaluated.
143 .IP "((expression1) && (expression2))"
144 Short-circuit "and".  If expression1 is FALSE, expression2 is not
145 evaluated.
146 .IP Limitations.
147 The && and || operators have equal precedence. You can't call a
148 function as a expression.
149 .PP
150 .PP
151 .SS Attribute references
152 Attribute references are:
153 .IP Attribute-Name
154 Refers to an attribute of that name in the Access-Request or
155 Accounting-Request packet.  May also refer to "server-side"
156 attributes, which are not documented anywhere.
157 .IP request:Attribute-Name
158 An alternate way of referencing an attribute in the request packet.
159 .PP
160 .IP reply:Attribute-Name
161 An attribute in the reply packet
162 .PP
163 .IP proxy-request:Attribute-Name
164 An attribute in the Access-Request or Accounting-Request packet which
165 will be proxied to the home server.
166 .PP
167 .IP proxy-reply:Attribute-Name
168 An attribute in the Access-Accept or other packet which was received
169 from a home server.
170 .PP
171 .IP control:Attribute-Name
172 An attribute in the per-request configuration and control attributes.
173 Also known as "check" attributes (doc/variables.txt).
174 .PP
175 .PP
176 .SS Adding attributes to reply packet (or other location)
177         reply .= {
178 .br
179                 attribute-name = value
180 .br
181                 ...
182 .br
183                 attribute-name = value
184 .br
185         }
186 .DE
187 .PP
188 The first name can be "request", "reply", "control", "proxy-request",
189 or "proxy-reply".
190 .PP
191 The operator can be
192 .PP
193  .= - appends attributes to end of the list
194 .PP
195  := - replaces existing list with the attributes in the list (bad idea)
196 .PP
197  = - use operators from "attribute = value" to decide what to do. (see "users")
198 .PP
199 The block must contain only attributes and values.  Nothing else is permitted.
200
201 .SH SECTIONS
202 .BR authorize
203 .BR post-auth
204 .BR pre-proxy
205 .BR post-proxy
206 .PP
207 .SH FILES
208 .I /etc/raddb/radiusd.conf
209 .PP
210 .SH "SEE ALSO"
211 .BR radiusd (8),
212 .BR users (5),
213 .BR radiusd.conf (5)
214 .SH AUTHOR
215 Alan DeKok <aland@ox.org>
216