Update to variable documentation to reflect recent additions
[freeradius.git] / doc / variables.txt
1 The variables defined by the server are:
2
3      %{Attribute-Name}               Corresponding value for Attribute-Name
4                                      in the request packet
5      %{request:Attribute-Name}       Corresponding value for Attribute-Name
6                                      in the request packet
7      %{reply:Attribute-Name}         Corresponding value for Attribute-Name
8                                      in the reply packet
9      %{proxy-request:Attribute-Name} Corresponding value for Attribute-Name
10                                      in the proxy request packet (if it exists)
11      %{proxy-reply:Attribute-Name}   Corresponding value for Attribute-Name
12                                      in the proxy reply packet (if it exists)
13
14   The above support the meta-Attribute Packet-Type as well. See the RADIUS
15 dictionary for details.
16          
17      %{check:Attribute-Name}         Corresponding value for Attribute-Name
18                                      in check items for request
19         
20
21      %{config:section.subsection.item} Corresponding value in 'radiusd.conf'
22                                        for the string value of that item.
23
24   The %{config:...} variables should be used VERY carefully, as they
25 may leak secret information from your RADIUS server, if you use them
26 in reply attributes to the NAS!
27
28   e.g.
29
30   %{User-Name}                   The string value of the User-Name attribute.
31   %{proxy-reply:Framed-Protocol} The string value of the Framed-Protocol
32                                  attribute, from the proxy reply.
33   %{config:modules.unix.passwd}  The string value of the 'passwd' configuration
34                                  item in the 'unix' module, in the 'modules'
35                                  section of radiusd.conf.
36
37 Variables are used in dynamically translated strings.  Most of the
38 configuration entries in radiusd.conf (and related files) will do
39 dynamic string translation.  To do the same dynamic translation in
40 RADIUS attributes, you must put the string into an back-quoted string:
41
42        Session-Timeout = `%{expr: 2 + 3}`
43
44 To do the dynamic translation in the 'radiusd.conf' (or some other
45 configuration files), just use the variable as-is.  See 'radiusd.conf'
46 for examples.
47
48
49 Additionally, you can use conditional syntax similar to ${foo:-bar} as
50 defined in 'sh'.  For example:
51
52   1.  %{Foo:-bar}
53     When attribute Foo is set:  returns value of Foo
54     When attribute Foo unset:   returns literal string 'bar'
55
56   2.  %{Foo:-%{Bar}}
57     When attribute Foo is set:  returns value of attribute Foo
58     When attribute Foo unset:   returns value of attribute Bar (if any)
59
60   3.  %{Foo:-%{bar:-baz}}
61     When attribute Foo is set:  returns value of attribute Foo
62     When attribute Foo unset:   returns value of attribute Bar (if any)
63     When attribute Bar unset:   returns literal string 'baz'
64
65
66 When calling an external program (e.g. from Exec-Program-Wait), these
67 variables can be passed on the command line to the program.  In
68 addition, the server places all of the attributes in the RADIUS
69 request into environment variables for the external program.  The
70 variables are renamed under the following rules:
71
72   1.  All letters are made upper-case.
73
74   2.  All hyphens '-' are turned into underscores '_'
75
76 so the attribute User-Name can be passed on the command line to the
77 program as %{User-Name}, or used inside the program as the environment
78 variable USER_NAME (or $USER_NAME for shell scripts).
79
80 If you want to see the list of all of the variables, try adding a line
81 'printenv > /tmp/exec-program-wait' to the script.  Then look in the
82 file for a complete list of variables.
83
84 The following one-character variables are also defined.  However, they
85 are duplicates of the previous general cases, and are only provided
86 for backwards compatibility.  They WILL BE removed in a future
87 release.  They also do NOT permit the use of conditional syntax
88 (':-'), as described above.
89
90
91     Variable  Description                 Proper Equivalent
92     --------  -----------                 ----------------
93      %a       Protocol (SLIP/PPP)         %{Framed-Protocol}
94      %c       Callback-Number             %{Callback-Number}
95      %d       request day (DD)
96      %f       Framed IP address           %{Framed-IP-Address}
97      %i       Calling Station ID          %{Calling-Station-Id}
98      %l       request timestamp
99      %m       request month (MM)
100      %n       NAS IP address              %{NAS-IP-Address}
101      %p       Port number                 %{NAS-Port-Id}
102      %s       Speed (PW_CONNECT_INFO)     %{Connect-Info}
103      %t       request in ctime format
104      %u       User name                   %{User-Name}
105      %A       radacct_dir                 %{config:radacctdir}
106      %C       clientname
107      %D       request date (YYYYMMDD)
108      %H       request hour
109      %L       radlog_dir                  %{config:logdir}
110      %M       MTU                         %{Framed-MTU}
111      %R       radius_dir                  %{config:raddbdir}
112      %S       request timestamp
113                 in SQL format
114      %T       request timestamp
115                 in database format
116      %U       Stripped User name          %{Stripped-User-Name}
117      %V       Request-Authenticator
118                 (Verified/None)
119      %Y       request year (YYYY)
120      %Z       All request attributes
121                except password
122                (must have a big buffer)