Browse Source

Prep for NRPE 2.5

Ethan Galstad 20 years ago
parent
commit
60e5478bf3
7 changed files with 27 additions and 17 deletions
  1. 1 1
      Changelog
  2. 1 1
      configure
  3. 1 1
      configure.in
  4. 1 1
      include/common.h
  5. 6 6
      include/dh.h
  6. 1 1
      src/check_nrpe.c
  7. 16 6
      src/nrpe.c

+ 1 - 1
Changelog

@@ -3,7 +3,7 @@ NRPE Changelog
 **************
 
 
-2.5 - ??/??/2006
+2.5 - 04/06/2006
 ----------------
 - (Re)added allowed_hosts option for systems that don't support TCP wrappers
 - Fix for SSL errors under Solaris 8 (Niels Endres)

+ 1 - 1
configure

@@ -1296,7 +1296,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 PKG_NAME=nrpe
 PKG_VERSION="2.5"
 PKG_HOME_URL="http://www.nagios.org/"
-PKG_REL_DATE="03-21-2006"
+PKG_REL_DATE="04-06-2006"
 
 ac_aux_dir=
 for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do

+ 1 - 1
configure.in

@@ -11,7 +11,7 @@ AC_PREFIX_DEFAULT(/usr/local/nagios)
 PKG_NAME=nrpe
 PKG_VERSION="2.5"
 PKG_HOME_URL="http://www.nagios.org/"
-PKG_REL_DATE="03-21-2006"
+PKG_REL_DATE="04-06-2006"
 
 dnl Figure out how to invoke "install" and what install options to use.
 AC_PROG_INSTALL

+ 1 - 1
include/common.h

@@ -24,7 +24,7 @@
 #include "config.h"
 
 #define PROGRAM_VERSION "2.5"
-#define MODIFICATION_DATE "03-21-2006"
+#define MODIFICATION_DATE "04-06-2006"
 
 #define OK		0
 #define ERROR		-1

+ 6 - 6
include/dh.h

@@ -4,12 +4,12 @@
 DH *get_dh512()
 	{
 	static unsigned char dh512_p[]={
-		0xC4,0xA5,0x12,0x8D,0x07,0x6B,0x7C,0x00,0x1A,0x5E,0xFE,0xF5,
-		0xA8,0x36,0x55,0xBB,0xBD,0x23,0x69,0x76,0x34,0xA0,0x36,0x79,
-		0x15,0x70,0x22,0xFF,0xAB,0xA8,0x8F,0xAF,0x7B,0x4C,0x9F,0xAB,
-		0x16,0x7D,0xB6,0x92,0x51,0xE6,0x0C,0x50,0x39,0xCB,0x92,0x92,
-		0x29,0x24,0x03,0x32,0xC7,0x26,0x26,0x36,0xA5,0x10,0x35,0x42,
-		0x7B,0xA6,0x0F,0x33,
+		0xB0,0xE0,0xEC,0x93,0x2C,0x3E,0xBB,0x6C,0x9C,0x7D,0xD7,0x46,
+		0xA5,0x9A,0xBD,0x05,0x35,0x09,0xAA,0xD4,0xF6,0x59,0xD9,0xB7,
+		0xC8,0x04,0x7A,0x88,0x0F,0xBF,0x9D,0xBB,0xAE,0xC9,0xD0,0xA2,
+		0xC6,0xE5,0x8E,0xAC,0x13,0x01,0x4C,0x2B,0x1E,0x18,0xB0,0xC6,
+		0x46,0x6E,0x70,0x6E,0xED,0xBC,0x4C,0x47,0xA3,0x9D,0x23,0x6D,
+		0xD1,0x37,0xFB,0x3B,
 		};
 	static unsigned char dh512_g[]={
 		0x02,

+ 1 - 1
src/check_nrpe.c

@@ -4,7 +4,7 @@
  * Copyright (c) 1999-2006 Ethan Galstad (nagios@nagios.org)
  * License: GPL
  *
- * Last Modified: 03-21-2006
+ * Last Modified: 04-06-2006
  *
  * Command line: CHECK_NRPE -H <host_address> [-p port] [-c command] [-to to_sec]
  *

+ 16 - 6
src/nrpe.c

@@ -4,7 +4,7 @@
  * Copyright (c) 1999-2006 Ethan Galstad (nagios@nagios.org)
  * License: GPL
  *
- * Last Modified: 03-21-2006
+ * Last Modified: 04-06-2006
  *
  * Command line: nrpe -c <config_file> [--inetd | --daemon]
  *
@@ -62,6 +62,7 @@ char    *nrpe_group=NULL;
 char    *allowed_hosts=NULL;
 
 char    *pid_file=NULL;
+int     wrote_pid_file=FALSE;
 
 int     allow_arguments=FALSE;
 
@@ -882,7 +883,8 @@ int is_an_allowed_host(char *connecting_host){
 	int result=0;
         struct hostent *myhost;
 	char **pptr=NULL;
-	char resolved_addr[INET6_ADDRSTRLEN]="";
+	char *save_connecting_host=NULL;
+	struct in_addr addr;
 	
 	/* make sure we have something */
 	if(connecting_host==NULL)
@@ -909,6 +911,7 @@ int is_an_allowed_host(char *connecting_host){
 		if((temp_buffer=strdup(allowed_hosts))==NULL)
 			return 0;
 
+		save_connecting_host=strdup(connecting_host);
 		for(temp_ptr=strtok(temp_buffer,",");temp_ptr!=NULL;temp_ptr=strtok(NULL,",")){
 
 			myhost=gethostbyname(temp_ptr);
@@ -916,9 +919,8 @@ int is_an_allowed_host(char *connecting_host){
 
 				/* check all addresses for the host... */
 				for(pptr=myhost->h_addr_list;*pptr!=NULL;pptr++){
-
-					inet_ntop(myhost->h_addrtype,*pptr,resolved_addr,sizeof(resolved_addr));
-					if(!strcmp(resolved_addr,connecting_host)){
+					memcpy(&addr, *pptr, sizeof(addr));
+					if(!strcmp(save_connecting_host, inet_ntoa(addr))){
 						result=1;
 						break;
 					        }
@@ -928,6 +930,9 @@ int is_an_allowed_host(char *connecting_host){
 			if(result==1)
 				break;
 		        }
+
+		strcpy(connecting_host, save_connecting_host);
+		free(save_connecting_host);
 	        }
 
 	free(temp_buffer);
@@ -1502,7 +1507,7 @@ int write_pid_file(void){
 
 			/* previous process is still running */
 			else{
-				syslog(LOG_ERR,"There's already a nrpe server running.");
+				syslog(LOG_ERR,"There's already an NRPE server running (PID %lu).  Bailing out...",(unsigned long)pid);
 				return ERROR;
 			        }
 		        }
@@ -1513,6 +1518,7 @@ int write_pid_file(void){
 		sprintf(pbuf,"%d\n",(int)getpid());
 		write(fd,pbuf,strlen(pbuf));
 		close(fd);
+		wrote_pid_file=TRUE;
 	        }
 	else{
 		syslog(LOG_ERR,"Cannot write to pidfile '%s' - check your privileges.",pid_file);
@@ -1530,6 +1536,10 @@ int remove_pid_file(void){
 	if(pid_file==NULL)
 		return OK;
 
+	/* pid file was not written */
+	if(wrote_pid_file==FALSE)
+		return OK;
+
 	/* remove existing pid file */
 	if(unlink(pid_file)==-1){
 		syslog(LOG_ERR,"Cannot remove pidfile '%s' - check your privileges.",pid_file);