[Nagiosplug-checkins] SF.net SVN: nagiosplug: [1788] nagiosplug/trunk

psychotrahe at users.sourceforge.net psychotrahe at users.sourceforge.net
Sun Sep 23 11:48:38 CEST 2007


Revision: 1788
          http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=1788&view=rev
Author:   psychotrahe
Date:     2007-09-23 02:48:37 -0700 (Sun, 23 Sep 2007)

Log Message:
-----------
Added radiusclient-ng support for check_radius. Thanks to Sebastien Guay (#1218438)

Modified Paths:
--------------
    nagiosplug/trunk/NEWS
    nagiosplug/trunk/THANKS.in
    nagiosplug/trunk/configure.in
    nagiosplug/trunk/plugins/check_radius.c

Modified: nagiosplug/trunk/NEWS
===================================================================
--- nagiosplug/trunk/NEWS	2007-09-22 17:48:33 UTC (rev 1787)
+++ nagiosplug/trunk/NEWS	2007-09-23 09:48:37 UTC (rev 1788)
@@ -25,7 +25,8 @@
 	WARNING: check_disk's -E option must now be passed before -p or -r/-R arguments
 	  Passing -E after -p or -r results in UNKNOWN state, now
 	  This is needed due to the new ignore feature
-	Fix bug when mixing case sensitive and case insensitive regex arguments
+	Fix check_disk bug when mixing case sensitive and case insensitive regex arguments
+	Check_radius now supports radiusclient-ng
 
 1.4.9 4th June 2006
 	Inclusion of contrib/check_cluster2 as check_cluster with some improvements

Modified: nagiosplug/trunk/THANKS.in
===================================================================
--- nagiosplug/trunk/THANKS.in	2007-09-22 17:48:33 UTC (rev 1787)
+++ nagiosplug/trunk/THANKS.in	2007-09-23 09:48:37 UTC (rev 1788)
@@ -224,3 +224,4 @@
 Christoph Schell
 Andrew Elwell
 Heiti Ernits
+Sebastien Guay

Modified: nagiosplug/trunk/configure.in
===================================================================
--- nagiosplug/trunk/configure.in	2007-09-22 17:48:33 UTC (rev 1787)
+++ nagiosplug/trunk/configure.in	2007-09-23 09:48:37 UTC (rev 1788)
@@ -218,8 +218,15 @@
 	RADIUSLIBS="-lradiusclient"
   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(radiusclient-ng,rc_read_config)
+  if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then
+    EXTRAS="$EXTRAS check_radius"
+  	  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).])
+  fi
 fi
 LIBS="$_SAVEDLIBS"
 

Modified: nagiosplug/trunk/plugins/check_radius.c
===================================================================
--- nagiosplug/trunk/plugins/check_radius.c	2007-09-22 17:48:33 UTC (rev 1787)
+++ nagiosplug/trunk/plugins/check_radius.c	2007-09-23 09:48:37 UTC (rev 1788)
@@ -43,12 +43,35 @@
 #include "utils.h"
 #include "netutils.h"
 
+#ifdef HAVE_LIBRADIUSCLIENT_NG
+#include <radiusclient-ng.h>
+rc_handle *rch = NULL;
+#else
 #include <radiusclient.h>
+#endif
 
 int process_arguments (int, char **);
 void print_help (void);
 void print_usage (void);
 
+/* libradiusclient(-ng) wrapper functions */
+#ifdef 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)
+#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,e,f)
+#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)
+#else
+#define my_rc_conf_str(a) rc_conf_str(a)
+#define my_rc_send_server(a,b) rc_send_server(a, b)
+#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(a,b,c,d,e,f)
+#define my_rc_own_ipaddress() rc_own_ipaddress()
+#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(a, b, c, d)
+#define my_rc_read_dictionary(a) rc_read_dictionary(a)
+#endif
+int my_rc_read_config(char *);
+
 char *server = NULL;
 char *username = NULL;
 char *password = NULL;
@@ -133,33 +156,33 @@
 		usage4 (_("Could not parse arguments"));
 
 	str = strdup ("dictionary");
-	if ((config_file && rc_read_config (config_file)) ||
-			rc_read_dictionary (rc_conf_str (str)))
+	if ((config_file && my_rc_read_config (config_file)) ||
+			my_rc_read_dictionary (my_rc_conf_str (str)))
 		die (STATE_UNKNOWN, _("Config file error"));
 
 	service = PW_AUTHENTICATE_ONLY;
 
 	memset (&data, 0, sizeof(data));
-	if (!(rc_avpair_add (&data.send_pairs, PW_SERVICE_TYPE, &service, 0) &&
-				rc_avpair_add (&data.send_pairs, PW_USER_NAME, username, 0) &&
-				rc_avpair_add (&data.send_pairs, PW_USER_PASSWORD, password, 0) &&
-				(nasid==NULL || rc_avpair_add (&data.send_pairs, PW_NAS_IDENTIFIER, nasid, 0))))
+	if (!(my_rc_avpair_add (&data.send_pairs, PW_SERVICE_TYPE, &service, 0) &&
+				my_rc_avpair_add (&data.send_pairs, PW_USER_NAME, username, 0) &&
+				my_rc_avpair_add (&data.send_pairs, PW_USER_PASSWORD, password, 0) &&
+				(nasid==NULL || my_rc_avpair_add (&data.send_pairs, PW_NAS_IDENTIFIER, nasid, 0))))
 		die (STATE_UNKNOWN, _("Out of Memory?"));
 
 	/* 
 	 * Fill in NAS-IP-Address 
 	 */
 
-	if ((client_id = rc_own_ipaddress ()) == 0)
+	if ((client_id = my_rc_own_ipaddress ()) == 0)
 		return (ERROR_RC);
 
-	if (rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) ==
+	if (my_rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) ==
 			NULL) return (ERROR_RC);
 
-	rc_buildreq (&data, PW_ACCESS_REQUEST, server, port, (int)timeout_interval,
+	my_rc_buildreq (&data, PW_ACCESS_REQUEST, server, port, (int)timeout_interval,
 	             retries);
 
-	result = rc_send_server (&data, msg);
+	result = my_rc_send_server (&data, msg);
 	rc_avpair_free (data.send_pairs);
 	if (data.receive_pairs)
 		rc_avpair_free (data.receive_pairs);
@@ -350,3 +373,15 @@
 	printf ("%s -H host -F config_file -u username -p password [-n nas-id] [-P port]\n\
                   [-t timeout] [-r retries] [-e expect]\n", progname);
 }
+
+
+
+int my_rc_read_config(char * a)
+{
+#ifdef HAVE_LIBRADIUSCLIENT_NG
+	rch = rc_read_config(a);
+	return (rch == NULL) ? 1 : 0;
+#else
+	return rc_read_config(a);
+#endif
+}


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Commits mailing list