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