diff --git a/plugins/check_radius.c b/plugins/check_radius.c
index d56222f98cc0ea10d1fa071a8e6c683b19aae01d..07ee4c7f35bcedaa7c61d7a3a585060cb6d7b369 100644 (file)
--- a/plugins/check_radius.c
+++ b/plugins/check_radius.c
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ $Id$
+
******************************************************************************/
const char *progname = "check_radius";
#include "common.h"
#include "utils.h"
#include "netutils.h"
+
#include <radiusclient.h>
int process_arguments (int, char **);
char *server = NULL;
char *username = NULL;
char *password = NULL;
+char *nasid = NULL;
char *expect = NULL;
char *config_file = NULL;
unsigned short port = PW_AUTH_UDP_PORT;
-@@
******************************************************************************/
+
+
int
main (int argc, char **argv)
{
UINT4 service;
char msg[BUFFER_LEN];
SEND_DATA data;
- int result;
+ int result = STATE_UNKNOWN;
UINT4 client_id;
char *str;
textdomain (PACKAGE);
if (process_arguments (argc, argv) == ERROR)
- usage (_("Could not parse arguments\n"));
+ usage4 (_("Could not parse arguments"));
str = strdup ("dictionary");
if ((config_file && rc_read_config (config_file)) ||
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)))
+ rc_avpair_add (&data.send_pairs, PW_USER_PASSWORD, password, 0) &&
+ (nasid==NULL || rc_avpair_add (&data.send_pairs, PW_NAS_IDENTIFIER, nasid, 0))))
die (STATE_UNKNOWN, _("Out of Memory?"));
/*
{"port", required_argument, 0, 'P'},
{"username", required_argument, 0, 'u'},
{"password", required_argument, 0, 'p'},
+ {"nas-id", required_argument, 0, 'n'},
{"filename", required_argument, 0, 'F'},
{"expect", required_argument, 0, 'e'},
{"retries", required_argument, 0, 'r'},
if (is_intpos (argv[4]))
timeout_interval = atoi (argv[4]);
else
- usage (_("Timeout interval must be a positive integer"));
+ usage2 (_("Timeout interval must be a positive integer"), optarg);
if (is_intpos (argv[5]))
retries = atoi (argv[5]);
else
- usage (_("Number of retries must be a positive integer"));
+ usage4 (_("Number of retries must be a positive integer"));
server = argv[6];
if (is_intpos (argv[7]))
port = atoi (argv[7]);
else
- usage (_("Server port must be a positive integer"));
+ usage4 (_("Port must be a positive integer"));
expect = argv[8];
return OK;
}
while (1) {
- c = getopt_long (argc, argv, "+hVvH:P:F:u:p:t:r:e:", longopts,
+ c = getopt_long (argc, argv, "+hVvH:P:F:u:p:n:t:r:e:", longopts,
&option);
if (c == -1 || c == EOF || c == 1)
switch (c) {
case '?': /* print short usage statement if args not parsable */
- printf (_("%s: Unknown argument: %s\n\n"), progname, optarg);
- print_usage ();
- exit (STATE_UNKNOWN);
+ usage2 (_("Unknown argument"), optarg);
case 'h': /* help */
print_help ();
exit (OK);
break;
case 'H': /* hostname */
if (is_host (optarg) == FALSE) {
- printf (_("Invalid host name/address\n\n"));
- print_usage ();
- exit (STATE_UNKNOWN);
+ usage2 (_("Invalid hostname/address"), optarg);
}
server = optarg;
break;
if (is_intnonneg (optarg))
port = atoi (optarg);
else
- usage (_("Server port must be a positive integer"));
+ usage4 (_("Port must be a positive integer"));
break;
case 'u': /* username */
username = optarg;
case 'p': /* password */
password = optarg;
break;
+ case 'n': /* nas id */
+ nasid = optarg;
+ break;
case 'F': /* configuration file */
config_file = optarg;
break;
if (is_intpos (optarg))
retries = atoi (optarg);
else
- usage (_("Number of retries must be a positive integer"));
+ usage4 (_("Number of retries must be a positive integer"));
break;
case 't': /* timeout */
if (is_intpos (optarg))
timeout_interval = atoi (optarg);
else
- usage (_("Timeout interval must be a positive integer"));
+ usage2 (_("Timeout interval must be a positive integer"), optarg);
break;
}
}
-
-
-\f
void
print_help (void)
{
print_revision (progname, revision);
- printf (_("Copyright (c) 1999 Robert August Vincent II\n"));
- printf (_(COPYRIGHT), copyright, email);
+ printf ("Copyright (c) 1999 Robert August Vincent II\n");
+ printf (COPYRIGHT, copyright, email);
printf(_("Tests to see if a radius server is accepting connections.\n\n"));
The user to authenticate\n\
-p, --password=STRING\n\
Password for autentication (SECURITY RISK)\n\
+ -n, --nas-id=STRING\n\
+ NAS identifier\n\
-F, --filename=STRING\n\
Configuration file\n\
-e, --expect=STRING\n\
-
void
print_usage (void)
{
printf ("\
-Usage: %s -H host -F config_file -u username -p password [-P port]\n\
- [-t timeout] [-r retries] [-e expect]\n", progname);
- printf (_(UT_HLP_VRS), progname, progname);
+Usage: %s -H host -F config_file -u username -p password [-n nas-id] [-P port]\n\
+ [-t timeout] [-r retries] [-e expect]\n", progname);
}