[monitoring-plugins] check_radius: Support FreeRADIUS Client library

Holger Weiss git at monitoring-plugins.org
Sun Jun 22 21:50:08 CEST 2014


 Module: monitoring-plugins
 Branch: master
 Commit: c0311d98481b783f1d24dd6c59fe25ce994a090d
 Author: Holger Weiss <holger at zedat.fu-berlin.de>
   Date: Sun Jun 22 14:10:38 2014 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=c0311d9

check_radius: Support FreeRADIUS Client library

Allow for using the FreeRADIUS Client library instead of radiusclient or
radiusclient-ng.  The latter two projects are dead.

Closes #1231.

---

 NEWS                   |  1 +
 REQUIREMENTS           | 10 ++++++----
 configure.ac           | 11 +++++++++--
 plugins/check_radius.c | 21 ++++++++++++++-------
 4 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/NEWS b/NEWS
index 4c51179..796bb2d 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ This file documents the major additions and syntax changes between releases.
 	check_ide_smart now defaults to plugin output, original output appended with -v
 	Extra-Opts are now enabled by default
 	check_swap now supports a configurable state when there is no swap
+	check_radius now supports the FreeRADIUS Client library
 
 	FIXES
 	Don't let e.g. check_http's -C option reset SSL version if e.g. -S 1 -C 5 is specified
diff --git a/REQUIREMENTS b/REQUIREMENTS
index 994764c..303fd62 100644
--- a/REQUIREMENTS
+++ b/REQUIREMENTS
@@ -50,14 +50,16 @@ check_dbi:
 	  http://libdbi.sourceforge.net/
 
 check_radius:
-	- Requires the radiusclient-ng library available from:
+	- Requires the FreeRADIUS Client library available from:
+	  http://freeradius.org/freeradius-client/
+	- As an alternative, the radiusclient-ng library may be used:
 	  http://sourceforge.net/projects/radiusclient-ng.berlios/
 	- This plugin also works with the original radiusclient library from
 	  ftp://ftp.cityline.net/pub/radiusclient/
 		RPM (rpmfind): radiusclient 0.3.2, radiusclient-devel-0.3.2
-	  Unless you're using a distro-maintained version of this library you
-	  probably want to use radiusclient-ng. The original radiusclient library is
-	  unmaintained and has many known issues, particularly with 64bit systems.
+	  However, you probably want to use the FreeRADIUS Client library, as
+	  both radiusclient and radiusclient-ng are unmaintained and have known
+	  issues.
 
 check_snmp:
 	- Requires the NET-SNMP package available from
diff --git a/configure.ac b/configure.ac
index a7501ab..9aaa515 100644
--- a/configure.ac
+++ b/configure.ac
@@ -286,8 +286,15 @@ AS_IF([test "x$with_radius" != "xno"], [
     	  RADIUSLIBS="-lradiusclient-ng"
       AC_SUBST(RADIUSLIBS)
     else
-      AC_MSG_WARN([Skipping radius plugin])
-      AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
+      AC_CHECK_LIB(freeradius-client,rc_read_config)
+      if test "$ac_cv_lib_freeradius_client_rc_read_config" = "yes"; then
+        EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
+        RADIUSLIBS="-lfreeradius-client"
+        AC_SUBST(RADIUSLIBS)
+      else
+        AC_MSG_WARN([Skipping radius plugin])
+        AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
+      fi
     fi
   fi
   LIBS="$_SAVEDLIBS"
diff --git a/plugins/check_radius.c b/plugins/check_radius.c
index 3481f0c..9394d26 100644
--- a/plugins/check_radius.c
+++ b/plugins/check_radius.c
@@ -36,9 +36,10 @@ const char *email = "devel at monitoring-plugins.org";
 #include "utils.h"
 #include "netutils.h"
 
-#ifdef HAVE_LIBRADIUSCLIENT_NG
+#if defined(HAVE_LIBFREERADIUS_CLIENT)
+#include <freeradius-client.h>
+#elif defined(HAVE_LIBRADIUSCLIENT_NG)
 #include <radiusclient-ng.h>
-rc_handle *rch = NULL;
 #else
 #include <radiusclient.h>
 #endif
@@ -47,11 +48,14 @@ int process_arguments (int, char **);
 void print_help (void);
 void print_usage (void);
 
-/* libradiusclient(-ng) wrapper functions */
-#ifdef HAVE_LIBRADIUSCLIENT_NG
+#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG)
 #define my_rc_conf_str(a) rc_conf_str(rch,a)
 #define my_rc_send_server(a,b) rc_send_server(rch,a,b)
+#ifdef HAVE_LIBFREERADIUS_CLIENT
+#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,(a)->secret,e,f)
+#else
 #define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,e,f)
+#endif
 #define my_rc_own_ipaddress() rc_own_ipaddress(rch)
 #define my_rc_avpair_add(a,b,c,d) rc_avpair_add(rch,a,b,c,-1,d)
 #define my_rc_read_dictionary(a) rc_read_dictionary(rch, a)
@@ -72,6 +76,10 @@ void print_usage (void);
 
 int my_rc_read_config(char *);
 
+#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG)
+rc_handle *rch = NULL;
+#endif
+
 char *server = NULL;
 char *username = NULL;
 char *password = NULL;
@@ -142,11 +150,10 @@ Please note that all tags must be lowercase to use the DocBook XML DTD.
 int
 main (int argc, char **argv)
 {
-	UINT4 service;
 	char msg[BUFFER_LEN];
 	SEND_DATA data;
 	int result = STATE_UNKNOWN;
-	UINT4 client_id;
+	uint32_t client_id, service;
 	char *str;
 
 	setlocale (LC_ALL, "");
@@ -392,7 +399,7 @@ print_usage (void)
 
 int my_rc_read_config(char * a)
 {
-#ifdef HAVE_LIBRADIUSCLIENT_NG
+#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG)
 	rch = rc_read_config(a);
 	return (rch == NULL) ? 1 : 0;
 #else



More information about the Commits mailing list