]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Rearranged code to build with various compile options
authorAlan T. DeKok <aland@freeradius.org>
Wed, 26 Oct 2011 07:26:42 +0000 (09:26 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 26 Oct 2011 07:29:01 +0000 (09:29 +0200)
WITHOUT_PROXY
WITHOUT_STATS

etc.

The server should build with any combination of the above options.
While they're not commonly used, they are useful.  When most
functionality is disabled, the server produces a ~600K statically
linked binary with all of the most common modules.

This is suitable for embedded systems...

src/include/radiusd.h
src/include/stats.h
src/include/tls.h
src/main/cb.c
src/main/evaluate.c
src/main/modcall.c
src/main/process.c
src/main/valuepair.c
src/modules/rlm_dynamic_clients/rlm_dynamic_clients.c
src/modules/rlm_replicate/rlm_replicate.c

index b8598ffce9e98f3b175162039a18e52922e267b6..c1d665d973c15339972b81362dd0030c111b8d4d 100644 (file)
@@ -100,10 +100,12 @@ typedef struct auth_req REQUEST;
 #else
 #ifdef HAVE_OPENSSL_SSL_H
 #ifndef WITH_TLS
+#ifndef NO_OPENSSL
 #define WITH_TLS (1)
 #endif
 #endif
 #endif
+#endif
 
 /*
  *     WITH_VMPS is handled by src/include/autoconf.h
index d1d3a438a603a3bb51ececdc97e0d293a75625ae..a5c8fe3a775ba05424d97477bda6f3127add8dae 100644 (file)
@@ -94,7 +94,7 @@ void radius_stats_ema(fr_stats_ema_t *ema,
 #define request_stats_init(_x)
 #define request_stats_final(_x)
 
-#define FR_STATS_INC(_x)
+#define FR_STATS_INC(_x, _y)
 #define FR_STATS_TYPE_INC(_x)
 
 #endif
index 20e4422152be4c780eadb0720386f104d1ce7646..333698a67d4e699774f9d11968783c3bc8a37398 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef FR_TLS_H
 #define FR_TLS_H
 
-#ifndef NO_OPENSSL
+#ifdef WITH_TLS
 
 /*
  * @file tls.h
@@ -388,5 +388,5 @@ struct fr_tls_server_conf_t {
 }
 #endif
 
-#endif /* NO_OPENSSL */
+#endif /* WITH_TLS */
 #endif /* FR_TLS_H */
index e7bc760d7ecf6ee9a7435c16317a8c03d8d7c698..e42713cfde5132ddb4dfb5aa7e83fd5642ae9f54 100644 (file)
@@ -27,7 +27,7 @@ RCSID("$Id$")
 #include <freeradius-devel/autoconf.h>
 #include <freeradius-devel/radiusd.h>
 
-#ifndef NO_OPENSSL
+#ifdef WITH_TLS
 
 void cbtls_info(const SSL *s, int where, int ret)
 {
@@ -129,4 +129,4 @@ int cbtls_password(char *buf,
        return(strlen((char *)userdata));
 }
 
-#endif /* !defined(NO_OPENSSL) */
+#endif
index d5c6929fafd17d317d23c38373561fa60ae4f8b5..92dd0fad4f0dddb36ba9f65126891c1549259082 100644 (file)
@@ -203,101 +203,6 @@ static const FR_NAME_NUMBER modreturn_table[] = {
 };
 
 
-int radius_get_vp(REQUEST *request, const char *name, VALUE_PAIR **vp_p)
-{
-       const char *vp_name = name;
-       REQUEST *myrequest = request;
-       DICT_ATTR *da;
-       VALUE_PAIR *vps = NULL;
-
-       *vp_p = NULL;
-
-       /*
-        *      Allow for tunneled sessions.
-        */
-       if (strncmp(vp_name, "outer.", 6) == 0) {
-               if (!myrequest->parent) return TRUE;
-               vp_name += 6;
-               myrequest = myrequest->parent;
-       }
-
-       if (strncmp(vp_name, "request:", 8) == 0) {
-               vp_name += 8;
-               vps = myrequest->packet->vps;
-
-       } else if (strncmp(vp_name, "reply:", 6) == 0) {
-               vp_name += 6;
-               vps = myrequest->reply->vps;
-
-#ifdef WITH_PROXY
-       } else if (strncmp(vp_name, "proxy-request:", 14) == 0) {
-               vp_name += 14;
-               if (request->proxy) vps = myrequest->proxy->vps;
-
-       } else if (strncmp(vp_name, "proxy-reply:", 12) == 0) {
-               vp_name += 12;
-               if (request->proxy_reply) vps = myrequest->proxy_reply->vps;
-#endif
-
-       } else if (strncmp(vp_name, "config:", 7) == 0) {
-               vp_name += 7;
-               vps = myrequest->config_items;
-
-       } else if (strncmp(vp_name, "control:", 8) == 0) {
-               vp_name += 8;
-               vps = myrequest->config_items;
-
-#ifdef WITH_COA
-       } else if (strncmp(vp_name, "coa:", 4) == 0) {
-               vp_name += 4;
-
-               if (myrequest->coa &&
-                   (myrequest->coa->proxy->code == PW_COA_REQUEST)) {
-                       vps = myrequest->coa->proxy->vps;
-               }
-
-       } else if (strncmp(vp_name, "coa-reply:", 10) == 0) {
-               vp_name += 10;
-
-               if (myrequest->coa && /* match reply with request */
-                   (myrequest->coa->proxy->code == PW_COA_REQUEST) &&
-                   (myrequest->coa->proxy_reply)) {
-                       vps = myrequest->coa->proxy_reply->vps;
-               }
-
-       } else if (strncmp(vp_name, "disconnect:", 11) == 0) {
-               vp_name += 11;
-
-               if (myrequest->coa &&
-                   (myrequest->coa->proxy->code == PW_DISCONNECT_REQUEST)) {
-                       vps = myrequest->coa->proxy->vps;
-               }
-
-       } else if (strncmp(vp_name, "disconnect-reply:", 17) == 0) {
-               vp_name += 17;
-
-               if (myrequest->coa && /* match reply with request */
-                   (myrequest->coa->proxy->code == PW_DISCONNECT_REQUEST) &&
-                   (myrequest->coa->proxy_reply)) {
-                       vps = myrequest->coa->proxy_reply->vps;
-               }
-#endif
-
-       } else {
-               vps = myrequest->packet->vps;
-       }
-
-       da = dict_attrbyname(vp_name);
-       if (!da) return FALSE;  /* not a dictionary name */
-
-       /*
-        *      May not may not be found, but it *is* a known name.
-        */
-       *vp_p = pairfind(vps, da->attr, da->vendor);
-       return TRUE;
-}
-
-
 /*
  *     *presult is "did comparison match or not"
  */
index 82805317aafa319c8a3ed8fb6bad9d66020c6615..15449727cada3756136d89c718e8cdf261e9edde 100644 (file)
@@ -366,11 +366,13 @@ typedef struct modcall_stack {
 } modcall_stack;
 
 
+#ifdef WITH_UNLANG
 static void pairfree_wrapper(void *data)
 {
        VALUE_PAIR **vp = (VALUE_PAIR **) data;
        pairfree(vp);
 }
+#endif
 
 /**
  * @brief Call a module, iteratively, with a local stack, rather than
@@ -784,6 +786,7 @@ int modcall(int component, modcallable *c, REQUEST *request)
                        child->name ? child->name : "",
                        fr_int2str(rcode_table, myresult, "??"));
                
+#ifdef WITH_UNLANG
                if (0) {
                handle_result:
                        if (child->type != MOD_BREAK) {
@@ -793,6 +796,9 @@ int modcall(int component, modcallable *c, REQUEST *request)
                                        fr_int2str(rcode_table, myresult, "??"));
                        }
                }
+#else
+               handle_result:
+#endif
                
                /*
                 *      This is a bit of a hack...
@@ -2068,9 +2074,11 @@ static modcallable *do_compile_modsingle(modcallable *parent,
                }
        }
 
+#ifdef WITH_UNLANG
        if (strcmp(modrefname, "break") == 0) {
                return do_compile_modbreak(parent, component);
        }
+#endif
 
        /*
         *      Not a virtual module.  It must be a real module.
index d70119c15f1d7aa6fe9c0d7218bc4be5be669f1b..a5dceef811e92ff9a9d97629c20e8021dfe2b0d7 100644 (file)
@@ -963,6 +963,7 @@ static int request_pre_handler(REQUEST *request, UNUSED int action)
        if (request->packet->vps == NULL) {
                rcode = request->listener->decode(request->listener, request);
                
+#ifdef WITH_UNLANG
                if (debug_condition) {
                        int result = FALSE;
                        const char *my_debug = debug_condition;
@@ -978,6 +979,7 @@ static int request_pre_handler(REQUEST *request, UNUSED int action)
                                request->radlog = radlog_request;
                        }
                }
+#endif
                
                DEBUG_PACKET(request, request->packet, 0);
        } else {
index 8e48f1f0b7506ea28408fa143e7fd5462b153856..091ee416751e63668145c3d91cf30d139e7baa37 100644 (file)
@@ -822,3 +822,98 @@ void debug_pair_list(VALUE_PAIR *vp)
        }
        fflush(fr_log_fp);
 }
+
+
+int radius_get_vp(REQUEST *request, const char *name, VALUE_PAIR **vp_p)
+{
+       const char *vp_name = name;
+       REQUEST *myrequest = request;
+       DICT_ATTR *da;
+       VALUE_PAIR *vps = NULL;
+
+       *vp_p = NULL;
+
+       /*
+        *      Allow for tunneled sessions.
+        */
+       if (strncmp(vp_name, "outer.", 6) == 0) {
+               if (!myrequest->parent) return TRUE;
+               vp_name += 6;
+               myrequest = myrequest->parent;
+       }
+
+       if (strncmp(vp_name, "request:", 8) == 0) {
+               vp_name += 8;
+               vps = myrequest->packet->vps;
+
+       } else if (strncmp(vp_name, "reply:", 6) == 0) {
+               vp_name += 6;
+               vps = myrequest->reply->vps;
+
+#ifdef WITH_PROXY
+       } else if (strncmp(vp_name, "proxy-request:", 14) == 0) {
+               vp_name += 14;
+               if (request->proxy) vps = myrequest->proxy->vps;
+
+       } else if (strncmp(vp_name, "proxy-reply:", 12) == 0) {
+               vp_name += 12;
+               if (request->proxy_reply) vps = myrequest->proxy_reply->vps;
+#endif
+
+       } else if (strncmp(vp_name, "config:", 7) == 0) {
+               vp_name += 7;
+               vps = myrequest->config_items;
+
+       } else if (strncmp(vp_name, "control:", 8) == 0) {
+               vp_name += 8;
+               vps = myrequest->config_items;
+
+#ifdef WITH_COA
+       } else if (strncmp(vp_name, "coa:", 4) == 0) {
+               vp_name += 4;
+
+               if (myrequest->coa &&
+                   (myrequest->coa->proxy->code == PW_COA_REQUEST)) {
+                       vps = myrequest->coa->proxy->vps;
+               }
+
+       } else if (strncmp(vp_name, "coa-reply:", 10) == 0) {
+               vp_name += 10;
+
+               if (myrequest->coa && /* match reply with request */
+                   (myrequest->coa->proxy->code == PW_COA_REQUEST) &&
+                   (myrequest->coa->proxy_reply)) {
+                       vps = myrequest->coa->proxy_reply->vps;
+               }
+
+       } else if (strncmp(vp_name, "disconnect:", 11) == 0) {
+               vp_name += 11;
+
+               if (myrequest->coa &&
+                   (myrequest->coa->proxy->code == PW_DISCONNECT_REQUEST)) {
+                       vps = myrequest->coa->proxy->vps;
+               }
+
+       } else if (strncmp(vp_name, "disconnect-reply:", 17) == 0) {
+               vp_name += 17;
+
+               if (myrequest->coa && /* match reply with request */
+                   (myrequest->coa->proxy->code == PW_DISCONNECT_REQUEST) &&
+                   (myrequest->coa->proxy_reply)) {
+                       vps = myrequest->coa->proxy_reply->vps;
+               }
+#endif
+
+       } else {
+               vps = myrequest->packet->vps;
+       }
+
+       da = dict_attrbyname(vp_name);
+       if (!da) return FALSE;  /* not a dictionary name */
+
+       /*
+        *      May not may not be found, but it *is* a known name.
+        */
+       *vp_p = pairfind(vps, da->attr, da->vendor);
+       return TRUE;
+}
index 163d7d71d4edb7114f5e42fab4524430cec51e5e..565bd1b54da6bee3aec1c3b7a727a2f246f24055 100644 (file)
@@ -27,6 +27,7 @@ RCSID("$Id$")
 #include <freeradius-devel/radiusd.h>
 #include <freeradius-devel/modules.h>
 
+#ifdef WITH_DYNAMIC_CLIENTS
 /*
  *     Find the client definition.
  */
@@ -89,6 +90,13 @@ static int dynamic_client_authorize(UNUSED void *instance, REQUEST *request)
 
        return RLM_MODULE_OK;
 }
+#else
+static int dynamic_client_authorize(UNUSED void *instance, REQUEST *request)
+{
+       RDEBUG("Dynamic clients are unsupported in this build.");
+       return RLM_MODULE_FAIL;
+}
+#endif
 
 /*
  *     The module name should be the only globally exported symbol.
index 2fc4fa25c6637f88a9325a33ab3ed18c240f1135..2ea3290909be46107b9fa4b6544d30c4c61ed8f5 100644 (file)
@@ -27,7 +27,7 @@ RCSID("$Id$")
 #include <freeradius-devel/radiusd.h>
 #include <freeradius-devel/modules.h>
 
-
+#ifdef WITH_PROXY
 static void cleanup(RADIUS_PACKET *packet)
 {
        if (!packet) return;
@@ -183,6 +183,13 @@ static int replicate_packet(void *instance, REQUEST *request)
        cleanup(packet);
        return rcode;
 }
+#else
+static int replicate_packet(void *instance, REQUEST *request)
+{
+       RDEBUG("Replication is unsupported in this build.");
+       return RLM_MODULE_FAIL;
+}
+#endif
 
 /*
  *     The module name should be the only globally exported symbol.