فهرست منبع

Remove unused functions.

Doug Nazar 1 سال پیش
والد
کامیت
98317dd9a5
4فایلهای تغییر یافته به همراه4 افزوده شده و 55 حذف شده
  1. 0 2
      include/nrpe.h
  2. 0 18
      src/acl.c
  3. 4 4
      src/check_nrpe.c
  4. 0 31
      src/nrpe.c

+ 0 - 2
include/nrpe.h

@@ -52,13 +52,11 @@ void setup_wait_conn(void);
 int wait_conn_fork(int sock);
 void conn_check_peer(int sock);
 void handle_connection(int);
-void init_handle_conn(void);
 int handle_conn_ssl(int sock, void *ssl_ptr);
 int read_packet(int sock, void *ssl_ptr, v2_packet *v2_pkt, v3_packet **v3_pkt);
 void free_memory(void);
 int my_system(char*, int, int*, char**);	/* executes a command via popen(), but also protects against timeouts */
 void my_system_sighandler(int);				/* handles timeouts when executing commands via my_system() */
-void my_connection_sighandler(int);			/* handles timeouts of connection */
 int drop_privileges(char *,char *, int);
 int write_pid_file(void);
 int remove_pid_file(void);

+ 0 - 18
src/acl.c

@@ -100,24 +100,6 @@ int isvalidchar(int c) {
         }
 }
 
-/*
- * Get substring from allowed_hosts from s position to e position.
- */
-
-char * acl_substring(char *string, int s, int e) {
-    char *substring;
-    int len = e - s;
-
-        if (len < 0)
-                return NULL;
-
-    if ( (substring = malloc(len + 1)) == NULL)
-        return NULL;
-
-    memmove(substring, string + s, len + 1);
-    return substring;
-}
-
 /*
  * Add IPv4 host or network to IP ACL. IPv4 format is X.X.X.X[/X].
  * Host will be added to ACL only if it has passed IPv4 format check.

+ 4 - 4
src/check_nrpe.c

@@ -56,7 +56,7 @@ struct sockaddr hostaddr;
 #endif
 int address_family = AF_UNSPEC;
 char *command_name = NULL;
-int socket_timeout = DEFAULT_SOCKET_TIMEOUT;
+int socket_timeout = -1; // after processing command line (including possible config file), this will be set to DEFAULT_SOCKET_TIMEOUT if unchanged;
 char timeout_txt[10];
 int timeout_return_code = -1;
 int stderr_to_stdout = 0;
@@ -114,8 +114,6 @@ int main(int argc, char **argv)
 	if (result != OK || show_help == TRUE || show_license == TRUE || show_version == TRUE)
 		usage(result);			/* usage() will call exit() */
 
-	snprintf(timeout_txt, sizeof(timeout_txt), "%d", socket_timeout);
-
 	if (server_port == 0)
 		server_port = DEFAULT_SERVER_PORT;
 	if (socket_timeout == -1)
@@ -133,6 +131,8 @@ int main(int argc, char **argv)
 	if (sslprm.allowDH == -1)
 		sslprm.allowDH = TRUE;
 
+	snprintf(timeout_txt, sizeof(timeout_txt), "%d", socket_timeout);
+
 	generate_crc32_table();		/* generate the CRC 32 table */
 	setup_ssl();				/* Do all the SSL/TLS set up */
 	set_sig_handlers();			/* initialize alarm signal handling */
@@ -1242,7 +1242,7 @@ int read_packet(int sock, void *ssl_ptr, v2_packet ** v2_pkt, v3_packet ** v3_pk
 		rc = recvall(sock, (char *)&packet, &tot_bytes, socket_timeout);
 
 		if (rc <= 0 || rc != bytes_to_recv) {
-			if (rc < bytes_to_recv) {
+			if (rc >= 0 && rc < bytes_to_recv) {
 				if (packet_ver <= NRPE_PACKET_VERSION_3)
 					printf("CHECK_NRPE: Receive header underflow - only %d bytes received (%zu expected).\n", rc, sizeof(bytes_to_recv));
 			}

+ 0 - 31
src/nrpe.c

@@ -1795,29 +1795,6 @@ void handle_connection(int sock)
 	return;
 }
 
-void init_handle_conn(void)
-{
-#ifdef HAVE_SIGACTION
-	struct sigaction sig_action;
-#endif
-
-	/* log info */
-	if (debug == TRUE)
-		logit(LOG_DEBUG, "Handling the connection...");
-
-	/* set connection handler */
-#ifdef HAVE_SIGACTION
-	sig_action.sa_sigaction = NULL;
-	sig_action.sa_handler = my_connection_sighandler;
-	sigfillset(&sig_action.sa_mask);
-	sig_action.sa_flags = SA_NODEFER | SA_RESTART;
-	sigaction(SIGALRM, &sig_action, NULL);
-#else
-	signal(SIGALRM, my_connection_sighandler);
-#endif	 /* HAVE_SIGACTION */
-	alarm(connection_timeout);
-}
-
 #ifdef HAVE_SSL
 int handle_conn_ssl(int sock, void *ssl_ptr)
 {
@@ -2420,14 +2397,6 @@ void my_system_sighandler(int sig)
 	exit(STATE_CRITICAL);		/* force the child process to exit... */
 }
 
-/* handle errors where connection takes too long */
-void my_connection_sighandler(int sig)
-{
-	(void)sig;
-	logit(LOG_ERR, "Connection has taken too long to establish. Exiting...");
-	exit(STATE_CRITICAL);
-}
-
 /* drops privileges */
 int drop_privileges(char *user, char *group, int full_drop)
 {