]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
cdr_radius, cel_radius: build agains libfreeradius-client
authorKevin Harwell <kharwell@digium.com>
Tue, 28 Jan 2014 23:02:38 +0000 (23:02 +0000)
committerKevin Harwell <kharwell@digium.com>
Tue, 28 Jan 2014 23:02:38 +0000 (23:02 +0000)
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)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@406801 65c4cc65-6c06-0410-ace0-fbb531ad65f3

cdr/cdr_radius.c
cel/cel_radius.c
configure
configure.ac
include/asterisk/autoconfig.h.in

index 140e7a01c0fd3e569c1937cdc9c92e066bdf2b83..fc28860913b1e8a971349622eb8addfff680c6dc 100644 (file)
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
+#ifdef FREERADIUS_CLIENT
+#include <freeradius-client.h>
+#else
 #include <radiusclient-ng.h>
+#endif
 
 #include "asterisk/channel.h"
 #include "asterisk/cdr.h"
@@ -82,7 +86,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 };
 
index 9b6812dc0e93d375e3e9573e09698736a4c112bf..8d6f647ddd1f939ceb8ab906f91acf1f1b9f6bb0 100644 (file)
 
 ASTERISK_FILE_VERSION(__FILE__, "$Rev$")
 
+#ifdef FREERADIUS_CLIENT
+#include <freeradius-client.h>
+#else
 #include <radiusclient-ng.h>
+#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 };
 
index 9938ebcc96a59d91b109ee98ddefa0756ed1e075..2a35f2da713ba8f983d7b4c14ced09a26673ba1e 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 402192 .
+# From configure.ac Revision: 405090 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.69 for asterisk trunk.
 #
 
 
 
+# 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=""
@@ -26635,6 +26746,7 @@ _ACEOF
 fi
 
 
+fi
 
 # This is a bit complex... in reality, Asterisk's AIS support is dependent on finding
 # *any* implementation of AIS, not just OpenAIS. However, the configure script needs
index 617d7f154680b3355e8e871538fc6c019d8eafb6..6de880d947925e3cc6b623761d4d9bb0b97d313d 100644 (file)
@@ -1995,7 +1995,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
 
 # This is a bit complex... in reality, Asterisk's AIS support is dependent on finding
 # *any* implementation of AIS, not just OpenAIS. However, the configure script needs
index 3f078263cb6da071e8e7c4b729b2993d35a5966c..1ad8e77216d316bc6b53cdbbac6e68e246176226 100644 (file)
@@ -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 you have the `acos' function. */
 #undef HAVE_ACOS