From: Alan T. DeKok Date: Wed, 26 Oct 2011 07:26:42 +0000 (+0200) Subject: Rearranged code to build with various compile options X-Git-Tag: release_3_0_0_beta0~545 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec453961fd628db702392ff1599e55111c6b7226;p=thirdparty%2Ffreeradius-server.git Rearranged code to build with various compile options 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... --- diff --git a/src/include/radiusd.h b/src/include/radiusd.h index b8598ffce9e..c1d665d973c 100644 --- a/src/include/radiusd.h +++ b/src/include/radiusd.h @@ -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 diff --git a/src/include/stats.h b/src/include/stats.h index d1d3a438a60..a5c8fe3a775 100644 --- a/src/include/stats.h +++ b/src/include/stats.h @@ -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 diff --git a/src/include/tls.h b/src/include/tls.h index 20e4422152b..333698a67d4 100644 --- a/src/include/tls.h +++ b/src/include/tls.h @@ -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 */ diff --git a/src/main/cb.c b/src/main/cb.c index e7bc760d7ec..e42713cfde5 100644 --- a/src/main/cb.c +++ b/src/main/cb.c @@ -27,7 +27,7 @@ RCSID("$Id$") #include #include -#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 diff --git a/src/main/evaluate.c b/src/main/evaluate.c index d5c6929fafd..92dd0fad4f0 100644 --- a/src/main/evaluate.c +++ b/src/main/evaluate.c @@ -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" */ diff --git a/src/main/modcall.c b/src/main/modcall.c index 82805317aaf..15449727cad 100644 --- a/src/main/modcall.c +++ b/src/main/modcall.c @@ -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. diff --git a/src/main/process.c b/src/main/process.c index d70119c15f1..a5dceef811e 100644 --- a/src/main/process.c +++ b/src/main/process.c @@ -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 { diff --git a/src/main/valuepair.c b/src/main/valuepair.c index 8e48f1f0b75..091ee416751 100644 --- a/src/main/valuepair.c +++ b/src/main/valuepair.c @@ -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; +} diff --git a/src/modules/rlm_dynamic_clients/rlm_dynamic_clients.c b/src/modules/rlm_dynamic_clients/rlm_dynamic_clients.c index 163d7d71d4e..565bd1b54da 100644 --- a/src/modules/rlm_dynamic_clients/rlm_dynamic_clients.c +++ b/src/modules/rlm_dynamic_clients/rlm_dynamic_clients.c @@ -27,6 +27,7 @@ RCSID("$Id$") #include #include +#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. diff --git a/src/modules/rlm_replicate/rlm_replicate.c b/src/modules/rlm_replicate/rlm_replicate.c index 2fc4fa25c66..2ea3290909b 100644 --- a/src/modules/rlm_replicate/rlm_replicate.c +++ b/src/modules/rlm_replicate/rlm_replicate.c @@ -27,7 +27,7 @@ RCSID("$Id$") #include #include - +#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.