]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Tie session state into the rest of the server.
authorAlan T. DeKok <aland@freeradius.org>
Fri, 31 Oct 2014 15:05:27 +0000 (11:05 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 31 Oct 2014 15:06:00 +0000 (11:06 -0400)
man/man5/unlang.5
src/include/radiusd.h
src/include/tmpl.h
src/main/auth.c
src/main/radiusd.c
src/main/radiusd.mk
src/main/tmpl.c
src/main/unittest.c
src/main/unittest.mk

index b9d483c373d054f3494ee365eadc5aaba9f145c2..7d274c47f7e7a349c2314e3aff61409f3189d412 100644 (file)
@@ -191,8 +191,9 @@ the current block.
 .DE
 
 The <list> can be one of "request", "reply", "proxy-request",
-"proxy-reply", "coa", "disconnect", or "control".  As of Version 3,
-the <list> can be omitted, in which case "request" is assumed.
+"proxy-reply", "coa", "disconnect", "session-state", or "control".  As
+of Version 3, the <list> can be omitted, in which case "request" is
+assumed.
 
 The "control" list is the list of attributes maintainted internally by
 the server that controls how the server processes the request.  Any
@@ -215,6 +216,11 @@ packet.  That packet is sent when the current Access-Request or
 Accounting-Request has been finished, and a reply sent to the NAS.
 See raddb/sites-available/originate-coa for additional information.
 
+The "session-state" list is primarily used for EAP.  Attributes put
+into the "session-state" list are saved for the next packet in the
+session.  They are automatically retreived when the next packet is
+received.
+
 The only contents permitted in an "update" section are attributes and
 values.  The contents of the "update" section are described in the
 ATTRIBUTE REFERENCE and ATTRIBUTE ASSIGNMENT sections below.
index 7513b37e0a099ca81138a821425f5969b3491e1d..1e6d9b05df864521b2eef7509a82f96449d9cab3 100644 (file)
@@ -222,6 +222,8 @@ struct rad_request {
 #endif
        VALUE_PAIR              *config_items;  //!< VALUE_PAIRs used to set per request parameters
                                                //!< for modules and the server core at runtime.
+       VALUE_PAIR              *state;         //!< VALUE_PAIRs used to set session parameters
+                                               //!< for multiple packets, e.g. EAP.
        VALUE_PAIR              *username;      //!< Cached username VALUE_PAIR.
        VALUE_PAIR              *password;      //!< Cached password VALUE_PAIR.
 
index d7606f9c8899cdb302730599dab2c390019b5c09..9b04505b204c869fafde2b29fa153e98bc97d3e6 100644 (file)
@@ -25,6 +25,7 @@ typedef enum pair_lists {
        PAIR_LIST_REQUEST,
        PAIR_LIST_REPLY,
        PAIR_LIST_CONTROL,
+       PAIR_LIST_STATE,
 #ifdef WITH_PROXY
        PAIR_LIST_PROXY_REQUEST,
        PAIR_LIST_PROXY_REPLY,
index e2f76828d83659233ca54ac8d385a0ff67a89ab9..4b7a8f09cb112af08c15d656ccab2223f1a729b1 100644 (file)
@@ -25,6 +25,7 @@ RCSID("$Id$")
 
 #include <freeradius-devel/radiusd.h>
 #include <freeradius-devel/modules.h>
+#include <freeradius-devel/state.h>
 #include <freeradius-devel/rad_assert.h>
 
 #include <ctype.h>
@@ -313,6 +314,7 @@ int rad_postauth(REQUEST *request)
        case RLM_MODULE_USERLOCK:
        default:
                request->reply->code = PW_CODE_ACCESS_REJECT;
+               fr_state_discard(request, request->packet);
                result = RLM_MODULE_REJECT;
                break;
        /*
@@ -329,6 +331,12 @@ int rad_postauth(REQUEST *request)
        case RLM_MODULE_OK:
        case RLM_MODULE_UPDATED:
                result = RLM_MODULE_OK;
+
+               if (request->reply->code == PW_CODE_ACCESS_CHALLENGE) {
+                       fr_state_put_vps(request, request->packet, request->reply);
+               } else if (request->reply->code == PW_CODE_ACCESS_ACCEPT) {
+                       fr_state_discard(request, request->packet);
+               }
                break;
        }
        return result;
@@ -415,6 +423,11 @@ int rad_authenticate(REQUEST *request)
                request->password = pairfind(request->packet->vps, PW_CHAP_PASSWORD, 0, TAG_ANY);
        }
 
+       /*
+        *      Grab the VPS associated with the State attribute.
+        */
+       fr_state_get_vps(request, request->packet);
+
        /*
         *      Get the user's authorization information from the database
         */
index cb0d77b2c6e69b38235079c888073151db1e2322..bc285bd7a1f95ac06a9e1bfeba9d0d2d311f29c0 100644 (file)
@@ -29,6 +29,7 @@ RCSID("$Id$")
 
 #include <freeradius-devel/radiusd.h>
 #include <freeradius-devel/modules.h>
+#include <freeradius-devel/state.h>
 #include <freeradius-devel/rad_assert.h>
 
 #include <sys/file.h>
@@ -578,6 +579,8 @@ int main(int argc, char *argv[])
         */
        fr_strerror();
 
+       fr_state_init();
+
        /*
         *      Process requests until HUP or exit.
         */
@@ -637,6 +640,8 @@ cleanup:
 
        xlat_free();            /* modules may have xlat's */
 
+       fr_state_delete();
+
        /*
         *      Free the configuration items.
         */
index 9a33539f90bd2709783f5a58e6a21be076dabf32..eb6ea991c394e4f2885f3053f7eaeef59de2b448 100644 (file)
@@ -1,7 +1,7 @@
 TARGET := radiusd
 SOURCES := acct.c auth.c client.c crypt.c files.c \
                  listen.c  mainconfig.c modules.c modcall.c \
-                 radiusd.c stats.c soh.c connection.c \
+                 radiusd.c state.c stats.c soh.c connection.c \
                  session.c threads.c version.c  \
                  process.c realms.c detail.c
 ifneq ($(OPENSSL_LIBS),)
index 7fcbc995b7b0ba7be03ef1eb0b64c769a594edfb..3f47798308b3319a1bccaab5247359b999bfd2e1 100644 (file)
@@ -36,6 +36,7 @@ const FR_NAME_NUMBER pair_lists[] = {
        { "reply",              PAIR_LIST_REPLY },
        { "control",            PAIR_LIST_CONTROL },            /* New name should have priority */
        { "config",             PAIR_LIST_CONTROL },
+       { "session-state",      PAIR_LIST_STATE },
 #ifdef WITH_PROXY
        { "proxy-request",      PAIR_LIST_PROXY_REQUEST },
        { "proxy-reply",        PAIR_LIST_PROXY_REPLY },
@@ -188,6 +189,9 @@ VALUE_PAIR **radius_list(REQUEST *request, pair_lists_t list)
        case PAIR_LIST_CONTROL:
                return &request->config_items;
 
+       case PAIR_LIST_STATE:
+               return &request->state;
+
 #ifdef WITH_PROXY
        case PAIR_LIST_PROXY_REQUEST:
                if (!request->proxy) break;
@@ -258,6 +262,9 @@ TALLOC_CTX *radius_list_ctx(REQUEST *request, pair_lists_t list_name)
        case PAIR_LIST_CONTROL:
                return request;
 
+       case PAIR_LIST_STATE:
+               return request;
+
 #ifdef WITH_PROXY
        case PAIR_LIST_PROXY_REQUEST:
                return request->proxy;
index 485891ad6ead02fa05bb18d41aaf40641d2f40f9..42219b166e33994de144f36467fc2cbc2caff0f4 100644 (file)
@@ -25,6 +25,7 @@ RCSID("$Id$")
 
 #include <freeradius-devel/radiusd.h>
 #include <freeradius-devel/modules.h>
+#include <freeradius-devel/state.h>
 #include <freeradius-devel/rad_assert.h>
 
 #ifdef HAVE_GETOPT_H
@@ -540,6 +541,8 @@ int main(int argc, char *argv[])
                goto finish;
        }
 
+       fr_state_init();
+
        /* Set the panic action (if required) */
        if (main_config.panic_action &&
 #ifndef NDEBUG
@@ -665,6 +668,8 @@ finish:
 
        xlat_free();            /* modules may have xlat's */
 
+       fr_state_delete();
+
        /*
         *      Free the configuration items.
         */
index a939b963cca23283dc8bcf734ca3e067449b95d6..804efeef8b779c099b6d954061eef908744b468e 100644 (file)
@@ -1,7 +1,7 @@
 TARGET := unittest
 SOURCES := acct.c auth.c client.c crypt.c files.c \
                  mainconfig.c modules.c modcall.c \
-                 unittest.c soh.c connection.c \
+                 unittest.c soh.c state.c connection.c \
                  session.c threads.c version.c  \
                  realms.c