]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
allow for local "client" files
authorAlan T. DeKok <aland@freeradius.org>
Tue, 26 Mar 2019 16:16:04 +0000 (12:16 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 26 Mar 2019 16:16:04 +0000 (12:16 -0400)
We may want to add a flag saying "allow anything", in which case
it should auto-create a fake client.

src/modules/proto_dhcpv4/proto_dhcpv4_udp.c

index 37f1e82397f2a26ad726718ebb4e62be05476735..8d6055480ace9a495de5bf0e11994bb04c72ed95 100644 (file)
@@ -70,6 +70,8 @@ typedef struct {
                                                                //!< buffer value.
        bool                            dynamic_clients;        //!< whether we have dynamic clients
 
+       RADCLIENT_LIST                  *clients;               //!< local clients
+
        fr_trie_t                       *trie;                  //!< for parsed networks
        fr_ipaddr_t                     *allow;                 //!< allowed networks for dynamic clients
        fr_ipaddr_t                     *deny;                  //!< denied networks for dynamic clients
@@ -650,11 +652,33 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                }
        }
 
+       /*
+        *      Look up local clients, if they exist.
+        *
+        *      @todo - ensure that we only parse clients which are
+        *      for IPPROTO_UDP, and require a "secret".
+        */
+       if (cf_section_find_next(server_cs, NULL, "client", CF_IDENT_ANY)) {
+               inst->clients = client_list_parse_section(server_cs, false);
+               if (!inst->clients) {
+                       cf_log_err(cs, "Failed creating local clients");
+                       return -1;
+               }
+       }
+
        return 0;
 }
 
 static RADCLIENT *mod_client_find(UNUSED fr_listen_t *li, fr_ipaddr_t const *ipaddr, int ipproto)
 {
+       /*
+        *      Prefer local clients.
+        */
+       if (inst->clients) {
+               client = client_find(inst->clients, ipaddr, ipproto);
+               if (client) return client;
+       }
+
        return client_find(NULL, ipaddr, ipproto);
 }