Ver Fonte

Added option to nrpe.cfg.in that can override hard-coded NASTY_METACHARS

Fix for issue #70
John C. Frickson há 9 anos atrás
pai
commit
04cef56c47
3 ficheiros alterados com 19 adições e 2 exclusões
  1. 4 1
      Changelog
  2. 7 0
      sample-config/nrpe.cfg.in
  3. 8 1
      src/nrpe.c

+ 4 - 1
Changelog

@@ -2,8 +2,11 @@
 NRPE Changelog
 **************
 
-3.0.x - 201x-xx-xx
+3.x.x - 201x-xx-xx
 ------------------
+ENHANCEMENTS
+- Added option to nrpe.cfg.in that can override hard-coded NASTY_METACHARS (John Frickson)
+
 FIXES
 - Added missing debugging syslog entries, and changed printf()'s to syslog()'s. (Jobst Schmalenbach)
 - Fix help output for ssl option (configure) (Ruben Kerkhof)

+ 7 - 0
sample-config/nrpe.cfg.in

@@ -246,6 +246,13 @@ connection_timeout=300
 
 
 
+# NASTY METACHARACTERS
+# This option allows you to override the list of characters that cannot
+# be passed to the NRPE daemon.
+
+# nasty_metachars="|`&><'\\[]{};\r\n"
+
+
 # INCLUDE CONFIG FILE
 # This directive allows you to include definitions from an external config file.
 

+ 8 - 1
src/nrpe.c

@@ -106,6 +106,7 @@ int       debug = FALSE;
 int       use_src = FALSE;		/* Define parameter for SRC option */
 int       no_forking = FALSE;
 int       listen_queue_size = DEFAULT_LISTEN_QUEUE_SIZE;
+char     *nasty_metachars = NULL;
 
 /* SSL/TLS parameters */
 typedef enum _SSL_VER {
@@ -184,6 +185,9 @@ int main(int argc, char **argv)
 		return STATE_CRITICAL;
 	}
 
+	if (!nasty_metachars)
+		nasty_metachars = strdup(NASTY_METACHARS);
+
 	/* initialize macros */
 	for (x = 0; x < MAX_COMMAND_ARGUMENTS; x++)
 		macro_argv[x] = NULL;
@@ -890,6 +894,9 @@ int read_config_file(char *filename)
 		} else if (!strcmp(varname, "keep_env_vars"))
 			keep_env_vars = strdup(varvalue);
 
+		else if (!strcmp(varname, "nasty_metachars"))
+			nasty_metachars = strdup(varvalue);
+
 		else {
 			syslog(LOG_WARNING, "Unknown option specified in config file '%s' - Line %d\n",
 				   filename, line);
@@ -2543,7 +2550,7 @@ int contains_nasty_metachars(char *str)
 	if (str == NULL)
 		return FALSE;
 
-	result = strcspn(str, NASTY_METACHARS);
+	result = strcspn(str, nasty_metachars);
 	if (result != strlen(str))
 		return TRUE;