[Nagiosplug-checkins] CVS: nagiosplug/plugins Makefile.am,1.6,1.7 check_dns.c,1.4,1.5 check_ldap.c,1.1.1.1,1.2 check_mrtg.c,1.2,1.3 check_mrtgtraf.c,1.1.1.1,1.2 check_nwstat.c,1.2,1.3 check_radius.c,1.1.1.1,1.2 utils.c,1.10,1.11 version.h.in,1.1.1.1,1.2

Karl DeBisschop kdebisschop at users.sourceforge.net
Wed Nov 13 18:27:02 CET 2002


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory usw-pr-cvs1:/tmp/cvs-serv3202

Modified Files:
	Makefile.am check_dns.c check_ldap.c check_mrtg.c 
	check_mrtgtraf.c check_nwstat.c check_radius.c utils.c 
	version.h.in 
Log Message:
remove call_getopt and ssprintf

Index: Makefile.am
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/Makefile.am,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** Makefile.am	25 Oct 2002 12:35:09 -0000	1.6
--- Makefile.am	14 Nov 2002 02:26:34 -0000	1.7
***************
*** 3,7 ****
  VPATH = $(top_srcdir) $(top_srcdir)/plugins $(top_srcdir)/plugins/t
  
! INCLUDES = @LDAPINCLUDE@ @PGINCLUDE@ @SSLINCLUDE@ 
  
  libexec_PROGRAMS = check_disk check_dummy check_http check_load \
--- 3,7 ----
  VPATH = $(top_srcdir) $(top_srcdir)/plugins $(top_srcdir)/plugins/t
  
! INCLUDES = @SSLINCLUDE@ 
  
  libexec_PROGRAMS = check_disk check_dummy check_http check_load \
***************
*** 119,122 ****
--- 119,126 ----
  check_nntp_DEPENDENCIES = check_tcp.c $(NETOBJS) $(DEPLIBS)
  check_pop_DEPENDENCIES = check_tcp.c $(NETOBJS) $(DEPLIBS)
+ 
+ check_mysql_INCLUDES = @MYSQLINCLUDE@
+ check_pgsql_INCLUDES = @PGINCLUDE@
+ check_ldap_INCLUDES = @LDAPINCLUDE@
  
  ##############################################################################

Index: check_dns.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_dns.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** check_dns.c	13 Nov 2002 11:50:54 -0000	1.4
--- check_dns.c	14 Nov 2002 02:26:34 -0000	1.5
***************
*** 89,93 ****
  
  	/* get the command to run */
! 	sprintf (&command_line, "%s %s %s", NSLOOKUP_COMMAND,	query_address, dns_server);
  
  	alarm (timeout_interval);
--- 89,93 ----
  
  	/* get the command to run */
! 	asprintf (&command_line, "%s %s %s", NSLOOKUP_COMMAND,	query_address, dns_server);
  
  	alarm (timeout_interval);

Index: check_ldap.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_ldap.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** check_ldap.c	28 Feb 2002 06:42:57 -0000	1.1.1.1
--- check_ldap.c	14 Nov 2002 02:26:34 -0000	1.2
***************
*** 35,39 ****
  
  int process_arguments (int, char **);
- int call_getopt (int, char **);
  int validate_arguments (void);
  static void print_help (void);
--- 35,38 ----
***************
*** 125,157 ****
  	int c;
  
- 	if (argc < 2)
- 		return ERROR;
- 
- 	for (c = 1; c < argc; c++) {
- 		if (strcmp ("-to", argv[c]) == 0)
- 			strcpy (argv[c], "-t");
- 	}
- 
- 	c = 0;
- 	while (c += (call_getopt (argc - c, &argv[c]))) {
- 		if (argc <= c)
- 			break;
- 		if (ld_host[0] == 0) {
- 			strncpy (ld_host, argv[c], sizeof (ld_host) - 1);
- 			ld_host[sizeof (ld_host) - 1] = 0;
- 		}
- 	}
- 
- 	return c;
- }
- 
- int
- call_getopt (int argc, char **argv)
- {
- 	int c, i = 1;
  #ifdef HAVE_GETOPT_H
  	int option_index = 0;
  	/* initialize the long option struct */
! 	static struct option long_options[] = {
  		{"help", no_argument, 0, 'h'},
  		{"version", no_argument, 0, 'V'},
--- 124,131 ----
  	int c;
  
  #ifdef HAVE_GETOPT_H
  	int option_index = 0;
  	/* initialize the long option struct */
! 	static struct option longopts[] = {
  		{"help", no_argument, 0, 'h'},
  		{"version", no_argument, 0, 'V'},
***************
*** 169,181 ****
  #endif
  
! 	for (c = 1; c < argc; c++)
  		if (strcmp ("-to", argv[c]) == 0)
  			strcpy (argv[c], "-t");
  
  	while (1) {
  #ifdef HAVE_GETOPT_H
! 		c =
! 			getopt_long (argc, argv, "+hVt:c:w:H:b:p:a:D:P:", long_options,
! 									 &option_index);
  #else
  		c = getopt (argc, argv, "+?hVt:c:w:H:b:p:a:D:P:");
--- 143,157 ----
  #endif
  
! 	if (argc < 2)
! 		return ERROR;
! 
! 	for (c = 1; c < argc; c++) {
  		if (strcmp ("-to", argv[c]) == 0)
  			strcpy (argv[c], "-t");
+ 	}
  
  	while (1) {
  #ifdef HAVE_GETOPT_H
! 		c =	getopt_long (argc, argv, "hVt:c:w:H:b:p:a:D:P:", longopts, &option_index);
  #else
  		c = getopt (argc, argv, "+?hVt:c:w:H:b:p:a:D:P:");
***************
*** 185,202 ****
  			break;
  
- 		i++;
- 		switch (c) {
- 		case 't':
- 		case 'c':
- 		case 'w':
- 		case 'H':
- 		case 'b':
- 		case 'p':
- 		case 'a':
- 		case 'D':
- 		case 'P':
- 			i++;
- 		}
- 
  		switch (c) {
  		case 'h':									/* help */
--- 161,164 ----
***************
*** 240,244 ****
  		}
  	}
! 	return i;
  }
  
--- 202,211 ----
  		}
  	}
! 
! 	if (ld_host[0] == 0) {
! 		asprintf (&ld_host, "%s", argv[c]);
! 	}
! 
! 	return validate_arguments ();
  }
  

Index: check_mrtg.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_mrtg.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** check_mrtg.c	13 Nov 2002 11:50:54 -0000	1.2
--- check_mrtg.c	14 Nov 2002 02:26:34 -0000	1.3
***************
*** 333,337 ****
  	}
  
! 	if (vargc > c && alue_critical_threshold == 0) {
  		value_critical_threshold = strtoul (argv[c++], NULL, 10);
  	}
--- 333,337 ----
  	}
  
! 	if (argc > c && value_critical_threshold == 0) {
  		value_critical_threshold = strtoul (argv[c++], NULL, 10);
  	}

Index: check_mrtgtraf.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_mrtgtraf.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** check_mrtgtraf.c	28 Feb 2002 06:42:58 -0000	1.1.1.1
--- check_mrtgtraf.c	14 Nov 2002 02:26:34 -0000	1.2
***************
*** 56,60 ****
  
  int process_arguments (int, char **);
- int call_getopt (int, char **);
  int validate_arguments (void);
  void print_help (void);
--- 56,59 ----
***************
*** 78,82 ****
  	char *temp_buffer;
  	time_t current_time;
! 	char error_message[MAX_INPUT_BUFFER];
  	time_t timestamp = 0L;
  	unsigned long average_incoming_rate = 0L;
--- 77,81 ----
  	char *temp_buffer;
  	time_t current_time;
! 	char *error_message;
  	time_t timestamp = 0L;
  	unsigned long average_incoming_rate = 0L;
***************
*** 199,203 ****
  			|| outgoing_rate > outgoing_critical_threshold) {
  		result = STATE_CRITICAL;
! 		sprintf (error_message, "%s. In = %0.1f %s, %s. Out = %0.1f %s",
  						 (use_average == TRUE) ? "Ave" : "Max", adjusted_incoming_rate,
  						 incoming_speed_rating, (use_average == TRUE) ? "Ave" : "Max",
--- 198,202 ----
  			|| outgoing_rate > outgoing_critical_threshold) {
  		result = STATE_CRITICAL;
! 		asprintf (&error_message, "%s. In = %0.1f %s, %s. Out = %0.1f %s",
  						 (use_average == TRUE) ? "Ave" : "Max", adjusted_incoming_rate,
  						 incoming_speed_rating, (use_average == TRUE) ? "Ave" : "Max",
***************
*** 207,211 ****
  					 || outgoing_rate > outgoing_warning_threshold) {
  		result = STATE_WARNING;
! 		sprintf (error_message, "%s. In = %0.1f %s, %s. Out = %0.1f %s",
  						 (use_average == TRUE) ? "Ave" : "Max", adjusted_incoming_rate,
  						 incoming_speed_rating, (use_average == TRUE) ? "Ave" : "Max",
--- 206,210 ----
  					 || outgoing_rate > outgoing_warning_threshold) {
  		result = STATE_WARNING;
! 		asprintf (&error_message, "%s. In = %0.1f %s, %s. Out = %0.1f %s",
  						 (use_average == TRUE) ? "Ave" : "Max", adjusted_incoming_rate,
  						 incoming_speed_rating, (use_average == TRUE) ? "Ave" : "Max",
***************
*** 234,299 ****
  	int c;
  
- 	if (argc < 2)
- 		return ERROR;
- 
- 	for (c = 1; c < argc; c++) {
- 		if (strcmp ("-to", argv[c]) == 0)
- 			strcpy (argv[c], "-t");
- 		else if (strcmp ("-wt", argv[c]) == 0)
- 			strcpy (argv[c], "-w");
- 		else if (strcmp ("-ct", argv[c]) == 0)
- 			strcpy (argv[c], "-c");
- 	}
- 
- 
- 
- 	c = 0;
- 	while ((c += (call_getopt (argc - c, &argv[c]))) < argc) {
- 
- 		if (is_option (argv[c]))
- 			continue;
- 
- 		if (log_file == NULL) {
- 			log_file = argv[c];
- 		}
- 		else if (expire_minutes == -1) {
- 			expire_minutes = atoi (optarg);
- 		}
- 		else if (strcmp (argv[c], "MAX") == 0) {
- 			use_average = FALSE;
- 		}
- 		else if (strcmp (argv[c], "AVG") == 0) {
- 			use_average = TRUE;
- 		}
- 		else if (incoming_warning_threshold == 0) {
- 			incoming_warning_threshold = strtoul (argv[c], NULL, 10);
- 		}
- 		else if (incoming_critical_threshold == 0) {
- 			incoming_critical_threshold = strtoul (argv[c], NULL, 10);
- 		}
- 		else if (outgoing_warning_threshold == 0) {
- 			outgoing_warning_threshold = strtoul (argv[c], NULL, 10);
- 		}
- 		else if (outgoing_critical_threshold == 0) {
- 			outgoing_critical_threshold = strtoul (argv[c], NULL, 10);
- 		}
- 	}
- 
- 	return validate_arguments ();
- }
- 
- 
- 
- 
- 
- 
- int
- call_getopt (int argc, char **argv)
- {
- 	int c, i = 0;
- 
  #ifdef HAVE_GETOPT_H
  	int option_index = 0;
! 	static struct option long_options[] = {
  		{"logfile", required_argument, 0, 'F'},
  		{"expires", required_argument, 0, 'e'},
--- 233,239 ----
  	int c;
  
  #ifdef HAVE_GETOPT_H
  	int option_index = 0;
! 	static struct option longopts[] = {
  		{"logfile", required_argument, 0, 'F'},
  		{"expires", required_argument, 0, 'e'},
***************
*** 309,335 ****
  #endif
  
  	while (1) {
  #ifdef HAVE_GETOPT_H
! 		c =
! 			getopt_long (argc, argv, "+hVF:e:a:c:w:", long_options, &option_index);
  #else
! 		c = getopt (argc, argv, "+hVF:e:a:c:w:");
  #endif
  
! 		i++;
! 
! 		if (c == -1 || c == EOF || c == 1)
  			break;
  
  		switch (c) {
- 		case 'F':
- 		case 'e':
- 		case 'a':
- 		case 'c':
- 		case 'w':
- 			i++;
- 		}
- 
- 		switch (c) {
  		case 'F':									/* input file */
  			log_file = optarg;
--- 249,275 ----
  #endif
  
+ 	if (argc < 2)
+ 		return ERROR;
+ 
+ 	for (c = 1; c < argc; c++) {
+ 		if (strcmp ("-to", argv[c]) == 0)
+ 			strcpy (argv[c], "-t");
+ 		else if (strcmp ("-wt", argv[c]) == 0)
+ 			strcpy (argv[c], "-w");
+ 		else if (strcmp ("-ct", argv[c]) == 0)
+ 			strcpy (argv[c], "-c");
+ 	}
+ 
  	while (1) {
  #ifdef HAVE_GETOPT_H
! 		c =	getopt_long (argc, argv, "hVF:e:a:c:w:", longopts, &option_index);
  #else
! 		c = getopt (argc, argv, "hVF:e:a:c:w:");
  #endif
  
! 		if (c == -1 || c == EOF)
  			break;
  
  		switch (c) {
  		case 'F':									/* input file */
  			log_file = optarg;
***************
*** 362,366 ****
  		}
  	}
! 	return i;
  }
  
--- 302,341 ----
  		}
  	}
! 
! 	c = optind;
! 	if (argc > c && log_file == NULL) {
! 		log_file = argv[c++];
! 	}
! 
! 	if (argc > c && expire_minutes == -1) {
! 		expire_minutes = atoi (argv[c++]);
! 	}
! 
! 	if (argc > c && strcmp (argv[c], "MAX") == 0) {
! 		use_average = FALSE;
! 		c++;
! 	}
! 	else if (argc > c && strcmp (argv[c], "AVG") == 0) {
! 		use_average = TRUE;
! 		c++;
! 	}
! 
! 	if (argc > c && incoming_warning_threshold == 0) {
! 		incoming_warning_threshold = strtoul (argv[c++], NULL, 10);
! 	}
! 
! 	if (argc > c && incoming_critical_threshold == 0) {
! 		incoming_critical_threshold = strtoul (argv[c++], NULL, 10);
! 	}
! 
! 	if (argc > c && outgoing_warning_threshold == 0) {
! 		outgoing_warning_threshold = strtoul (argv[c++], NULL, 10);
! 	}
! 	
! 	if (argc > c && outgoing_critical_threshold == 0) {
! 		outgoing_critical_threshold = strtoul (argv[c++], NULL, 10);
! 	}
! 
! 	return validate_arguments ();
  }
  

Index: check_nwstat.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_nwstat.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** check_nwstat.c	13 Nov 2002 11:50:54 -0000	1.2
--- check_nwstat.c	14 Nov 2002 02:26:34 -0000	1.3
***************
*** 297,301 ****
  		else if(check_warning_value==TRUE && lru_time <= warning_value)
  			result=STATE_WARNING;
! 		sprintf(&output_message,"LRU sitting time = %lu minutes",lru_time);
  
  
--- 297,301 ----
  		else if(check_warning_value==TRUE && lru_time <= warning_value)
  			result=STATE_WARNING;
! 		asprintf(&output_message,"LRU sitting time = %lu minutes",lru_time);
  
  
***************
*** 591,595 ****
  		max_service_processes=atoi(recv_buffer);
   
! 		sprintf(&send_buffer,"S21\r\n");
  		result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
  		if(result!=STATE_OK)
--- 591,595 ----
  		max_service_processes=atoi(recv_buffer);
   
! 		asprintf(&send_buffer,"S21\r\n");
  		result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
  		if(result!=STATE_OK)

Index: check_radius.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_radius.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** check_radius.c	28 Feb 2002 06:42:58 -0000	1.1.1.1
--- check_radius.c	14 Nov 2002 02:26:34 -0000	1.2
***************
*** 53,57 ****
   -t, --timeout=INTEGER\n\
      Seconds before connection times out (default: %d)\n\
!  -v\n\
      Show details for command-line debugging (do not use with nagios server)\n\
   -h, --help\n\
--- 53,57 ----
   -t, --timeout=INTEGER\n\
      Seconds before connection times out (default: %d)\n\
!  -v, --verbose\n\
      Show details for command-line debugging (do not use with nagios server)\n\
   -h, --help\n\
***************
*** 61,69 ****
  
  #define DESCRIPTION "\
! The password option presents a substantial security issue because the 
! password can be determined by careful watching of the command line in
! a process listing.  This risk is exacerbated because nagios will
! run the plugin at regular prdictable intervals.  Please be sure that
! the password used does not allow access to sensitive system resources,
  otherwise compormise could occur.\n"
  
--- 61,75 ----
  
  #define DESCRIPTION "\
! This plugin tests a radius server to see if it is accepting connections.\n\
! \n\
! The server to test must be specified in the invocation, as well as a user\n\
! name and password. A configuration file may also be present. The format of\n\
! the configuration file is described in the radiusclient library sources.\n\
! \n\
! The password option presents a substantial security issue because the\n\
! password can be determined by careful watching of the command line in\n\
! a process listing.  This risk is exacerbated because nagios will\n\
! run the plugin at regular prdictable intervals.  Please be sure that\n\
! the password used does not allow access to sensitive system resources,\n\
  otherwise compormise could occur.\n"
  
***************
*** 129,133 ****
  <sect2>
  <title>Future Enhancements</title>
! <para>ToDo List</para>
  <itemizedlist>
  <listitem>Add option to get password from a secured file rather than the command line</listitem>
--- 135,139 ----
  <sect2>
  <title>Future Enhancements</title>
! <para>Todo List</para>
  <itemizedlist>
  <listitem>Add option to get password from a secured file rather than the command line</listitem>

Index: utils.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/utils.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** utils.c	13 Nov 2002 11:50:54 -0000	1.10
--- utils.c	14 Nov 2002 02:26:34 -0000	1.11
***************
*** 49,53 ****
  void strip (char *);
  char *strscpy (char *dest, const char *src);
! char *strscat (char *dest, const char *src);
  char *strnl (char *str);
  char *strpcpy (char *dest, const char *src, const char *str);
--- 49,53 ----
  void strip (char *);
  char *strscpy (char *dest, const char *src);
! char *strscat (char *dest, char *src);
  char *strnl (char *str);
  char *strpcpy (char *dest, const char *src, const char *str);
***************
*** 407,411 ****
  
  char *
! strscat (char *dest, const char *src)
  {
  
--- 407,411 ----
  
  char *
! strscat (char *dest, char *src)
  {
  

Index: version.h.in
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/version.h.in,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** version.h.in	28 Feb 2002 06:43:00 -0000	1.1.1.1
--- version.h.in	14 Nov 2002 02:26:34 -0000	1.2
***************
*** 1,2 ****
- #define PACKAGE_VERSION "1.3.0-alpha1"
  #define CVS_DATE "$Date$"
--- 1 ----





More information about the Commits mailing list