summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSubhendu Ghosh <sghosh@users.sourceforge.net>2002-11-11 20:19:01 (GMT)
committerSubhendu Ghosh <sghosh@users.sourceforge.net>2002-11-11 20:19:01 (GMT)
commitfd59a578f5847c4d52ebab5d2a073c280f4a4b8c (patch)
tree2c3aa176984004fb11a35d669f9c5b934a9647d5
parent74cb2bc8c90429062eb424174b49de3ab8b9388e (diff)
downloadmonitoring-plugins-fd59a578f5847c4d52ebab5d2a073c280f4a4b8c.tar.gz
more snmpv3 patches
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@186 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--plugins/check_snmp.c36
1 files changed, 13 insertions, 23 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 19306b5..80366b8 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -34,7 +34,9 @@
34-H <ip_address> -o <OID> [-w warn_range] [-c crit_range] \n\ 34-H <ip_address> -o <OID> [-w warn_range] [-c crit_range] \n\
35 [-C community] [-s string] [-r regex] [-R regexi] [-t timeout]\n\ 35 [-C community] [-s string] [-r regex] [-R regexi] [-t timeout]\n\
36 [-l label] [-u units] [-p port-number] [-d delimiter]\n\ 36 [-l label] [-u units] [-p port-number] [-d delimiter]\n\
37 [-D output-delimiter] [-m miblist]" 37 [-D output-delimiter] [-m miblist] [-P snmp version]\n\
38 [-L seclevel] [-U secname] [-a authproto] [-A authpasswd]\n\
39 [-X privpasswd]\n"
38 40
39#define LONGOPTIONS "\ 41#define LONGOPTIONS "\
40 -H, --hostname=HOST\n\ 42 -H, --hostname=HOST\n\
@@ -645,7 +647,7 @@ process_arguments (int argc, char **argv)
645 secname = strscpy(secname, optarg); 647 secname = strscpy(secname, optarg);
646 break; 648 break;
647 case 'a': /* auth protocol */ 649 case 'a': /* auth protocol */
648 authproto = strscpy(authproto, optarg); 650 asprintf (&authproto, optarg);
649 break; 651 break;
650 case 'A': /* auth passwd */ 652 case 'A': /* auth passwd */
651 authpasswd = strscpy(authpasswd, optarg); 653 authpasswd = strscpy(authpasswd, optarg);
@@ -705,30 +707,18 @@ validate_arguments ()
705 if (units == NULL) 707 if (units == NULL)
706 asprintf (&units, ""); 708 asprintf (&units, "");
707 709
708 if ( strcmp(seclevel, "noAuthNoPriv") && strcmp(seclevel, "authNoPriv") && strcmp(seclevel, "authPriv") ) { 710 /* Need better checks to verify seclevel and authproto choices */
709 if (seclevel == NULL) 711
710 asprintf (&seclevel, "noAuthNoPriv"); 712 if (seclevel == NULL)
711 else { 713 asprintf (&seclevel, "noAuthNoPriv");
712 printf ("Invalid seclevel: %s! \n", seclevel);
713 print_usage ();
714 exit (STATE_UNKNOWN);
715 }
716 }
717 714
718 715
719 if ( strcmp (authproto, "SHA") && strcmp(authproto, "MD5") ) { 716 if (authproto == NULL )
720 if (authproto == NULL ) 717 asprintf(&authproto, DEFAULT_AUTH_PROTOCOL);
721 asprintf(&authproto, DEFAULT_AUTH_PROTOCOL); 718
722 else{
723 printf ("Invalid authproto: %s! \n", authproto);
724 print_usage ();
725 exit (STATE_UNKNOWN);
726 }
727 }
728
729 719
730 720
731 if (proto == NULL || !strcmp(proto,DEFAULT_PROTOCOL) ) { /* default protocol version */ 721 if (proto == NULL || (strcmp(proto,DEFAULT_PROTOCOL) == 0) ) { /* default protocol version */
732 asprintf(&proto, DEFAULT_PROTOCOL); 722 asprintf(&proto, DEFAULT_PROTOCOL);
733 asprintf(&authpriv, "%s%s", "-c ", community); 723 asprintf(&authpriv, "%s%s", "-c ", community);
734 } 724 }
@@ -752,7 +742,7 @@ validate_arguments ()
752 print_usage (); 742 print_usage ();
753 exit (STATE_UNKNOWN); 743 exit (STATE_UNKNOWN);
754 } 744 }
755 authpriv = ssprintf(authpriv, "-l authPriv -a %s -u %s -A %s -X %s ", authproto, secname, authpasswd, privpasswd); 745 authpriv = ssprintf(authpriv, "-l authPriv -a %s -u %s -A %s -x DES -X %s ", authproto, secname, authpasswd, privpasswd);
756 } 746 }
757 747
758 748