Преглед изворни кода

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.
Holger Weiss пре 12 година
родитељ
комит
c0311d9848
4 измењених фајлова са 30 додато и 13 уклоњено
  1. 1 0
      NEWS
  2. 6 4
      REQUIREMENTS
  3. 9 2
      configure.ac
  4. 14 7
      plugins/check_radius.c

+ 1 - 0
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

+ 6 - 4
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

+ 9 - 2
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"

+ 14 - 7
plugins/check_radius.c

@@ -36,9 +36,10 @@ const char *email = "devel@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