From 8dcf3e2a2b53342b0d6a65d7078b6c4629548321 Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Wed, 29 Sep 2010 16:36:24 +0200 Subject: [PATCH] Enable building WITHOUT_ACCOUNTING --- src/include/radiusd.h | 2 ++ src/main/event.c | 24 ++++++++++++++++++------ src/main/listen.c | 14 ++++++++++---- src/main/modules.c | 8 ++++++++ src/main/stats.c | 12 ++++++++++-- src/modules/rlm_always/rlm_always.c | 6 ++++++ src/modules/rlm_detail/rlm_detail.c | 2 ++ src/modules/rlm_radutmp/rlm_radutmp.c | 12 ++++++++++++ src/modules/rlm_sql/rlm_sql.c | 16 ++++++++++++++++ 9 files changed, 84 insertions(+), 12 deletions(-) diff --git a/src/include/radiusd.h b/src/include/radiusd.h index b4ee911..dbb128d 100644 --- a/src/include/radiusd.h +++ b/src/include/radiusd.h @@ -402,7 +402,9 @@ typedef struct main_config_t { int log_auth_goodpass; int allow_core_dumps; int debug_level; +#ifdef WITH_PROXY int proxy_requests; +#endif int reject_delay; int status_server; int max_request_time; diff --git a/src/main/event.c b/src/main/event.c index 5254374..a67d90b 100644 --- a/src/main/event.c +++ b/src/main/event.c @@ -2572,8 +2572,11 @@ static void request_post_handler(REQUEST *request) * and it should re-send it. * If configured, encode, sign, and send. */ - if ((request->reply->code != 0) || - (request->listener->type == RAD_LISTEN_DETAIL)) { + if ((request->reply->code != 0) +#ifdef WITH_DETAIL + || (request->listener->type == RAD_LISTEN_DETAIL) +#endif + ) { DEBUG_PACKET(request, request->reply, 1); request->listener->send(request->listener, request); } @@ -3015,7 +3018,10 @@ int received_request(rad_listen_t *listener, /* * We may want to quench the new request. */ - if ((listener->type != RAD_LISTEN_DETAIL) && + if ( +#ifdef WITH_DETAIL + (listener->type != RAD_LISTEN_DETAIL) && +#endif !can_handle_new_request(packet, client, root)) { return 0; } @@ -3644,7 +3650,10 @@ int event_new_fd(rad_listen_t *this) */ if (this->status == RAD_LISTEN_STATUS_CLOSED) { int count = this->count; + +#ifdef WITH_DETAIL rad_assert(this->type != RAD_LISTEN_DETAIL); +#endif #ifdef WITH_PROXY /* @@ -3920,7 +3929,10 @@ static void event_socket_handler(fr_event_list_t *xel, UNUSED int fd, xel = xel; - if ((listener->type != RAD_LISTEN_DETAIL) && + if ( +#ifdef WITH_DETAIL + (listener->type != RAD_LISTEN_DETAIL) && +#endif (listener->fd < 0)) { char buffer[256]; @@ -3940,7 +3952,7 @@ static void event_socket_handler(fr_event_list_t *xel, UNUSED int fd, thread_pool_addrequest(request, fun); } - +#ifdef WITH_DETAIL /* * This function is called periodically to see if this detail * file is available for reading. @@ -3972,7 +3984,7 @@ static void event_poll_detail(void *ctx) exit(1); } } - +#endif static void event_status(struct timeval *wake) { diff --git a/src/main/listen.c b/src/main/listen.c index 92c6fde..54dc3a6 100644 --- a/src/main/listen.c +++ b/src/main/listen.c @@ -2844,8 +2844,11 @@ RADCLIENT_LIST *listener_find_client_list(const fr_ipaddr_t *ipaddr, for (this = mainconfig.listen; this != NULL; this = this->next) { listen_socket_t *sock; - if ((this->type != RAD_LISTEN_AUTH) && - (this->type != RAD_LISTEN_ACCT)) continue; + if ((this->type != RAD_LISTEN_AUTH) +#ifdef WITH_ACCOUNTING + && (this->type != RAD_LISTEN_ACCT) +#endif + ) continue; sock = this->data; @@ -2870,8 +2873,11 @@ rad_listen_t *listener_find_byipaddr(const fr_ipaddr_t *ipaddr, int port) * FIXME: For TCP, ignore the *secondary* * listeners associated with the main socket. */ - if ((this->type != RAD_LISTEN_AUTH) && - (this->type != RAD_LISTEN_ACCT)) continue; + if ((this->type != RAD_LISTEN_AUTH) +#ifdef WITH_ACCOUNTING + && (this->type != RAD_LISTEN_ACCT) +#endif + ) continue; sock = this->data; diff --git a/src/main/modules.c b/src/main/modules.c index a569c07..e8db884 100644 --- a/src/main/modules.c +++ b/src/main/modules.c @@ -1106,6 +1106,14 @@ static int load_byserver(CONF_SECTION *cs) continue; } +#ifdef WITHOUT_ACCOUNTING + if (comp == RLM_COMPONENT_ACCT) continue; +#endif + +#ifdef WITHOUT_SESSION_MGMT + if (comp == RLM_COMPONENT_SESS) continue; +#endif + if (load_component_section(subcs, components, comp) < 0) { goto error; } diff --git a/src/main/stats.c b/src/main/stats.c index 85afcf8..ced48bb 100644 --- a/src/main/stats.c +++ b/src/main/stats.c @@ -55,15 +55,21 @@ void request_stats_final(REQUEST *request) if (request->master_state == REQUEST_COUNTED) return; if ((request->listener->type != RAD_LISTEN_NONE) && - (request->listener->type != RAD_LISTEN_AUTH) && - (request->listener->type != RAD_LISTEN_ACCT)) return; +#ifdef WITH_ACCOUNTING + (request->listener->type != RAD_LISTEN_ACCT) && +#endif + (request->listener->type != RAD_LISTEN_AUTH)) return; #undef INC_AUTH #define INC_AUTH(_x) radius_auth_stats._x++;request->listener->stats._x++;if (request->client && request->client->auth) request->client->auth->_x++; #undef INC_ACCT +#ifdef WITH_ACCOUNTING #define INC_ACCT(_x) radius_acct_stats._x++;request->listener->stats._x++;if (request->client && request->client->acct) request->client->acct->_x++ +#else +#define INC_ACCT(_x) +#endif /* * Update the statistics. @@ -366,6 +372,7 @@ void request_stats_reply(REQUEST *request) thread_pool_queue_stats(array); +#ifdef WITH_DETAIL for (i = 0; i <= RAD_LISTEN_DETAIL; i++) { vp = radius_paircreate(request, &request->reply->vps, 162 + i, VENDORPEC_FREERADIUS, @@ -375,6 +382,7 @@ void request_stats_reply(REQUEST *request) vp->vp_integer = array[i]; } #endif +#endif } /* diff --git a/src/modules/rlm_always/rlm_always.c b/src/modules/rlm_always/rlm_always.c index 5e688f6..33a9920 100644 --- a/src/modules/rlm_always/rlm_always.c +++ b/src/modules/rlm_always/rlm_always.c @@ -130,6 +130,7 @@ static int always_return(void *instance, REQUEST *request) return ((struct rlm_always_t *)instance)->rcode; } +#ifdef WITH_SESSION_MGMT /* * checksimul fakes some other variables besides the rcode... */ @@ -144,6 +145,7 @@ static int always_checksimul(void *instance, REQUEST *request) return inst->rcode; } +#endif static int always_detach(void *instance) { @@ -162,7 +164,11 @@ module_t rlm_always = { always_return, /* authorization */ always_return, /* preaccounting */ always_return, /* accounting */ +#ifdef WITH_SESSION_MGMT always_checksimul, /* checksimul */ +#else + NULL, +#endif always_return, /* pre-proxy */ always_return, /* post-proxy */ always_return /* post-auth */ diff --git a/src/modules/rlm_detail/rlm_detail.c b/src/modules/rlm_detail/rlm_detail.c index 6446359..8436317 100644 --- a/src/modules/rlm_detail/rlm_detail.c +++ b/src/modules/rlm_detail/rlm_detail.c @@ -478,12 +478,14 @@ static int do_detail(void *instance, REQUEST *request, RADIUS_PACKET *packet, */ static int detail_accounting(void *instance, REQUEST *request) { +#ifdef WITH_DETAIL if (request->listener->type == RAD_LISTEN_DETAIL && strcmp(((struct detail_instance *)instance)->detailfile, ((listen_detail_t *)request->listener->data)->filename) == 0) { RDEBUG("Suppressing writes to detail file as the request was just read from a detail file."); return RLM_MODULE_NOOP; } +#endif return do_detail(instance,request,request->packet, TRUE); } diff --git a/src/modules/rlm_radutmp/rlm_radutmp.c b/src/modules/rlm_radutmp/rlm_radutmp.c index 685efcb..65fe1c0 100644 --- a/src/modules/rlm_radutmp/rlm_radutmp.c +++ b/src/modules/rlm_radutmp/rlm_radutmp.c @@ -175,6 +175,7 @@ static NAS_PORT *nas_port_find(NAS_PORT *nas_port_list, uint32_t nasaddr, unsign } +#ifdef WITH_ACCOUNTING /* * Store logins in the RADIUS utmp file. */ @@ -545,7 +546,9 @@ static int radutmp_accounting(void *instance, REQUEST *request) return RLM_MODULE_OK; } +#endif +#ifdef WITH_SESSION_MGMT /* * See if a user is already logged in. Sets request->simul_count to the * current session count for this user and sets request->simul_mpp to 2 @@ -725,6 +728,7 @@ static int radutmp_checksimul(void *instance, REQUEST *request) return RLM_MODULE_OK; } +#endif /* globally exported name */ module_t rlm_radutmp = { @@ -737,8 +741,16 @@ module_t rlm_radutmp = { NULL, /* authentication */ NULL, /* authorization */ NULL, /* preaccounting */ +#ifdef WITH_ACCOUNTING radutmp_accounting, /* accounting */ +#else + NULL, +#endif +#ifdef WITH_SESSION_MGMT radutmp_checksimul, /* checksimul */ +#else + NULL, +#endif NULL, /* pre-proxy */ NULL, /* post-proxy */ NULL /* post-auth */ diff --git a/src/modules/rlm_sql/rlm_sql.c b/src/modules/rlm_sql/rlm_sql.c index 15da1c6..9bc0d35 100644 --- a/src/modules/rlm_sql/rlm_sql.c +++ b/src/modules/rlm_sql/rlm_sql.c @@ -81,6 +81,7 @@ static const CONF_PARSER module_config[] = { offsetof(SQL_CONFIG,authorize_group_check_query), NULL, ""}, {"authorize_group_reply_query", PW_TYPE_STRING_PTR, offsetof(SQL_CONFIG,authorize_group_reply_query), NULL, ""}, +#ifdef WITH_ACCOUNTING {"accounting_onoff_query", PW_TYPE_STRING_PTR, offsetof(SQL_CONFIG,accounting_onoff_query), NULL, ""}, {"accounting_update_query", PW_TYPE_STRING_PTR, @@ -95,14 +96,17 @@ static const CONF_PARSER module_config[] = { offsetof(SQL_CONFIG,accounting_stop_query), NULL, ""}, {"accounting_stop_query_alt", PW_TYPE_STRING_PTR, offsetof(SQL_CONFIG,accounting_stop_query_alt), NULL, ""}, +#endif {"group_membership_query", PW_TYPE_STRING_PTR, offsetof(SQL_CONFIG,groupmemb_query), NULL, NULL}, {"connect_failure_retry_delay", PW_TYPE_INTEGER, offsetof(SQL_CONFIG,connect_failure_retry_delay), NULL, "60"}, +#ifdef WITH_SESSION_MGMT {"simul_count_query", PW_TYPE_STRING_PTR, offsetof(SQL_CONFIG,simul_count_query), NULL, ""}, {"simul_verify_query", PW_TYPE_STRING_PTR, offsetof(SQL_CONFIG,simul_verify_query), NULL, ""}, +#endif {"postauth_query", PW_TYPE_STRING_PTR, offsetof(SQL_CONFIG,postauth_query), NULL, ""}, {"safe-characters", PW_TYPE_STRING_PTR, @@ -1167,6 +1171,7 @@ static int rlm_sql_authorize(void *instance, REQUEST * request) } } +#ifdef WITH_ACCOUNTING /* * Accounting: save the account data to our sql table */ @@ -1396,8 +1401,10 @@ static int rlm_sql_accounting(void *instance, REQUEST * request) { return ret; } +#endif +#ifdef WITH_SESSION_MGMT /* * See if a user is already logged in. Sets request->simul_count to the * current session count for this user. @@ -1584,6 +1591,7 @@ static int rlm_sql_checksimul(void *instance, REQUEST * request) { */ return RLM_MODULE_OK; } +#endif /* * Execute postauth_query after authentication @@ -1640,8 +1648,16 @@ module_t rlm_sql = { NULL, /* authentication */ rlm_sql_authorize, /* authorization */ NULL, /* preaccounting */ +#ifdef WITH_ACCOUNTING rlm_sql_accounting, /* accounting */ +#else + NULL, +#endif +#ifdef WITH_SESSION_MGMT rlm_sql_checksimul, /* checksimul */ +#else + NULL, +#endif NULL, /* pre-proxy */ NULL, /* post-proxy */ rlm_sql_postauth /* post-auth */ -- 2.1.4