Subversion Repositories ALCASAR

Rev

Rev 2476 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2476 Rev 2706
1
# -*- text -*-
1
# -*- text -*-
2
##
2
##
3
## query.conf -- MySQL configuration for default schema (schema.sql)
3
## query.conf -- MySQL configuration for default schema (schema.sql)
4
##
4
##
5
 
5
 
6
	# Safe characters list for sql queries. Everything else is replaced
6
	# Safe characters list for sql queries. Everything else is replaced
7
	# with their mime-encoded equivalents.
7
	# with their mime-encoded equivalents.
8
	# The default list should be ok (define in 'expr' module
8
	# The default list should be ok (define in 'expr' module
9
	#safe-characters = "@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_: /"
9
	#safe-characters = "@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_: /"
10
 
10
 
11
	#######################################################################
11
	#######################################################################
12
	#  Query config:  Username
12
	#  Query config:  Username
13
	#######################################################################
13
	#######################################################################
14
	# This is the username that will get substituted, escaped, and added
14
	# This is the username that will get substituted, escaped, and added
15
	# as attribute 'SQL-User-Name'.  '%{SQL-User-Name}' should be used below
15
	# as attribute 'SQL-User-Name'.  '%{SQL-User-Name}' should be used below
16
	# everywhere a username substitution is needed so you you can be sure
16
	# everywhere a username substitution is needed so you you can be sure
17
	# the username passed from the client is escaped properly.
17
	# the username passed from the client is escaped properly.
18
	#
18
	#
19
	#  Uncomment the next line, if you want the sql_user_name to mean:
19
	#  Uncomment the next line, if you want the sql_user_name to mean:
20
	#
20
	#
21
	#    Use Stripped-User-Name, if it's there.
21
	#    Use Stripped-User-Name, if it's there.
22
	#    Else use User-Name, if it's there,
22
	#    Else use User-Name, if it's there,
23
	#    Else use hard-coded string "DEFAULT" as the user name.
23
	#    Else use hard-coded string "DEFAULT" as the user name.
24
	#sql_user_name = "%{%{Stripped-User-Name}:-%{%{User-Name}:-DEFAULT}}"
24
	#sql_user_name = "%{%{Stripped-User-Name}:-%{%{User-Name}:-DEFAULT}}"
25
	#
25
	#
26
	sql_user_name = "%{User-Name}"
26
	sql_user_name = "%{User-Name}"
27
 
27
 
28
	#######################################################################
28
	#######################################################################
29
	#  Default profile
29
	#  Default profile
30
	#######################################################################
30
	#######################################################################
31
	# This is the default profile. It is found in SQL by group membership.
31
	# This is the default profile. It is found in SQL by group membership.
32
	# That means that this profile must be a member of at least one group
32
	# That means that this profile must be a member of at least one group
33
	# which will contain the corresponding check and reply items.
33
	# which will contain the corresponding check and reply items.
34
	# This profile will be queried in the authorize section for every user.
34
	# This profile will be queried in the authorize section for every user.
35
	# The point is to assign all users a default profile without having to
35
	# The point is to assign all users a default profile without having to
36
	# manually add each one to a group that will contain the profile.
36
	# manually add each one to a group that will contain the profile.
37
	# The SQL module will also honor the User-Profile attribute. This
37
	# The SQL module will also honor the User-Profile attribute. This
38
	# attribute can be set anywhere in the authorize section (ie the users
38
	# attribute can be set anywhere in the authorize section (ie the users
39
	# file). It is found exactly as the default profile is found.
39
	# file). It is found exactly as the default profile is found.
40
	# If it is set then it will *overwrite* the default profile setting.
40
	# If it is set then it will *overwrite* the default profile setting.
41
	# The idea is to select profiles based on checks on the incoming packets,
41
	# The idea is to select profiles based on checks on the incoming packets,
42
	# not on user group membership. For example:
42
	# not on user group membership. For example:
43
	# -- users file --
43
	# -- users file --
44
	# DEFAULT	Service-Type == Outbound-User, User-Profile := "outbound"
44
	# DEFAULT	Service-Type == Outbound-User, User-Profile := "outbound"
45
	# DEFAULT	Service-Type == Framed-User, User-Profile := "framed"
45
	# DEFAULT	Service-Type == Framed-User, User-Profile := "framed"
46
	#
46
	#
47
	# By default the default_user_profile is not set
47
	# By default the default_user_profile is not set
48
	#
48
	#
49
	default_user_profile = "ldap"
49
	#default_user_profile = "DEFAULT"
50
 
50
 
51
	#######################################################################
51
	#######################################################################
52
	#  NAS Query
52
	#  NAS Query
53
	#######################################################################
53
	#######################################################################
54
	#  This query retrieves the radius clients
54
	#  This query retrieves the radius clients
55
	#
55
	#
56
	#  0. Row ID (currently unused)
56
	#  0. Row ID (currently unused)
57
	#  1. Name (or IP address)
57
	#  1. Name (or IP address)
58
	#  2. Shortname
58
	#  2. Shortname
59
	#  3. Type
59
	#  3. Type
60
	#  4. Secret
60
	#  4. Secret
61
	#######################################################################
61
	#######################################################################
62
 
62
 
63
	# nas_query = "SELECT id, nasname, shortname, type, secret FROM ${nas_table}"
63
	# nas_query = "SELECT id, nasname, shortname, type, secret FROM ${nas_table}"
64
 
64
 
65
	#######################################################################
65
	#######################################################################
66
	#  Authorization Queries
66
	#  Authorization Queries
67
	#######################################################################
67
	#######################################################################
68
	#  These queries compare the check items for the user
68
	#  These queries compare the check items for the user
69
	#  in ${authcheck_table} and setup the reply items in
69
	#  in ${authcheck_table} and setup the reply items in
70
	#  ${authreply_table}.  You can use any query/tables
70
	#  ${authreply_table}.  You can use any query/tables
71
	#  you want, but the return data for each row MUST
71
	#  you want, but the return data for each row MUST
72
	#  be in the  following order:
72
	#  be in the  following order:
73
	#
73
	#
74
	#  0. Row ID (currently unused)
74
	#  0. Row ID (currently unused)
75
	#  1. UserName/GroupName
75
	#  1. UserName/GroupName
76
	#  2. Item Attr Name
76
	#  2. Item Attr Name
77
	#  3. Item Attr Value
77
	#  3. Item Attr Value
78
	#  4. Item Attr Operation
78
	#  4. Item Attr Operation
79
	#######################################################################
79
	#######################################################################
80
	# Use these for case sensitive usernames.
80
	# Use these for case sensitive usernames.
81
	authorize_check_query = "SELECT id, username, attribute, value, op \
81
	authorize_check_query = "SELECT id, username, attribute, value, op \
82
         FROM ${authcheck_table} \
82
         FROM ${authcheck_table} \
83
         WHERE username = BINARY '%{SQL-User-Name}' \
83
         WHERE username = BINARY '%{SQL-User-Name}' \
84
         ORDER BY id"
84
         ORDER BY id"
85
	authorize_reply_query = "SELECT id, username, attribute, value, op \
85
	authorize_reply_query = "SELECT id, username, attribute, value, op \
86
         FROM ${authreply_table} \
86
         FROM ${authreply_table} \
87
         WHERE username = BINARY '%{SQL-User-Name}' \
87
         WHERE username = BINARY '%{SQL-User-Name}' \
88
         ORDER BY id"
88
         ORDER BY id"
89
 
89
 
90
	# The default queries are case insensitive. (for compatibility with
90
	# The default queries are case insensitive. (for compatibility with
91
	# older versions of FreeRADIUS)
91
	# older versions of FreeRADIUS)
92
#	authorize_check_query = "SELECT id, username, attribute, value, op \
92
#	authorize_check_query = "SELECT id, username, attribute, value, op \
93
#          FROM ${authcheck_table} \
93
#          FROM ${authcheck_table} \
94
#          WHERE username = '%{SQL-User-Name}' \
94
#          WHERE username = '%{SQL-User-Name}' \
95
#          ORDER BY id"
95
#          ORDER BY id"
96
#	authorize_reply_query = "SELECT id, username, attribute, value, op \
96
#	authorize_reply_query = "SELECT id, username, attribute, value, op \
97
#          FROM ${authreply_table} \
97
#          FROM ${authreply_table} \
98
#          WHERE username = '%{SQL-User-Name}' \
98
#          WHERE username = '%{SQL-User-Name}' \
99
#          ORDER BY id"
99
#          ORDER BY id"
100
 
100
 
101
	# Use these for case sensitive usernames.
101
	# Use these for case sensitive usernames.
102
	group_membership_query = "SELECT groupname \
102
#	group_membership_query = "SELECT groupname \
103
         FROM ${usergroup_table} \
103
#         FROM ${usergroup_table} \
104
         WHERE username = BINARY '%{SQL-User-Name}' \
104
#         WHERE username = BINARY '%{SQL-User-Name}' \
105
         ORDER BY priority"
105
#         ORDER BY priority"
106
 
106
 
107
#	group_membership_query = "SELECT groupname \
107
#	group_membership_query = "SELECT groupname \
108
#          FROM ${usergroup_table} \
108
#          FROM ${usergroup_table} \
109
#          WHERE username = '%{SQL-User-Name}' \
109
#          WHERE username = '%{SQL-User-Name}' \
110
#          ORDER BY priority"
110
#          ORDER BY priority"
111
 
111
 
-
 
112
	group_membership_query = "SELECT '%{SQL-User-Name}'"
-
 
113
 
112
	authorize_group_check_query = "SELECT id, groupname, attribute, \
114
#	authorize_group_check_query = "SELECT id, groupname, attribute, \
113
          Value, op \
115
#          Value, op \
114
          FROM ${groupcheck_table} \
116
#          FROM ${groupcheck_table} \
115
          WHERE groupname = '%{Sql-Group}' \
117
#          WHERE groupname = '%{Sql-Group}' \
116
          ORDER BY id"
118
#          ORDER BY id"
117
	authorize_group_reply_query = "SELECT id, groupname, attribute, \
119
#	authorize_group_reply_query = "SELECT id, groupname, attribute, \
118
          value, op \
120
#          value, op \
119
          FROM ${groupreply_table} \
121
#          FROM ${groupreply_table} \
120
          WHERE groupname = '%{Sql-Group}' \
122
#          WHERE groupname = '%{Sql-Group}' \
121
          ORDER BY id"
123
#          ORDER BY id"
-
 
124
	authorize_group_check_query = "SELECT id, '%{SQL-User-Name}', attribute, value, op FROM ( \
-
 
125
           ( SELECT id, attribute, value, op FROM ${groupcheck_table} gr LEFT JOIN radusergroup ug ON gr.groupname = ug.groupname WHERE username = '%{SQL-User-Name}' ORDER BY ug.priority) UNION \
-
 
126
           ( SELECT id, attribute, value, op FROM ${groupcheck_table} WHERE groupname = '%{control:Tmp-String-0}') UNION \
-
 
127
           ( SELECT id, attribute, value, op FROM ${groupcheck_table} WHERE groupname = 'default') \
-
 
128
         ) attrs GROUP BY attribute"
-
 
129
	authorize_group_reply_query = "SELECT id, '%{SQL-User-Name}', attribute, value, op FROM ( \
-
 
130
           ( SELECT id, attribute, value, op FROM ${groupreply_table} gr LEFT JOIN radusergroup ug ON gr.groupname = ug.groupname WHERE username = '%{SQL-User-Name}' ORDER BY ug.priority) UNION \
-
 
131
           ( SELECT id, attribute, value, op FROM ${groupreply_table} WHERE groupname = '%{control:Tmp-String-0}') UNION \
-
 
132
           ( SELECT id, attribute, value, op FROM ${groupreply_table} WHERE groupname = 'default') \
-
 
133
         ) attrs GROUP BY attribute"
122
 
134
 
123
	#######################################################################
135
	#######################################################################
124
	#  Accounting Queries
136
	#  Accounting Queries
125
	#######################################################################
137
	#######################################################################
126
	# accounting_onoff_query	- query for Accounting On/Off packets
138
	# accounting_onoff_query	- query for Accounting On/Off packets
127
	# accounting_update_query	- query for Accounting update packets
139
	# accounting_update_query	- query for Accounting update packets
128
	# accounting_update_query_alt	- query for Accounting update packets
140
	# accounting_update_query_alt	- query for Accounting update packets
129
	#                               (alternate in case first query fails)
141
	#                               (alternate in case first query fails)
130
	# accounting_start_query	- query for Accounting start packets
142
	# accounting_start_query	- query for Accounting start packets
131
	# accounting_start_query_alt	- query for Accounting start packets
143
	# accounting_start_query_alt	- query for Accounting start packets
132
	#                               (alternate in case first query fails)
144
	#                               (alternate in case first query fails)
133
	# accounting_stop_query		- query for Accounting stop packets
145
	# accounting_stop_query		- query for Accounting stop packets
134
	# accounting_stop_query_alt	- query for Accounting start packets
146
	# accounting_stop_query_alt	- query for Accounting start packets
135
	#                               (alternate in case first query doesn't
147
	#                               (alternate in case first query doesn't
136
	#                                affect any existing rows in the table)
148
	#                                affect any existing rows in the table)
137
	#######################################################################
149
	#######################################################################
138
	accounting_onoff_query = "\
150
	accounting_onoff_query = "\
139
          UPDATE ${acct_table1} \
151
          UPDATE ${acct_table1} \
140
          SET \
152
          SET \
141
             acctstoptime       =  '%S', \
153
             acctstoptime       =  '%S', \
142
             acctsessiontime    =  unix_timestamp('%S') - \
154
             acctsessiontime    =  unix_timestamp('%S') - \
143
                                   unix_timestamp(acctstarttime), \
155
                                   unix_timestamp(acctstarttime), \
144
             acctterminatecause =  '%{Acct-Terminate-Cause}', \
156
             acctterminatecause =  '%{Acct-Terminate-Cause}', \
145
             acctstopdelay      =  %{%{Acct-Delay-Time}:-0} \
157
             acctstopdelay      =  %{%{Acct-Delay-Time}:-0} \
146
          WHERE acctstoptime IS NULL \
158
          WHERE acctstoptime IS NULL \
147
          AND nasipaddress      =  '%{NAS-IP-Address}' \
159
          AND nasipaddress      =  '%{NAS-IP-Address}' \
148
          AND acctstarttime     <= '%S'"
160
          AND acctstarttime     <= '%S'"
149
 
161
 
150
	accounting_update_query = " \
162
	accounting_update_query = " \
151
          UPDATE ${acct_table1} \
163
          UPDATE ${acct_table1} \
152
          SET \
164
          SET \
153
             framedipaddress = '%{Framed-IP-Address}', \
165
             framedipaddress = '%{Framed-IP-Address}', \
154
             acctsessiontime     = '%{Acct-Session-Time}', \
166
             acctsessiontime     = '%{Acct-Session-Time}', \
155
             acctinputoctets     = '%{%{Acct-Input-Gigawords}:-0}'  << 32 | \
167
             acctinputoctets     = '%{%{Acct-Input-Gigawords}:-0}'  << 32 | \
156
                                   '%{%{Acct-Input-Octets}:-0}', \
168
                                   '%{%{Acct-Input-Octets}:-0}', \
157
             acctoutputoctets    = '%{%{Acct-Output-Gigawords}:-0}' << 32 | \
169
             acctoutputoctets    = '%{%{Acct-Output-Gigawords}:-0}' << 32 | \
158
                                   '%{%{Acct-Output-Octets}:-0}' \
170
                                   '%{%{Acct-Output-Octets}:-0}' \
159
          WHERE acctsessionid = '%{Acct-Session-Id}' \
171
          WHERE acctsessionid = '%{Acct-Session-Id}' \
160
          AND username        = BINARY '%{SQL-User-Name}' \
172
          AND username        = BINARY '%{SQL-User-Name}' \
161
          AND nasipaddress    = '%{NAS-IP-Address}'"
173
          AND nasipaddress    = '%{NAS-IP-Address}'"
162
 
174
 
163
        accounting_update_query_alt = " \
175
        accounting_update_query_alt = " \
164
          INSERT INTO ${acct_table1} \
176
          INSERT INTO ${acct_table1} \
165
            (acctsessionid,    acctuniqueid,      username, \
177
            (acctsessionid,    acctuniqueid,      username, \
166
             realm,            nasipaddress,      nasportid, \
178
             realm,            nasipaddress,      nasportid, \
167
             nasporttype,      acctstarttime,     acctsessiontime, \
179
             nasporttype,      acctstarttime,     acctsessiontime, \
168
             acctauthentic,    connectinfo_start, acctinputoctets, \
180
             acctauthentic,    connectinfo_start, acctinputoctets, \
169
             acctoutputoctets, calledstationid,   callingstationid, \
181
             acctoutputoctets, calledstationid,   callingstationid, \
170
             servicetype,      framedprotocol,    framedipaddress, \
182
             servicetype,      framedprotocol,    framedipaddress, \
171
             acctstartdelay,   xascendsessionsvrkey) \
183
             acctstartdelay,   xascendsessionsvrkey) \
172
          VALUES \
184
          VALUES \
173
            ('%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', \
185
            ('%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', \
174
             BINARY '%{SQL-User-Name}', \
186
             BINARY '%{SQL-User-Name}', \
175
             '%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port}', \
187
             '%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port}', \
176
             '%{NAS-Port-Type}', \
188
             '%{NAS-Port-Type}', \
177
             DATE_SUB('%S', \
189
             DATE_SUB('%S', \
178
                      INTERVAL (%{%{Acct-Session-Time}:-0} + \
190
                      INTERVAL (%{%{Acct-Session-Time}:-0} + \
179
                                %{%{Acct-Delay-Time}:-0}) SECOND), \
191
                                %{%{Acct-Delay-Time}:-0}) SECOND), \
180
                      '%{Acct-Session-Time}', \
192
                      '%{Acct-Session-Time}', \
181
             '%{Acct-Authentic}', '', \
193
             '%{Acct-Authentic}', '', \
182
             '%{%{Acct-Input-Gigawords}:-0}' << 32 | \
194
             '%{%{Acct-Input-Gigawords}:-0}' << 32 | \
183
             '%{%{Acct-Input-Octets}:-0}', \
195
             '%{%{Acct-Input-Octets}:-0}', \
184
             '%{%{Acct-Output-Gigawords}:-0}' << 32 | \
196
             '%{%{Acct-Output-Gigawords}:-0}' << 32 | \
185
             '%{%{Acct-Output-Octets}:-0}', \
197
             '%{%{Acct-Output-Octets}:-0}', \
186
             '%{Called-Station-Id}', '%{Calling-Station-Id}', \
198
             '%{Called-Station-Id}', '%{Calling-Station-Id}', \
187
             '%{Service-Type}', '%{Framed-Protocol}', \
199
             '%{Service-Type}', '%{Framed-Protocol}', \
188
             '%{Framed-IP-Address}', \
200
             '%{Framed-IP-Address}', \
189
             '0', '%{X-Ascend-Session-Svr-Key}')"
201
             '0', '%{X-Ascend-Session-Svr-Key}')"
190
 
202
 
191
	accounting_start_query = " \
203
	accounting_start_query = " \
192
          INSERT INTO ${acct_table1} \
204
          INSERT INTO ${acct_table1} \
193
            (acctsessionid,    acctuniqueid,     username, \
205
            (acctsessionid,    acctuniqueid,     username, \
194
             realm,            nasipaddress,     nasportid, \
206
             realm,            nasipaddress,     nasportid, \
195
             nasporttype,      acctstarttime,    acctstoptime, \
207
             nasporttype,      acctstarttime,    acctstoptime, \
196
             acctsessiontime,  acctauthentic,    connectinfo_start, \
208
             acctsessiontime,  acctauthentic,    connectinfo_start, \
197
             connectinfo_stop, acctinputoctets,  acctoutputoctets, \
209
             connectinfo_stop, acctinputoctets,  acctoutputoctets, \
198
             calledstationid,  callingstationid, acctterminatecause, \
210
             calledstationid,  callingstationid, acctterminatecause, \
199
             servicetype,      framedprotocol,   framedipaddress, \
211
             servicetype,      framedprotocol,   framedipaddress, \
200
             acctstartdelay,   acctstopdelay,    xascendsessionsvrkey) \
212
             acctstartdelay,   acctstopdelay,    xascendsessionsvrkey) \
201
          VALUES \
213
          VALUES \
202
            ('%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', \
214
            ('%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', \
203
             BINARY '%{SQL-User-Name}', \
215
             BINARY '%{SQL-User-Name}', \
204
             '%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port}', \
216
             '%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port}', \
205
             '%{NAS-Port-Type}', '%S', NULL, \
217
             '%{NAS-Port-Type}', '%S', NULL, \
206
             '0', '%{Acct-Authentic}', '%{Connect-Info}', \
218
             '0', '%{Acct-Authentic}', '%{Connect-Info}', \
207
             '', '0', '0', \
219
             '', '0', '0', \
208
             '%{Called-Station-Id}', '%{Calling-Station-Id}', '', \
220
             '%{Called-Station-Id}', '%{Calling-Station-Id}', '', \
209
             '%{Service-Type}', '%{Framed-Protocol}', '%{Framed-IP-Address}', \
221
             '%{Service-Type}', '%{Framed-Protocol}', '%{Framed-IP-Address}', \
210
             '%{%{Acct-Delay-Time}:-0}', '0', '%{X-Ascend-Session-Svr-Key}')"
222
             '%{%{Acct-Delay-Time}:-0}', '0', '%{X-Ascend-Session-Svr-Key}')"
211
 
223
 
212
	accounting_start_query_alt  = " \
224
	accounting_start_query_alt  = " \
213
          UPDATE ${acct_table1} SET \
225
          UPDATE ${acct_table1} SET \
214
             acctstarttime     = '%S', \
226
             acctstarttime     = '%S', \
215
             acctstartdelay    = '%{%{Acct-Delay-Time}:-0}', \
227
             acctstartdelay    = '%{%{Acct-Delay-Time}:-0}', \
216
             connectinfo_start = '%{Connect-Info}' \
228
             connectinfo_start = '%{Connect-Info}' \
217
          WHERE acctsessionid  = '%{Acct-Session-Id}' \
229
          WHERE acctsessionid  = '%{Acct-Session-Id}' \
218
          AND username         = BINARY '%{SQL-User-Name}' \
230
          AND username         = BINARY '%{SQL-User-Name}' \
219
          AND nasipaddress     = '%{NAS-IP-Address}'"
231
          AND nasipaddress     = '%{NAS-IP-Address}'"
220
 
232
 
221
	accounting_stop_query = " \
233
	accounting_stop_query = " \
222
          UPDATE ${acct_table2} SET \
234
          UPDATE ${acct_table2} SET \
223
             acctstoptime       = '%S', \
235
             acctstoptime       = '%S', \
224
             acctsessiontime    = '%{Acct-Session-Time}', \
236
             acctsessiontime    = '%{Acct-Session-Time}', \
225
             acctinputoctets    = '%{%{Acct-Input-Gigawords}:-0}' << 32 | \
237
             acctinputoctets    = '%{%{Acct-Input-Gigawords}:-0}' << 32 | \
226
                                  '%{%{Acct-Input-Octets}:-0}', \
238
                                  '%{%{Acct-Input-Octets}:-0}', \
227
             acctoutputoctets   = '%{%{Acct-Output-Gigawords}:-0}' << 32 | \
239
             acctoutputoctets   = '%{%{Acct-Output-Gigawords}:-0}' << 32 | \
228
                                  '%{%{Acct-Output-Octets}:-0}', \
240
                                  '%{%{Acct-Output-Octets}:-0}', \
229
             acctterminatecause = '%{Acct-Terminate-Cause}', \
241
             acctterminatecause = '%{Acct-Terminate-Cause}', \
230
             acctstopdelay      = '%{%{Acct-Delay-Time}:-0}', \
242
             acctstopdelay      = '%{%{Acct-Delay-Time}:-0}', \
231
             connectinfo_stop   = '%{Connect-Info}' \
243
             connectinfo_stop   = '%{Connect-Info}' \
232
          WHERE acctsessionid   = '%{Acct-Session-Id}' \
244
          WHERE acctsessionid   = '%{Acct-Session-Id}' \
233
          AND username          = BINARY '%{SQL-User-Name}' \
245
          AND username          = BINARY '%{SQL-User-Name}' \
234
          AND nasipaddress      = '%{NAS-IP-Address}'"
246
          AND nasipaddress      = '%{NAS-IP-Address}'"
235
 
247
 
236
	accounting_stop_query_alt = " \
248
	accounting_stop_query_alt = " \
237
          INSERT INTO ${acct_table2} \
249
          INSERT INTO ${acct_table2} \
238
            (acctsessionid, acctuniqueid, username, \
250
            (acctsessionid, acctuniqueid, username, \
239
             realm, nasipaddress, nasportid, \
251
             realm, nasipaddress, nasportid, \
240
             nasporttype, acctstarttime, acctstoptime, \
252
             nasporttype, acctstarttime, acctstoptime, \
241
             acctsessiontime, acctauthentic, connectinfo_start, \
253
             acctsessiontime, acctauthentic, connectinfo_start, \
242
             connectinfo_stop, acctinputoctets, acctoutputoctets, \
254
             connectinfo_stop, acctinputoctets, acctoutputoctets, \
243
             calledstationid, callingstationid, acctterminatecause, \
255
             calledstationid, callingstationid, acctterminatecause, \
244
             servicetype, framedprotocol, framedipaddress, \
256
             servicetype, framedprotocol, framedipaddress, \
245
             acctstartdelay, acctstopdelay) \
257
             acctstartdelay, acctstopdelay) \
246
          VALUES \
258
          VALUES \
247
            ('%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', \
259
            ('%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', \
248
             BINARY '%{SQL-User-Name}', \
260
             BINARY '%{SQL-User-Name}', \
249
             '%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port}', \
261
             '%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port}', \
250
             '%{NAS-Port-Type}', \
262
             '%{NAS-Port-Type}', \
251
             DATE_SUB('%S', \
263
             DATE_SUB('%S', \
252
                 INTERVAL (%{%{Acct-Session-Time}:-0} + \
264
                 INTERVAL (%{%{Acct-Session-Time}:-0} + \
253
                 %{%{Acct-Delay-Time}:-0}) SECOND), \
265
                 %{%{Acct-Delay-Time}:-0}) SECOND), \
254
             '%S', '%{Acct-Session-Time}', '%{Acct-Authentic}', '', \
266
             '%S', '%{Acct-Session-Time}', '%{Acct-Authentic}', '', \
255
             '%{Connect-Info}', \
267
             '%{Connect-Info}', \
256
             '%{%{Acct-Input-Gigawords}:-0}' << 32 | \
268
             '%{%{Acct-Input-Gigawords}:-0}' << 32 | \
257
             '%{%{Acct-Input-Octets}:-0}', \
269
             '%{%{Acct-Input-Octets}:-0}', \
258
             '%{%{Acct-Output-Gigawords}:-0}' << 32 | \
270
             '%{%{Acct-Output-Gigawords}:-0}' << 32 | \
259
             '%{%{Acct-Output-Octets}:-0}', \
271
             '%{%{Acct-Output-Octets}:-0}', \
260
             '%{Called-Station-Id}', '%{Calling-Station-Id}', \
272
             '%{Called-Station-Id}', '%{Calling-Station-Id}', \
261
             '%{Acct-Terminate-Cause}', \
273
             '%{Acct-Terminate-Cause}', \
262
             '%{Service-Type}', '%{Framed-Protocol}', '%{Framed-IP-Address}', \
274
             '%{Service-Type}', '%{Framed-Protocol}', '%{Framed-IP-Address}', \
263
             '0', '%{%{Acct-Delay-Time}:-0}')"
275
             '0', '%{%{Acct-Delay-Time}:-0}')"
264
# We add the following patch (freeradius V2 to V3) in order ALCASAR works
276
# We add the following patch (freeradius V2 to V3) in order ALCASAR works
265
# be carefull : 'tolower' need now the 'expr' module
277
# be carefull : 'tolower' need now the 'expr' module
266
accounting {
278
accounting {
267
	reference = "%{tolower:type.%{Acct-Status-Type}.query}"
279
	reference = "%{tolower:type.%{Acct-Status-Type}.query}"
268
	type {
280
	type {
269
		accounting-on {
281
		accounting-on {
270
			query = "${....accounting_onoff_query}"
282
			query = "${....accounting_onoff_query}"
271
		}
283
		}
272
		accounting-off {
284
		accounting-off {
273
			query = "${....accounting_onoff_query}"
285
			query = "${....accounting_onoff_query}"
274
		}
286
		}
275
		start {
287
		start {
276
			query = "${....accounting_start_query}"
288
			query = "${....accounting_start_query}"
277
			query = "${....accounting_start_query_alt}"
289
			query = "${....accounting_start_query_alt}"
278
		}
290
		}
279
		interim-update {
291
		interim-update {
280
			query = "${....accounting_update_query}"
292
			query = "${....accounting_update_query}"
281
			query = "${....accounting_update_query_alt}"
293
			query = "${....accounting_update_query_alt}"
282
		}
294
		}
283
		stop {
295
		stop {
284
			query = "${....accounting_stop_query}"
296
			query = "${....accounting_stop_query}"
285
			query = "${....accounting_stop_query_alt}"
297
			query = "${....accounting_stop_query_alt}"
286
		}
298
		}
287
	}
299
	}
288
}
300
}
289
	#######################################################################
301
	#######################################################################
290
	# Simultaneous Use Checking Queries
302
	# Simultaneous Use Checking Queries
291
	#######################################################################
303
	#######################################################################
292
	# simul_count_query	- query for the number of current connections
304
	# simul_count_query	- query for the number of current connections
293
	#			- If this is not defined, no simultaneouls use checking
305
	#			- If this is not defined, no simultaneouls use checking
294
	#			- will be performed by this module instance
306
	#			- will be performed by this module instance
295
	# simul_verify_query	- query to return details of current connections for verification
307
	# simul_verify_query	- query to return details of current connections for verification
296
	#			- Leave blank or commented out to disable verification step
308
	#			- Leave blank or commented out to disable verification step
297
	#			- Note that the returned field order should not be changed.
309
	#			- Note that the returned field order should not be changed.
298
	#######################################################################
310
	#######################################################################
299
 
311
 
300
	# Uncomment simul_count_query to enable simultaneous use checking
312
	# Uncomment simul_count_query to enable simultaneous use checking
301
	simul_count_query = "SELECT COUNT(*) \
313
	simul_count_query = "SELECT COUNT(*) \
302
                             FROM ${acct_table1} \
314
                             FROM ${acct_table1} \
303
                             WHERE username = BINARY '%{SQL-User-Name}' \
315
                             WHERE username = BINARY '%{SQL-User-Name}' \
304
                             AND acctstoptime IS NULL"
316
                             AND acctstoptime IS NULL"
305
 
317
 
306
	#simul_verify_query  = "SELECT radacctid, acctsessionid, username, \
318
	#simul_verify_query  = "SELECT radacctid, acctsessionid, username, \
307
                               #nasipaddress, nasportid, framedipaddress, \
319
                               #nasipaddress, nasportid, framedipaddress, \
308
                               #callingstationid, framedprotocol \
320
                               #callingstationid, framedprotocol \
309
                               #FROM ${acct_table1} \
321
                               #FROM ${acct_table1} \
310
                               #WHERE username = '%{SQL-User-Name}' \
322
                               #WHERE username = '%{SQL-User-Name}' \
311
                               #AND acctstoptime IS NULL"
323
                               #AND acctstoptime IS NULL"
312
 
324
 
313
	#######################################################################
325
	#######################################################################
314
	# Authentication Logging Queries
326
	# Authentication Logging Queries
315
	#######################################################################
327
	#######################################################################
316
	# postauth_query		- Insert some info after authentication
328
	# postauth_query		- Insert some info after authentication
317
	#######################################################################
329
	#######################################################################
318
#                          (username, pass, reply, authdate) \
330
#                          (username, pass, reply, authdate) \
319
#                          '%{%{User-Password}:-%{Chap-Password}}', \
331
#                          '%{%{User-Password}:-%{Chap-Password}}', \
320
 
332
 
321
	postauth_query = "INSERT INTO ${postauth_table} \
333
	postauth_query = "INSERT INTO ${postauth_table} \
322
                          (username, reply, authdate) \
334
                          (username, reply, authdate) \
323
                          VALUES ( \
335
                          VALUES ( \
324
                          BINARY '%{User-Name}', \
336
                          BINARY '%{User-Name}', \
325
                          '%{reply:Packet-Type}', '%S')"
337
                          '%{reply:Packet-Type}', '%S')"
326
# We add the following patch (freeradius V2 to V3) in order ALCASAR works
338
# We add the following patch (freeradius V2 to V3) in order ALCASAR works
327
post-auth {
339
post-auth {
328
	query = "${..postauth_query}"
340
	query = "${..postauth_query}"
329
}
341
}
330
 
342