Imported Upstream version 1.4.10
This commit is contained in:
parent
6dd54dd8e2
commit
cff68b4c0a
203 changed files with 15026 additions and 8063 deletions
|
@ -5,7 +5,7 @@
|
|||
* License: GPL
|
||||
* Copyright (c) 1999-2006 nagios-plugins team
|
||||
*
|
||||
* Last Modified: $Date: 2007/01/28 21:46:40 $
|
||||
* Last Modified: $Date: 2007-09-26 11:57:44 +0100 (Wed, 26 Sep 2007) $
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
|
@ -30,12 +30,12 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: check_radius.c,v 1.25 2007/01/28 21:46:40 hweiss Exp $
|
||||
* $Id: check_radius.c 1800 2007-09-26 10:57:44Z hweiss $
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
const char *progname = "check_radius";
|
||||
const char *revision = "$Revision: 1.25 $";
|
||||
const char *revision = "$Revision: 1800 $";
|
||||
const char *copyright = "2000-2006";
|
||||
const char *email = "nagiosplug-devel@lists.sourceforge.net";
|
||||
|
||||
|
@ -43,12 +43,35 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
|
|||
#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 @@ main (int argc, char **argv)
|
|||
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);
|
||||
|
@ -202,30 +225,6 @@ process_arguments (int argc, char **argv)
|
|||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
if (argc < 2)
|
||||
return ERROR;
|
||||
|
||||
if (argc == 9) {
|
||||
config_file = argv[1];
|
||||
username = argv[2];
|
||||
password = argv[3];
|
||||
if (is_intpos (argv[4]))
|
||||
timeout_interval = atoi (argv[4]);
|
||||
else
|
||||
usage2 (_("Timeout interval must be a positive integer"), optarg);
|
||||
if (is_intpos (argv[5]))
|
||||
retries = atoi (argv[5]);
|
||||
else
|
||||
usage4 (_("Number of retries must be a positive integer"));
|
||||
server = argv[6];
|
||||
if (is_intpos (argv[7]))
|
||||
port = atoi (argv[7]);
|
||||
else
|
||||
usage4 (_("Port must be a positive integer"));
|
||||
expect = argv[8];
|
||||
return OK;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
c = getopt_long (argc, argv, "+hVvH:P:F:u:p:n:t:r:e:", longopts,
|
||||
&option);
|
||||
|
@ -286,6 +285,16 @@ process_arguments (int argc, char **argv)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (server == NULL)
|
||||
usage4 (_("Host not specified"));
|
||||
if (username == NULL)
|
||||
usage4 (_("User not specified"));
|
||||
if (password == NULL)
|
||||
usage4 (_("Password not specified"));
|
||||
if (config_file == NULL)
|
||||
usage4 (_("Configuration file not specified"));
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
@ -350,3 +359,15 @@ print_usage (void)
|
|||
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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue