From adf43b35cc8acd0e3c86bbcd83448afa83a49f8c Mon Sep 17 00:00:00 2001 From: "Sergey V. Lobanov" Date: Thu, 22 Aug 2024 21:36:12 +0000 Subject: [PATCH] logwtmp check --- accel-pppd/CMakeLists.txt | 13 +++++++++++++ accel-pppd/extra/logwtmp.c | 7 +++++++ tests/accel-pppd/general/test_basic.py | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/accel-pppd/CMakeLists.txt b/accel-pppd/CMakeLists.txt index cd7186ba..496fbdca 100644 --- a/accel-pppd/CMakeLists.txt +++ b/accel-pppd/CMakeLists.txt @@ -71,6 +71,19 @@ IF (HAVE_GOOD_IFARP) ADD_DEFINITIONS(-DHAVE_GOOD_IFARP) ENDIF (HAVE_GOOD_IFARP) +INCLUDE (CheckCSourceCompiles) +CHECK_C_SOURCE_COMPILES(" +#include +int main(void) +{ + logwtmp(\"\", \"\", \"\"); + return 0; +}" HAVE_LOGWTMP) + +IF (HAVE_LOGWTMP) + ADD_DEFINITIONS(-DHAVE_LOGWTMP) +ENDIF (HAVE_LOGWTMP) + ADD_SUBDIRECTORY(triton) ADD_SUBDIRECTORY(vlan-mon) diff --git a/accel-pppd/extra/logwtmp.c b/accel-pppd/extra/logwtmp.c index f95b62c4..f27234d4 100644 --- a/accel-pppd/extra/logwtmp.c +++ b/accel-pppd/extra/logwtmp.c @@ -14,6 +14,7 @@ #include "memdebug.h" +#ifdef HAVE_LOGWTMP static void ev_ses_started(struct ap_session *ses) { logwtmp(ses->ifname, ses->username ?: "", ses->ctrl->calling_station_id); @@ -29,5 +30,11 @@ static void init(void) triton_event_register_handler(EV_SES_STARTED, (triton_event_func)ev_ses_started); triton_event_register_handler(EV_SES_FINISHED, (triton_event_func)ev_ses_finished); } +#else +static void init(void) +{ + log_warn("logwtmp is not supported on your platfrom, check libc doc"); +} +#endif DEFINE_INIT(200, init); diff --git a/tests/accel-pppd/general/test_basic.py b/tests/accel-pppd/general/test_basic.py index fe2f8093..9652ee0b 100644 --- a/tests/accel-pppd/general/test_basic.py +++ b/tests/accel-pppd/general/test_basic.py @@ -39,7 +39,7 @@ def accel_pppd_config(): pppd_compat shaper #net-snmp - #logwtmp + logwtmp ipv6_nd ipv6_dhcp