]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Move auth_name() into proto_radius_auth
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 28 May 2018 12:14:08 +0000 (18:14 +0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 28 May 2018 12:14:08 +0000 (18:14 +0600)
src/include/radiusd.h
src/main/auth.c
src/main/stats.c
src/modules/proto_radius/proto_radius.c
src/modules/proto_radius/proto_radius_auth.c

index 957695b3ebaa24b9a2bdd4d30ddfd2a6589f5e29..180ef2c33a171a3d3bec34ac5c321c96c182d4af 100644 (file)
@@ -437,7 +437,6 @@ int         pairlist_read(TALLOC_CTX *ctx, char const *file, PAIR_LIST **list, int comp
 void           pairlist_free(PAIR_LIST **);
 
 /* auth.c */
-char   *auth_name(char *buf, size_t buflen, REQUEST *request, bool do_cli);
 rlm_rcode_t            rad_authenticate (REQUEST *);
 rlm_rcode_t            rad_postauth(REQUEST *);
 rlm_rcode_t            rad_virtual_server(REQUEST *);
index fb8ee3d8f5bb6dd10d0a2f487d909bbc764e38f2..26b30026f6fb0d98bdfb3677d433edec9ba0cb7b 100644 (file)
@@ -33,37 +33,6 @@ RCSID("$Id$")
 
 #include <ctype.h>
 
-/*
- *     Return a short string showing the terminal server, port
- *     and calling station ID.
- */
-char *auth_name(char *buf, size_t buflen, REQUEST *request, bool do_cli)
-{
-       VALUE_PAIR      *cli;
-       VALUE_PAIR      *pair;
-       uint32_t        port = 0;       /* RFC 2865 NAS-Port is 4 bytes */
-       char const      *tls = "";
-
-       if ((cli = fr_pair_find_by_num(request->packet->vps, 0, FR_CALLING_STATION_ID, TAG_ANY)) == NULL) {
-               do_cli = false;
-       }
-
-       if ((pair = fr_pair_find_by_num(request->packet->vps, 0, FR_NAS_PORT, TAG_ANY)) != NULL) {
-               port = pair->vp_uint32;
-       }
-
-       if (request->packet->dst_port == 0) {
-               tls = " via proxy to virtual server";
-       }
-
-       snprintf(buf, buflen, "from client %.128s port %u%s%.128s%s",
-                       request->client->shortname, port,
-                (do_cli ? " cli " : ""), (do_cli ? cli->vp_strvalue : ""),
-                tls);
-
-       return buf;
-}
-
 /*
  *     Check password.
  *
@@ -523,9 +492,9 @@ skip:
        rcode = rad_authenticate(request);
 
        if (request->reply->code == FR_CODE_ACCESS_REJECT) {
-               fr_pair_delete_by_num(&request->control, 0, FR_POST_AUTH_TYPE, TAG_ANY);
+               fr_pair_delete_by_child_num(&request->control, fr_dict_root(fr_dict_internal), FR_POST_AUTH_TYPE, TAG_ANY);
 
-               MEM(vp = fr_pair_afrom_num(request, 0, FR_POST_AUTH_TYPE));
+               MEM(vp = fr_pair_afrom_child_num(request, fr_dict_root(fr_dict_internal), FR_POST_AUTH_TYPE));
                fr_pair_value_from_str(vp, "Reject", -1);
                fr_pair_add(&request->control, vp);
 
index 428954606d7191c2074afadf4fc6dc1beabf2c44..6dae1076195eb1d105b3449c6f798e99f8a37e63 100644 (file)
@@ -447,6 +447,8 @@ do { \
        fr_pair_add(&request->reply->vps, vp); \
 } while (0)
 
+static fr_dict_attr_t const *freeradius_vendor_root;
+
 static void request_stats_addvp(REQUEST *request,
                                fr_stats2vp *table, fr_stats_t *stats)
 {
index 1055e676566a3c1d521286e797b7dbf27ea9d800..bfdccb416efae480513b128521a39559fc3498fc 100644 (file)
@@ -668,20 +668,10 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
        proto_radius_t          *inst = talloc_get_type_abort(instance, proto_radius_t);
        size_t                  i;
 
-       fr_dict_attr_t const    *da;
        CONF_PAIR               *cp = NULL;
        CONF_ITEM               *ci = NULL;
        CONF_SECTION            *server = cf_item_to_section(cf_parent(conf));
 
-       /*
-        *      Needed to populate the code array
-        */
-       da = fr_dict_attr_by_name(NULL, "Packet-Type");
-       if (!da) {
-               ERROR("Missing definition for Packet-Type");
-               return -1;
-       }
-
        /*
         *      Compile each "send/recv + RADIUS packet type" section.
         *      This is so that the submodules don't need to do this.
@@ -720,7 +710,7 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
                 *      Check that the packet type is known.
                 */
                packet_type = cf_section_name2(subcs);
-               dv = fr_dict_enum_by_alias(da, packet_type, -1);
+               dv = fr_dict_enum_by_alias(attr_packet_type, packet_type, -1);
                if (!dv || (dv->value->vb_uint32 > FR_CODE_DO_NOT_RESPOND) ||
                    !code2component[dv->value->vb_uint32]) {
                        cf_log_err(subcs, "Invalid RADIUS packet type in '%s %s {...}'", name, packet_type);
index f9c4816b675275e0d09c1bef0c78868581e7debd..930561a230d9d268d0b780dd0c9a5460f3543366 100644 (file)
@@ -88,6 +88,7 @@ fr_dict_autoload_t proto_radius_auth_dict[] = {
        { NULL }
 };
 
+static fr_dict_attr_t const *attr_calling_station_id;
 static fr_dict_attr_t const *attr_auth_type;
 static fr_dict_attr_t const *attr_module_failure_message;
 static fr_dict_attr_t const *attr_module_success_message;
@@ -97,6 +98,7 @@ static fr_dict_attr_t const *attr_service_type;
 static fr_dict_attr_t const *attr_state;
 static fr_dict_attr_t const *attr_user_name;
 static fr_dict_attr_t const *attr_user_password;
+static fr_dict_attr_t const *attr_nas_port;
 
 extern fr_dict_attr_autoload_t proto_radius_auth_dict_attr[];
 fr_dict_attr_autoload_t proto_radius_auth_dict_attr[] = {
@@ -104,14 +106,45 @@ fr_dict_attr_autoload_t proto_radius_auth_dict_attr[] = {
        { .out = &attr_module_failure_message, .name = "Module-Failure-Message", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
        { .out = &attr_module_success_message, .name = "Module-Success-Message", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
        { .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_freeradius },
+
+       { .out = &attr_calling_station_id, .name = "Calling-Station-Id", .type = FR_TYPE_STRING, .dict = &dict_radius },
        { .out = &attr_chap_password, .name = "CHAP-Password", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
        { .out = &attr_service_type, .name = "Service-Type", .type = FR_TYPE_UINT32, .dict = &dict_radius },
        { .out = &attr_state, .name = "State", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
        { .out = &attr_user_name, .name = "User-Name", .type = FR_TYPE_STRING, .dict = &dict_radius },
        { .out = &attr_user_password, .name = "User-Password", .type = FR_TYPE_STRING, .dict = &dict_radius },
+       { .out = &attr_nas_port, .name = "NAS-Port", .type = FR_TYPE_UINT32, .dict = &dict_radius },
+
        { NULL }
 };
 
+/*
+ *     Return a short string showing the terminal server, port
+ *     and calling station ID.
+ */
+static char *auth_name(char *buf, size_t buflen, REQUEST *request, bool do_cli)
+{
+       VALUE_PAIR      *cli;
+       VALUE_PAIR      *pair;
+       uint32_t        port = 0;       /* RFC 2865 NAS-Port is 4 bytes */
+       char const      *tls = "";
+
+       cli = fr_pair_find_by_da(request->packet->vps, attr_calling_station_id, TAG_ANY);
+       if (!cli) do_cli = false;
+
+       pair = fr_pair_find_by_da(request->packet->vps, attr_nas_port, TAG_ANY);
+       if (pair != NULL) port = pair->vp_uint32;
+
+       if (request->packet->dst_port == 0) tls = " via proxy to virtual server";
+
+       snprintf(buf, buflen, "from client %.128s port %u%s%.128s%s",
+                request->client->shortname, port,
+                (do_cli ? " cli " : ""), (do_cli ? cli->vp_strvalue : ""),
+                tls);
+
+       return buf;
+}
+
 /*
  *     Make sure user/pass are clean and then create an attribute
  *     which contains the log message.