]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
update Oracle for Class queries
authorAlan T. DeKok <aland@freeradius.org>
Tue, 25 May 2021 12:47:12 +0000 (08:47 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 25 May 2021 12:47:12 +0000 (08:47 -0400)
raddb/mods-config/sql/main/oracle/queries.conf
raddb/mods-config/sql/main/oracle/schema.sql

index fa34d8eff1e9dc28b5eebabe80e53d5ef6b63b75..ad33d34c2bc15c470c1f331eaea2bd754c69bdf6 100644 (file)
@@ -40,6 +40,40 @@ event_timestamp_epoch = "%{%{integer:Event-Timestamp}:-%l}"
 
 event_timestamp = "TO_DATE('1970-01-01','YYYY-MM-DD') + NUMTODSINTERVAL(${event_timestamp_epoch},'SECOND')"
 
+#######################################################################
+#  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
 #######################################################################
@@ -321,7 +355,8 @@ accounting {
                                        DelegatedIPv6Prefix, \
                                        AcctStartDelay, \
                                        AcctStopDelay, \
-                                       XAscendSessionSvrKey) \
+                                       XAscendSessionSvrKey \
+                                       ${..class.column_name}) \
                                VALUES(\
                                        '', \
                                        '%{Acct-Session-Id}', \
@@ -351,7 +386,8 @@ accounting {
                                        '%{Delegated-IPv6-Prefix}', \
                                        '%{Acct-Delay-Time}', \
                                        '0', \
-                                       '%{X-Ascend-Session-Svr-Key}')"
+                                       '%{X-Ascend-Session-Svr-Key}' \
+                                       ${....class.packet_xlat})"
 
                        #
                        #  When using "sql_session_start", you should comment out
@@ -437,7 +473,8 @@ accounting {
                                        FramedInterfaceId, \
                                        DelegatedIPv6Prefix, \
                                        AcctStartDelay, \
-                                       XAscendSessionSvrKey) \
+                                       XAscendSessionSvrKey \
+                                       ${..class.column_name}) \
                                VALUES(\
                                        '', \
                                        '%{Acct-Session-Id}', \
@@ -465,7 +502,8 @@ accounting {
                                        '%{Framed-Interface-Id}', \
                                        '%{Delegated-IPv6-Prefix}', \
                                        '0', \
-                                       '%{X-Ascend-Session-Svr-Key}')"
+                                       '%{X-Ascend-Session-Svr-Key}' \
+                                       ${....class.packet_xlat})"
 
                        #
                        #  When using "sql_session_start", you should comment out
@@ -548,7 +586,8 @@ accounting {
                                        FramedInterfaceId, \
                                        DelegatedIPv6Prefix, \
                                        AcctStartDelay, \
-                                       AcctStopDelay) \
+                                       AcctStopDelay \
+                                       ${..class.column_name}) \
                                VALUES(\
                                        '', \
                                        '%{Acct-Session-Id}', \
@@ -580,7 +619,8 @@ accounting {
                                        '%{Framed-Interface-Id}', \
                                        '%{Delegated-IPv6-Prefix}', \
                                        '0', \
-                                       '%{%{Acct-Delay-Time}:-0}')"
+                                       '%{%{Acct-Delay-Time}:-0}' \
+                                       ${....class.packet_xlat})"
 
                        #
                        #  When using "sql_session_start", you should comment out
@@ -635,10 +675,11 @@ post-auth {
 #      logfile = ${logdir}/post-auth.sql
        query = "\
                INSERT INTO ${..postauth_table} \
-                       (username, pass, reply, authdate) \
+                       (username, pass, reply, authdate ${..class.column_name}) \
                VALUES (\
                        '%{User-Name}', \
                        '%{%{User-Password}:-%{Chap-Password}}', \
                        '%{reply:Packet-Type}', \
-                       TO_TIMESTAMP('%S.%M','YYYY-MM-DDHH24:MI:SS.FF'))"
+                       TO_TIMESTAMP('%S.%M','YYYY-MM-DDHH24:MI:SS.FF') \
+                       ${..class.reply_xlat})"
 }
index 54916e5e9c4c7926a97a88d90ee1a08acf48a92a..96cde18d1c42057dfff65df9fff5f664790c4fcb 100644 (file)
@@ -48,6 +48,8 @@ CREATE UNIUQE INDEX radacct_idx0
 CREATE UNIQUE INDEX radacct_idx1
        ON radacct(acctsessionid,username,acctstarttime,
                acctstoptime,nasipaddress,framedipaddress,framedipv6address,framedipv6prefix,framedinterfaceid,delegatedipv6prefix);
+CREATE INDEX radacct_idx2
+       ON radacct(class);
 
 CREATE SEQUENCE radacct_seq START WITH 1 INCREMENT BY 1;
 
@@ -160,8 +162,13 @@ CREATE TABLE radpostauth (
          UserName      VARCHAR(64) NOT NULL,
          Pass          VARCHAR(64),
          Reply         VARCHAR(64),
-         AuthDate      TIMESTAMP(6) WITH TIME ZONE
+         AuthDate      TIMESTAMP(6) WITH TIME ZONE,
+         Class         VARCHAR(64)
 );
+CREATE INDEX radpostauth_idx0
+       ON radpostauth(UserName);
+CREATE INDEX radpostauth_idx1
+       ON radpostauth(class);
 
 CREATE SEQUENCE radpostauth_seq START WITH 1 INCREMENT BY 1;