]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Revert "remove use of request->username"
authorAlan T. DeKok <aland@freeradius.org>
Wed, 31 Jul 2019 17:17:08 +0000 (13:17 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 31 Jul 2019 17:17:08 +0000 (13:17 -0400)
This reverts commit 89852b7e7add77ee4b1ed7a1a4fe3e6f6f67871c.

Nope.  There's a lot more work to do

doc/upgrade/README.adoc
raddb/mods-available/sqlcounter
src/modules/rlm_sqlcounter/rlm_sqlcounter.c

index 9f6ab6d1d0bcbe2f6094c0be765d1f6226698d64..c0e47aa681a5c346d38281f53229ac68999ae59b 100644 (file)
@@ -641,15 +641,6 @@ with newer features in the server such as CoA, where reply_name can now
 be `+&coa:Session-Timeout+`. That allows the server to send a CoA packet
 which updates the `+Session-Timeout+` for the user.
 
-In v4, when the `key` field was set to `User-Name`, the module would
-also look for `Stripped-User-Name` as the key.  In v4, this
-functionality has been moved to the configuration.  To get the same
-functionality, the key should now be specified as a dynamic expansion:
-
-```
-key = "%{%{Stripped-User-Name}:-%{User-Name}}"
-```
-
 === rlm_sqlippool
 
 NOTE: The `+ipv6+` configuration item has been deleted. It was
index 3654270114e1bd39ed6d3fe851aaeafe0b144c79..a8b9d0704cb923e3ba0d3eb2cf7f2e13c24b6f6e 100644 (file)
@@ -73,7 +73,7 @@
 #  | `%%e`        | unix time value of end of reset period.
 #  |===
 #
-#      key = "%{%{Stripped-User-Name}:-%{User-Name}}"
+#      key = &User-Name
 #
 #  counter_name:: Name of the `check` attribute to use to access the counter in
 #  the `users` file or SQL `radcheck` or `radcheckgroup` tables.
@@ -98,7 +98,7 @@ sqlcounter dailycounter {
        counter_name = &Daily-Session-Time
        check_name = &control:Max-Daily-Session
        reply_name = &reply:Session-Timeout
-       key = "%{%{Stripped-User-Name}:-%{User-Name}}"
+       key = &User-Name
 
        reset = daily
 
index e27be652c922c609e1f234209578bf7b181c09c0..8cd4857dacc0fc1a731715ab27fca23dd50f5d3e 100644 (file)
@@ -80,7 +80,7 @@ static const CONF_PARSER module_config[] = {
        { FR_CONF_OFFSET("query", FR_TYPE_STRING | FR_TYPE_XLAT | FR_TYPE_REQUIRED, rlm_sqlcounter_t, query) },
        { FR_CONF_OFFSET("reset", FR_TYPE_STRING | FR_TYPE_REQUIRED, rlm_sqlcounter_t, reset) },
 
-       { FR_CONF_OFFSET("key", FR_TYPE_TMPL | FR_TYPE_ATTRIBUTE, rlm_sqlcounter_t, key_attr), .dflt = "%{%{Stripped-User-Name}:-%{User-Name}}", .quote = T_BARE_WORD },
+       { FR_CONF_OFFSET("key", FR_TYPE_TMPL | FR_TYPE_ATTRIBUTE, rlm_sqlcounter_t, key_attr), .dflt = "&request:User-Name", .quote = T_BARE_WORD },
 
        /* Just used to register a paircmp against */
        { FR_CONF_OFFSET("counter_name", FR_TYPE_TMPL | FR_TYPE_ATTRIBUTE | FR_TYPE_REQUIRED, rlm_sqlcounter_t, paircmp_attr) },
@@ -101,11 +101,13 @@ fr_dict_autoload_t rlm_sqlcounter_dict[] = {
        { NULL }
 };
 
+static fr_dict_attr_t const *attr_user_name;
 static fr_dict_attr_t const *attr_reply_message;
 static fr_dict_attr_t const *attr_session_timeout;
 
 extern fr_dict_attr_autoload_t rlm_sqlcounter_dict_attr[];
 fr_dict_attr_autoload_t rlm_sqlcounter_dict_attr[] = {
+       { .out = &attr_user_name, .name = "User-Name", .type = FR_TYPE_STRING, .dict = &dict_radius },
        { .out = &attr_reply_message, .name = "Reply-Message", .type = FR_TYPE_STRING, .dict = &dict_radius },
        { .out = &attr_session_timeout, .name = "Session-Timeout", .type = FR_TYPE_UINT32, .dict = &dict_radius },
        { NULL }
@@ -424,7 +426,16 @@ static rlm_rcode_t CC_HINT(nonnull) mod_authorize(void *instance, UNUSED void *t
                find_next_reset(inst, fr_time_to_sec(request->packet->timestamp));
        }
 
-       tmpl_find_vp(&key_vp, request, inst->key_attr);
+       /*
+        *      Look for the key.  User-Name is special.  It means
+        *      The REAL username, after stripping.
+        */
+       if ((inst->key_attr->tmpl_list == PAIR_LIST_REQUEST) &&
+           (inst->key_attr->tmpl_da == attr_user_name)) {
+               key_vp = request->username;
+       } else {
+               tmpl_find_vp(&key_vp, request, inst->key_attr);
+       }
        if (!key_vp) {
                RWDEBUG2("Couldn't find key attribute, %s, doing nothing...", inst->key_attr->tmpl_da->name);
                return RLM_MODULE_NOOP;