summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Makefile.am2
-rw-r--r--plugins/check_real.d/config.h2
-rw-r--r--plugins/check_snmp.c9
-rw-r--r--plugins/check_snmp.d/check_snmp_helpers.c19
-rw-r--r--plugins/utils.h1
5 files changed, 21 insertions, 12 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 2bea8fc0..9aefcea0 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -166,7 +166,7 @@ check_real_LDADD = $(NETLIBS)
166check_snmp_SOURCES = check_snmp.c check_snmp.d/check_snmp_helpers.c 166check_snmp_SOURCES = check_snmp.c check_snmp.d/check_snmp_helpers.c
167check_snmp_LDADD = $(BASEOBJS) 167check_snmp_LDADD = $(BASEOBJS)
168check_snmp_LDFLAGS = $(AM_LDFLAGS) -lm `net-snmp-config --libs` 168check_snmp_LDFLAGS = $(AM_LDFLAGS) -lm `net-snmp-config --libs`
169check_snmp_CFLAGS = $(AM_CFLAGS) `net-snmp-config --cflags | sed 's/-Werror=declaration-after-statement//'` 169check_snmp_CFLAGS = $(AM_CFLAGS) `net-snmp-config --cflags | sed 's/-Werror=declaration-after-statement//' | sed 's/-Wundef//'`
170check_smtp_LDADD = $(SSLOBJS) 170check_smtp_LDADD = $(SSLOBJS)
171check_ssh_LDADD = $(NETLIBS) 171check_ssh_LDADD = $(NETLIBS)
172check_swap_SOURCES = check_swap.c check_swap.d/swap.c 172check_swap_SOURCES = check_swap.c check_swap.d/swap.c
diff --git a/plugins/check_real.d/config.h b/plugins/check_real.d/config.h
index 2d99ad49..314aff37 100644
--- a/plugins/check_real.d/config.h
+++ b/plugins/check_real.d/config.h
@@ -9,7 +9,7 @@ enum {
9 PORT = 554 9 PORT = 554
10}; 10};
11 11
12const char *default_expect = "RTSP/1."; 12char *default_expect = "RTSP/1.";
13 13
14typedef struct { 14typedef struct {
15 char *server_address; 15 char *server_address;
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 0f62ce8b..2b3099c9 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -256,7 +256,10 @@ int main(int argc, char **argv) {
256 256
257 timeout_interval = DEFAULT_SOCKET_TIMEOUT; 257 timeout_interval = DEFAULT_SOCKET_TIMEOUT;
258 258
259 np_init((char *)progname, argc, argv); 259 char progname_copy[256];
260 strncpy(progname_copy, progname, sizeof(progname_copy)-1);
261 progname_copy[255] = '\0';
262 np_init(progname_copy, argc, argv);
260 263
261 state_key stateKey = np_enable_state(NULL, 1, progname, argc, argv); 264 state_key stateKey = np_enable_state(NULL, 1, progname, argc, argv);
262 265
@@ -508,8 +511,8 @@ static process_arguments_wrapper process_arguments(int argc, char **argv) {
508 unsigned char *privpasswd = NULL; 511 unsigned char *privpasswd = NULL;
509 int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE; 512 int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE;
510 char *port = NULL; 513 char *port = NULL;
511 char *miblist = NULL; 514 const char *miblist = NULL;
512 char *connection_prefix = NULL; 515 const char *connection_prefix = NULL;
513 bool snmp_version_set_explicitely = false; 516 bool snmp_version_set_explicitely = false;
514 // TODO error checking 517 // TODO error checking
515 while (true) { 518 while (true) {
diff --git a/plugins/check_snmp.d/check_snmp_helpers.c b/plugins/check_snmp.d/check_snmp_helpers.c
index 83e94a34..c3f25307 100644
--- a/plugins/check_snmp.d/check_snmp_helpers.c
+++ b/plugins/check_snmp.d/check_snmp_helpers.c
@@ -91,6 +91,8 @@ const char DEFAULT_OUTPUT_DELIMITER[] = " ";
91 91
92const int RANDOM_STATE_DATA_LENGTH_PREDICTION = 8192; 92const int RANDOM_STATE_DATA_LENGTH_PREDICTION = 8192;
93 93
94char community[100];
95
94check_snmp_config check_snmp_config_init() { 96check_snmp_config check_snmp_config_init() {
95 check_snmp_config tmp = { 97 check_snmp_config tmp = {
96 .snmp_params = 98 .snmp_params =
@@ -129,14 +131,17 @@ check_snmp_config check_snmp_config_init() {
129 tmp.snmp_params.snmp_session.retries = DEFAULT_RETRIES; 131 tmp.snmp_params.snmp_session.retries = DEFAULT_RETRIES;
130 tmp.snmp_params.snmp_session.version = DEFAULT_SNMP_VERSION; 132 tmp.snmp_params.snmp_session.version = DEFAULT_SNMP_VERSION;
131 tmp.snmp_params.snmp_session.securityLevel = SNMP_SEC_LEVEL_NOAUTH; 133 tmp.snmp_params.snmp_session.securityLevel = SNMP_SEC_LEVEL_NOAUTH;
132 tmp.snmp_params.snmp_session.community = (unsigned char *)"public"; 134 strcpy(community, "public");
133 tmp.snmp_params.snmp_session.community_len = strlen("public"); 135 tmp.snmp_params.snmp_session.community = (unsigned char *)community;
136 tmp.snmp_params.snmp_session.community_len = strlen(community);
134 return tmp; 137 return tmp;
135} 138}
136 139
137snmp_responces do_snmp_query(check_snmp_config_snmp_parameters parameters) { 140snmp_responces do_snmp_query(check_snmp_config_snmp_parameters parameters) {
138 if (parameters.ignore_mib_parsing_errors) { 141 if (parameters.ignore_mib_parsing_errors) {
139 char *opt_toggle_res = snmp_mib_toggle_options("e"); 142 char option_e[2];
143 option_e[0] = 'e'; option_e[1] = '\0';
144 char *opt_toggle_res = snmp_mib_toggle_options(option_e);
140 if (opt_toggle_res != NULL) { 145 if (opt_toggle_res != NULL) {
141 die(STATE_UNKNOWN, "Unable to disable MIB parsing errors"); 146 die(STATE_UNKNOWN, "Unable to disable MIB parsing errors");
142 } 147 }
@@ -436,7 +441,7 @@ check_snmp_evaluation evaluate_single_unit(response_value response,
436 } 441 }
437 } else { 442 } else {
438 // It's only a counter if we cont compute rate 443 // It's only a counter if we cont compute rate
439 pd_num_val.uom = "c"; 444 pd_num_val.uom = strdup("c");
440 pd_result_val = mp_create_pd_value(response.value.uIntVal); 445 pd_result_val = mp_create_pd_value(response.value.uIntVal);
441 } 446 }
442 break; 447 break;
@@ -476,7 +481,7 @@ check_snmp_evaluation evaluate_single_unit(response_value response,
476 pd_result_val = mp_create_pd_value(treated_value); 481 pd_result_val = mp_create_pd_value(treated_value);
477 482
478 if (response.type == ASN_COUNTER) { 483 if (response.type == ASN_COUNTER) {
479 pd_num_val.uom = "c"; 484 pd_num_val.uom = strdup("c");
480 } 485 }
481 } 486 }
482 487
@@ -820,7 +825,7 @@ state_data *np_state_read(state_key stateKey) {
820 * envvar NAGIOS_PLUGIN_STATE_DIRECTORY 825 * envvar NAGIOS_PLUGIN_STATE_DIRECTORY
821 * statically compiled shared state directory 826 * statically compiled shared state directory
822 */ 827 */
823char *_np_state_calculate_location_prefix(void) { 828static const char *_np_state_calculate_location_prefix(void) {
824 char *env_dir; 829 char *env_dir;
825 830
826 /* Do not allow passing MP_STATE_PATH in setuid plugins 831 /* Do not allow passing MP_STATE_PATH in setuid plugins
@@ -871,7 +876,7 @@ state_key np_enable_state(char *keyname, int expected_data_version, const char *
871 tmp_char++; 876 tmp_char++;
872 } 877 }
873 this_state->name = temp_keyname; 878 this_state->name = temp_keyname;
874 this_state->plugin_name = (char *)plugin_name; 879 this_state->plugin_name = strdup(plugin_name);
875 this_state->data_version = expected_data_version; 880 this_state->data_version = expected_data_version;
876 this_state->state_data = NULL; 881 this_state->state_data = NULL;
877 882
diff --git a/plugins/utils.h b/plugins/utils.h
index 68ff1630..c1c921fb 100644
--- a/plugins/utils.h
+++ b/plugins/utils.h
@@ -13,6 +13,7 @@ in order to resist overflow attacks. In addition, a few functions are
13provided to standardize version and error reporting across the entire 13provided to standardize version and error reporting across the entire
14suite of plugins. */ 14suite of plugins. */
15 15
16#undef USE_OPENSSL // net-snmp defines USE_OPENSSL as NETSNMP_USE_OPENSSL in net-snmp-config.h
16#include "../config.h" 17#include "../config.h"
17#include <stdbool.h> 18#include <stdbool.h>
18#include <stdint.h> 19#include <stdint.h>