Browse Source

Invert Tom's changes - default to enabled (for backward compatibility) and allow disabling

madlohe 6 years ago
parent
commit
f328a958d6
5 changed files with 16 additions and 16 deletions
  1. 1 1
      include/utils.h
  2. 2 2
      sample-config/nrpe.cfg.in
  3. 7 5
      src/check_nrpe.c
  4. 3 3
      src/nrpe.c
  5. 3 5
      src/utils.c

+ 1 - 1
include/utils.h

@@ -49,6 +49,6 @@ void open_log_file();
 void logit(int priority, const char *format, ...);
 void close_log_file();
 void display_license(void);
-extern int enable_syslog;
+extern int disable_syslog;
 
 #endif

+ 2 - 2
sample-config/nrpe.cfg.in

@@ -271,8 +271,8 @@ connection_timeout=300
 # nasty_metachars="|`&><'\\[]{};\r\n"
 
 # This option allows you to enable or disable logging error messages to the syslog facilities.
-# If this option is not set, the error messages will not be logged.
-enable_syslog=0
+# If this option is not set, the error messages will be logged.
+disable_syslog=0
 
 # COMMAND DEFINITIONS
 # Command definitions that this daemon will run.  Definitions

+ 7 - 5
src/check_nrpe.c

@@ -130,7 +130,7 @@ static int verify_callback(int ok, X509_STORE_CTX * ctx);
 #endif
 void alarm_handler(int);
 int graceful_close(int, int);
-int enable_syslog = FALSE;
+int disable_syslog = FALSE;
 
 
 int main(int argc, char **argv)
@@ -245,6 +245,7 @@ int process_arguments(int argc, char **argv, int from_config_file)
 		{"license", no_argument, 0, 'l'},
 		{"version", no_argument, 0, 'V'},
 		{"stderr-to-stdout", no_argument, 0, 'E'},
+		{"disable-syslog", no_argument, 0, 'D'},
 		{0, 0, 0, 0}
 	};
 #endif
@@ -254,7 +255,7 @@ int process_arguments(int argc, char **argv, int from_config_file)
 		return ERROR;
 
 	optind = 0;
-	snprintf(optchars, MAX_INPUT_BUFFER, "H:f:b:c:a:t:p:S:L:C:K:A:d:s:P:g:2346hlnuVEe");
+	snprintf(optchars, MAX_INPUT_BUFFER, "H:f:b:c:a:t:p:S:L:C:K:A:d:s:P:g:2346hlnuVED");
 
 	while (1) {
 		if (argindex > 0)
@@ -500,8 +501,8 @@ int process_arguments(int argc, char **argv, int from_config_file)
 			open_log_file();
 			break;
 
-		case 'e':
-			enable_syslog = TRUE;
+		case 'D':
+			disable_syslog = TRUE;
 			break;
 
 
@@ -716,7 +717,7 @@ void usage(int result)
 		printf("       [-P <size>] [-S <ssl version>]  [-L <cipherlist>] [-C <clientcert>]\n");
 		printf("       [-K <key>] [-A <ca-certificate>] [-s <logopts>] [-b <bindaddr>]\n");
 		printf("       [-f <cfg-file>] [-p <port>] [-t <interval>:<state>] [-g <log-file>]\n");
-		printf("       [-c <command>] [-E] [-a <arglist...>]\n");
+		printf("       [-c <command>] [-E] [-D] [-a <arglist...>]\n");
 		printf("\n");
 		printf("Options:\n");
 		printf(" -H, --host=HOST              The address of the host running the NRPE daemon\n");
@@ -734,6 +735,7 @@ void usage(int result)
 		printf("                                        (This will be the default in a future release.)\n");
 		printf("                              1         Allow Anonymous Diffie Hellman (default)\n");
 		printf("                              2         Force Anonymous Diffie Hellman\n");
+		printf(" -D, --disable-syslog         Disable logging to syslog facilities\n");
 		printf(" -P, --payload-size=SIZE      Specify non-default payload size for NSClient++\n");
 		printf(" -S, --ssl-version=VERSION    The SSL/TLS version to use. Can be any one of:\n");
 #if OPENSSL_VERSION_NUMBER < 0x10100000

+ 3 - 3
src/nrpe.c

@@ -160,7 +160,7 @@ static void my_disconnect_sighandler(int sig);
 static void complete_SSL_shutdown(SSL *);
 #endif
 
-int enable_syslog = FALSE;
+int disable_syslog = FALSE;
 
 int main(int argc, char **argv)
 {
@@ -957,8 +957,8 @@ int read_config_file(char *filename)
 		else if (!strcmp(varname, "dont_blame_nrpe"))
 			allow_arguments = (atoi(varvalue) == 1) ? TRUE : FALSE;
 
-		else if (!strcmp(varname, "enable_syslog"))
-			enable_syslog = (atoi(varvalue) == 1) ? TRUE : FALSE;
+		else if (!strcmp(varname, "disable_syslog"))
+			disable_syslog = (atoi(varvalue) == 1) ? TRUE : FALSE;
 
 		else if (!strcmp(varname, "allow_bash_command_substitution"))
 			allow_bash_cmd_subst = (atoi(varvalue) == 1) ? TRUE : FALSE;

+ 3 - 5
src/utils.c

@@ -58,7 +58,6 @@ char *log_file = NULL;
 FILE *log_fp = NULL;
 
 static int my_create_socket(struct addrinfo *ai, const char *bind_address, int redirect_stderr);
-extern int enable_debug;
 
 
 /* build the crc table - must be called before calculating the crc value */
@@ -549,10 +548,9 @@ void logit(int priority, const char *format, ...)
 			fprintf(log_fp, "[%llu] %s\n", (unsigned long long)log_time, buffer);
 			fflush(log_fp);
 
-		} else {
-		       if ( enable_syslog )
-                       		syslog(priority, "%s", buffer);
-		       }
+		} else if (!disable_syslog) {
+			syslog(priority, "%s", buffer);
+		}
 
 		free(buffer);
 	}