From ade5c8a2a47d2c2b1b0a4ab70eabd4bc095bd289 Mon Sep 17 00:00:00 2001 From: Kevin Harwell Date: Tue, 28 Jan 2014 23:23:15 +0000 Subject: cdr_radius, cel_radius: build agains libfreeradius-client MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Asterisk's RADIUS module currently build against libradiusclient-ng, but this project has been superseeded by libfreeradius-client. The API is 99% compatible except that the header name has changed, the library name has changed, and the configuration file location has changed. (closes issue ASTERISK-22980) Reported by: Jeremy Lainé Patches: freeradius-client.patch uploaded by sharky (license 6561) ........ Merged revisions 406801 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 406802 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 406803 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@406825 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- cdr/cdr_radius.c | 8 +++ cel/cel_radius.c | 8 +++ configure | 114 ++++++++++++++++++++++++++++++++++++++- configure.ac | 9 +++- include/asterisk/autoconfig.h.in | 3 ++ 5 files changed, 140 insertions(+), 2 deletions(-) diff --git a/cdr/cdr_radius.c b/cdr/cdr_radius.c index 1466808d5..5f8f0fa4a 100644 --- a/cdr/cdr_radius.c +++ b/cdr/cdr_radius.c @@ -41,7 +41,11 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +#ifdef FREERADIUS_CLIENT +#include +#else #include +#endif #include "asterisk/channel.h" #include "asterisk/cdr.h" @@ -87,7 +91,11 @@ static const char desc[] = "RADIUS CDR Backend"; static const char name[] = "radius"; static const char cdr_config[] = "cdr.conf"; +#ifdef FREERADIUS_CLIENT +static char radiuscfg[PATH_MAX] = "/etc/radiusclient/radiusclient.conf"; +#else static char radiuscfg[PATH_MAX] = "/etc/radiusclient-ng/radiusclient.conf"; +#endif static struct ast_flags global_flags = { RADIUS_FLAG_USEGMTIME | RADIUS_FLAG_LOGUNIQUEID | RADIUS_FLAG_LOGUSERFIELD }; diff --git a/cel/cel_radius.c b/cel/cel_radius.c index be5a9e66f..aafdfcb05 100644 --- a/cel/cel_radius.c +++ b/cel/cel_radius.c @@ -35,7 +35,11 @@ ASTERISK_FILE_VERSION(__FILE__, "$Rev$") +#ifdef FREERADIUS_CLIENT +#include +#else #include +#endif #include "asterisk/channel.h" #include "asterisk/cel.h" @@ -79,7 +83,11 @@ enum { static char *cel_config = "cel.conf"; +#ifdef FREERADIUS_CLIENT +static char radiuscfg[PATH_MAX] = "/etc/radiusclient/radiusclient.conf"; +#else static char radiuscfg[PATH_MAX] = "/etc/radiusclient-ng/radiusclient.conf"; +#endif static struct ast_flags global_flags = { RADIUS_FLAG_USEGMTIME | RADIUS_FLAG_LOGUNIQUEID | RADIUS_FLAG_LOGUSERFIELD }; diff --git a/configure b/configure index 815bb64c0..84de43aa2 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac Revision: 403330 . +# From configure.ac Revision: 405130 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for asterisk trunk. # @@ -27758,6 +27758,117 @@ fi +# Accept either RADIUS client library, their APIs are fully compatible, +# just different header filenames and different SONAMEs + +if test "x${PBX_RADIUS}" != "x1" -a "${USE_RADIUS}" != "no"; then + pbxlibdir="" + # if --with-RADIUS=DIR has been specified, use it. + if test "x${RADIUS_DIR}" != "x"; then + if test -d ${RADIUS_DIR}/lib; then + pbxlibdir="-L${RADIUS_DIR}/lib" + else + pbxlibdir="-L${RADIUS_DIR}" + fi + fi + pbxfuncname="rc_read_config" + if test "x${pbxfuncname}" = "x" ; then # empty lib, assume only headers + AST_RADIUS_FOUND=yes + else + ast_ext_lib_check_save_CFLAGS="${CFLAGS}" + CFLAGS="${CFLAGS} " + as_ac_Lib=`$as_echo "ac_cv_lib_freeradius-client_${pbxfuncname}" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${pbxfuncname} in -lfreeradius-client" >&5 +$as_echo_n "checking for ${pbxfuncname} in -lfreeradius-client... " >&6; } +if eval \${$as_ac_Lib+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lfreeradius-client ${pbxlibdir} $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char ${pbxfuncname} (); +int +main () +{ +return ${pbxfuncname} (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$as_ac_Lib=yes" +else + eval "$as_ac_Lib=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +eval ac_res=\$$as_ac_Lib + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : + AST_RADIUS_FOUND=yes +else + AST_RADIUS_FOUND=no +fi + + CFLAGS="${ast_ext_lib_check_save_CFLAGS}" + fi + + # now check for the header. + if test "${AST_RADIUS_FOUND}" = "yes"; then + RADIUS_LIB="${pbxlibdir} -lfreeradius-client " + # if --with-RADIUS=DIR has been specified, use it. + if test "x${RADIUS_DIR}" != "x"; then + RADIUS_INCLUDE="-I${RADIUS_DIR}/include" + fi + RADIUS_INCLUDE="${RADIUS_INCLUDE} " + if test "xfreeradius-client.h" = "x" ; then # no header, assume found + RADIUS_HEADER_FOUND="1" + else # check for the header + ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}" + CPPFLAGS="${CPPFLAGS} ${RADIUS_INCLUDE}" + ac_fn_c_check_header_mongrel "$LINENO" "freeradius-client.h" "ac_cv_header_freeradius_client_h" "$ac_includes_default" +if test "x$ac_cv_header_freeradius_client_h" = xyes; then : + RADIUS_HEADER_FOUND=1 +else + RADIUS_HEADER_FOUND=0 +fi + + + CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}" + fi + if test "x${RADIUS_HEADER_FOUND}" = "x0" ; then + RADIUS_LIB="" + RADIUS_INCLUDE="" + else + if test "x${pbxfuncname}" = "x" ; then # only checking headers -> no library + RADIUS_LIB="" + fi + PBX_RADIUS=1 + cat >>confdefs.h <<_ACEOF +#define HAVE_RADIUS 1 +_ACEOF + + fi + fi +fi + + +if test "x${PBX_RADIUS}" = "x1"; then + +$as_echo "#define FREERADIUS_CLIENT /**/" >>confdefs.h + +else if test "x${PBX_RADIUS}" != "x1" -a "${USE_RADIUS}" != "no"; then pbxlibdir="" @@ -27862,6 +27973,7 @@ _ACEOF fi +fi if test "x${PBX_COROSYNC}" != "x1" -a "${USE_COROSYNC}" != "no"; then diff --git a/configure.ac b/configure.ac index fb14b2936..80fbcf59c 100644 --- a/configure.ac +++ b/configure.ac @@ -2134,7 +2134,14 @@ fi # Some distributions (like SuSE) remove the 5.1 suffix. AST_EXT_LIB_CHECK([LUA], [lua], [luaL_openlib], [lua.h], [-lm]) -AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h]) +# Accept either RADIUS client library, their APIs are fully compatible, +# just different header filenames and different SONAMEs +AST_EXT_LIB_CHECK([RADIUS], [freeradius-client], [rc_read_config], [freeradius-client.h]) +if test "x${PBX_RADIUS}" = "x1"; then + AC_DEFINE(FREERADIUS_CLIENT, [], [Use the FreeRADIUS-client library]) +else + AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h]) +fi AST_EXT_LIB_CHECK([COROSYNC], [cpg], [cpg_join], [corosync/cpg.h], [-lcfg]) AST_EXT_LIB_CHECK([COROSYNC_CFG_STATE_TRACK], [cfg], [corosync_cfg_state_track], [corosync/cfg.h], [-lcfg]) diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in index 71f213518..257081924 100644 --- a/include/asterisk/autoconfig.h.in +++ b/include/asterisk/autoconfig.h.in @@ -29,6 +29,9 @@ /* Define to 1 if using `alloca.c'. */ #undef C_ALLOCA +/* Use the FreeRADIUS-client library */ +#undef FREERADIUS_CLIENT + /* Define to 1 if anonymous semaphores work. */ #undef HAS_WORKING_SEMAPHORE -- cgit v1.2.3