Subversion Repositories ALCASAR

Rev

Rev 2422 | Rev 2476 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

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