]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
update MySQL for Class queries
authorAlan T. DeKok <aland@freeradius.org>
Tue, 25 May 2021 13:27:49 +0000 (09:27 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 25 May 2021 13:27:49 +0000 (09:27 -0400)
raddb/mods-config/sql/main/mysql/queries.conf
raddb/mods-config/sql/main/mysql/schema.sql

index 51560a71ed819a95bc0f5ccc352efe69e374f7c5..af1568a7f05650b426aec426ba8aabf9e3cdb5ca 100644 (file)
@@ -68,6 +68,40 @@ event_timestamp_epoch = "%{%{integer:Event-Timestamp}:-%l}"
 
 event_timestamp = "FROM_UNIXTIME(${event_timestamp_epoch})"
 
+#######################################################################
+#  Query config:  Class attribute
+#######################################################################
+#
+#  3.0.22 and later have a "class" column in the accounting table.
+#
+#  However, we do NOT want to break existing configurations by adding
+#  the Class attribute to the default queries.  If we did that, then
+#  systems using newer versions of the server would fail, because
+#  there is no "class" column in their accounting tables.
+#
+#  The solution to that is the following "class" subsection.  If your
+#  database has a "class" column for the various tables, then you can
+#  uncomment the configuration items here.  The queries below will
+#  then automatically insert the Class attribute into radacct,
+#  radpostauth, etc.
+#
+class {
+       #
+       #  Delete the '#' character from each of the configuration
+       #  items in this section.  This change puts the Class
+       #  attribute into the various tables.  Leave the double-quoted
+       #  string there, as the value for the configuration item.
+       #
+       #  See also policy.d/accounting, and the "insert_acct_class"
+       #  policy.  You will need to list (or uncomment)
+       #  "insert_acct_class" in the "post-auth" section in order to
+       #  create a Class attribute.
+       #
+       column_name =   # ", class"
+       packet_xlat =   # ", '%{Class}'"
+       reply_xlat =    # ", '%{Reply:Class}'"
+}
+
 #######################################################################
 # Default profile
 #######################################################################
@@ -237,7 +271,7 @@ accounting {
                acctoutputoctets,       calledstationid,        callingstationid, \
                acctterminatecause,     servicetype,            framedprotocol, \
                framedipaddress,        framedipv6address,      framedipv6prefix, \
-               framedinterfaceid,      delegatedipv6prefix"
+               framedinterfaceid,      delegatedipv6prefix     ${..class.column_name}"
 
        type {
                accounting-on {
@@ -297,7 +331,8 @@ accounting {
                                '', \
                                '', \
                                '', \
-                               '')"
+                               '' \
+                               ${....class.packet_xlat})"
 
                        query = "\
                                UPDATE ${....acct_table1} SET \
@@ -345,7 +380,8 @@ accounting {
                                        '%{Framed-IPv6-Address}', \
                                        '%{Framed-IPv6-Prefix}', \
                                        '%{Framed-Interface-Id}', \
-                                       '%{Delegated-IPv6-Prefix}')"
+                                       '%{Delegated-IPv6-Prefix}' \
+                                       ${....class.packet_xlat})"
 
                        #
                        #  When using "sql_session_start", you should comment out
@@ -449,7 +485,8 @@ accounting {
                                        '%{Framed-IPv6-Address}', \
                                        '%{Framed-IPv6-Prefix}', \
                                        '%{Framed-Interface-Id}', \
-                                       '%{Delegated-IPv6-Prefix}')"
+                                       '%{Delegated-IPv6-Prefix}' \
+                                       ${....class.packet_xlat})"
 
                        #
                        #  When using "sql_session_start", you should comment out
@@ -537,7 +574,8 @@ accounting {
                                        '%{Framed-IPv6-Address}', \
                                        '%{Framed-IPv6-Prefix}', \
                                        '%{Framed-Interface-Id}', \
-                                       '%{Delegated-IPv6-Prefix}')"
+                                       '%{Delegated-IPv6-Prefix}' \
+                                       ${....class.packet_xlat})"
 
                        #
                        #  When using "sql_session_start", you should comment out
@@ -602,10 +640,11 @@ post-auth {
 
        query = "\
                INSERT INTO ${..postauth_table} \
-                       (username, pass, reply, authdate) \
+                       (username, pass, reply, authdate ${..class.column_name}) \
                VALUES ( \
                        '%{SQL-User-Name}', \
                        '%{%{User-Password}:-%{Chap-Password}}', \
                        '%{reply:Packet-Type}', \
-                       '%S.%M')"
+                       '%S.%M' \
+                       ${..class.reply_xlat})"
 }
index f1ad9afd34fbed766ecbb513927c4f1dd89d9015..41fcccad1c012226d12cc721518fe91e311e55e2 100644 (file)
@@ -57,7 +57,8 @@ CREATE TABLE IF NOT EXISTS radacct (
   KEY acctstarttime (acctstarttime),
   KEY acctinterval (acctinterval),
   KEY acctstoptime (acctstoptime),
-  KEY nasipaddress (nasipaddress)
+  KEY nasipaddress (nasipaddress),
+  KEY class (class)
 ) ENGINE = INNODB;
 
 #
@@ -145,8 +146,10 @@ CREATE TABLE IF NOT EXISTS radpostauth (
   pass varchar(64) NOT NULL default '',
   reply varchar(32) NOT NULL default '',
   authdate timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
+  class varchar(64) default NULL,
   PRIMARY KEY  (id),
-  KEY username (username(32))
+  KEY username (username),
+  KEY class (class)
 ) ENGINE = INNODB;
 
 #