Ethan Galstad 23 лет назад
Родитель
Сommit
df33a9eb1a
9 измененных файлов с 49 добавлено и 29 удалено
  1. 8 0
      Changelog
  2. 5 3
      Makefile.in
  3. 2 2
      common/common.h
  4. 2 2
      configure
  5. 2 2
      configure.in
  6. 1 1
      nrpe.spec
  7. 3 3
      src/Makefile.in
  8. 3 5
      src/check_nrpe.c
  9. 23 11
      src/nrpe.c

+ 8 - 0
Changelog

@@ -3,6 +3,14 @@ NRPE Changelog
 **************
 
 
+1.8 - 01/16/2003
+----------------
+- Daemon now closes stdio/out/err properly (James Peterson)
+- Makefile changes (James Peterson)
+- Mode command line option bug fix in daemon
+- Fixed incorrect command line options in check_nrpe plugin
+
+
 1.7 - 01/08/2003
 ----------------
 - Spec file updates and minor bug fixes (James Peterson)

+ 5 - 3
Makefile.in

@@ -1,7 +1,7 @@
 ###############################
 # Makefile for NRPE
 #
-# Last Modified: 01-07-2003
+# Last Modified: 01-16-2003
 ###############################
 
 
@@ -48,9 +48,11 @@ clean:
 	cd $(SRC_BASE); $(MAKE) $@ ; cd ..
 	rm -f core
 	rm -f *~ */*~
-	rm -f config.log config.status config.cache nrpe.cfg nrpe.xinetd Makefile subst $(SRC_COMMON)/config.h init-script init-script.debian init-script.freebsd
 
 distclean: clean
+	cd $(SRC_BASE); $(MAKE) $@ ; cd ..
+	rm -f config.log config.status config.cache nrpe.cfg nrpe.xinetd subst $(SRC_COMMON)/config.h init-script init-script.debian init-script.freebsd
+	rm -f Makefile
 
-devclean: clean
+devclean: distclean
 

+ 2 - 2
common/common.h

@@ -22,8 +22,8 @@
  ************************************************************************/
 
 
-#define PROGRAM_VERSION "1.7"
-#define MODIFICATION_DATE "01-08-2003"
+#define PROGRAM_VERSION "1.8"
+#define MODIFICATION_DATE "01-16-2003"
 
 #define OK		0
 #define ERROR		-1

+ 2 - 2
configure

@@ -525,9 +525,9 @@ fi
 
 
 PKG_NAME=nrpe
-PKG_VERSION="1.7"
+PKG_VERSION="1.8"
 PKG_HOME_URL="http://www.nagios.org/"
-PKG_REL_DATE="01-08-2003"
+PKG_REL_DATE="01-16-2003"
 
 
 ac_aux_dir=

+ 2 - 2
configure.in

@@ -9,9 +9,9 @@ AC_CONFIG_HEADER(common/config.h)
 AC_PREFIX_DEFAULT(/usr/local/nagios)
 
 PKG_NAME=nrpe
-PKG_VERSION="1.7"
+PKG_VERSION="1.8"
 PKG_HOME_URL="http://www.nagios.org/"
-PKG_REL_DATE="01-08-2003"
+PKG_REL_DATE="01-16-2003"
 
 dnl Figure out how to invoke "install" and what install options to use.
 

+ 1 - 1
nrpe.spec

@@ -1,5 +1,5 @@
 %define name nrpe
-%define version 1.7
+%define version 1.8
 %define release 1
 %define nsusr nagios
 %define nsgrp nagios

+ 3 - 3
src/Makefile.in

@@ -1,7 +1,7 @@
 ###############################
 # Makefile for NRPE
 #
-# Last Modified: 07-09-2002
+# Last Modified: 01-16-2003
 ###############################
 
 
@@ -27,8 +27,8 @@ check_nrpe: check_nrpe.c utils.c utils.h $(SRC_COMMON)/common.h $(SRC_COMMON)/co
 clean:
 	rm -f core nrpe check_nrpe
 	rm -f *~ */*~
-	rm -f Makefile
 
 distclean: clean
+	rm -f Makefile
 
-devclean: clean
+devclean: distclean

+ 3 - 5
src/check_nrpe.c

@@ -4,10 +4,9 @@
  * Copyright (c) 1999-2003 Ethan Galstad (nagios@nagios.org)
  * License: GPL
  *
- * Last Modified: 01-08-2003
+ * Last Modified: 01-16-2003
  *
- * Command line: CHECK_NRPE -H <host_address> [-p port] [-c command] [-wt warn_time] \
- *                          [-ct crit_time] [-to to_sec]
+ * Command line: CHECK_NRPE -H <host_address> [-p port] [-c command] [-to to_sec]
  *
  * Description:
  *
@@ -67,8 +66,7 @@ int main(int argc, char **argv){
 
 	if(result!=OK || show_help==TRUE){
 
-		printf("Usage: %s -H <host_address> [-p port] [-c command] [-wt warn_time]\n",argv[0]);
-		printf("          [-ct crit_time] [-to to_sec]\n");
+		printf("Usage: %s -H <host_address> [-p port] [-c command] [-to to_sec]\n",argv[0]);
 		printf("\n");
 		printf("Options:\n");
 		printf(" <host_address> = The IP address of the host running the NRPE daemon\n");

+ 23 - 11
src/nrpe.c

@@ -4,7 +4,7 @@
  * Copyright (c) 1999-2003 Ethan Galstad (nagios@nagios.org)
  * License: GPL
  *
- * Last Modified: 01-08-2003
+ * Last Modified: 01-16-2003
  *
  * Command line: nrpe -c <config_file> [--inetd | --daemon]
  *
@@ -149,21 +149,25 @@ int main(int argc, char **argv){
 	/* else daemonize and start listening for requests... */
 	else if(fork()==0){
 
-		/* We are in the 1st child, become session leader */
+		/* we're a daemon - set up a new process group */
 		setsid();
 
 		/* ignore SIGHUP */
 		signal(SIGHUP, SIG_IGN);
 
-		/* fork again, 1st child exits */
-		if(fork()!=0)
-			exit(0);
-
-		/* grandchild process continues... */
-	  
 		chdir("/");
 		umask(0);
 
+		/* close standard file descriptors */
+		close(0);
+		close(1);
+		close(2);
+
+		/* redirect standard descriptors to /dev/null */
+		open("/dev/null",O_RDONLY);
+		open("/dev/null",O_WRONLY);
+		open("/dev/null",O_WRONLY);
+
 		/* drop privileges */
 		drop_privileges(nrpe_user,nrpe_group);
 
@@ -941,7 +945,7 @@ int drop_privileges(char *user, char *group){
 /* process command line arguments */
 int process_arguments(int argc, char **argv){
 	int x;
-
+	int have_mode=FALSE;
 
 	/* no options were supplied */
 	if(argc<2)
@@ -959,10 +963,14 @@ int process_arguments(int argc, char **argv){
 			else
 				return ERROR;
 		        }
-		else if(!strcmp(argv[x-1],"-d") || !strcmp(argv[x-1],"--daemon"))
+		else if(!strcmp(argv[x-1],"-d") || !strcmp(argv[x-1],"--daemon")){
 			use_inetd=FALSE;
-		else if(!strcmp(argv[1],"-i") || !strcmp(argv[x-1],"--inetd"))
+			have_mode=TRUE;
+		        }
+		else if(!strcmp(argv[1],"-i") || !strcmp(argv[x-1],"--inetd")){
 			use_inetd=TRUE;
+			have_mode=TRUE;
+		        }
 		else if(!strcmp(argv[x-1],"-h") || !strcmp(argv[x-1],"--help"))
 			show_help=TRUE;
 		else if(!strcmp(argv[x-1],"-l") || !strcmp(argv[x-1],"--license"))
@@ -973,6 +981,10 @@ int process_arguments(int argc, char **argv){
 			return ERROR;
 	        }
 
+	/* bail if we didn't get a mode */
+	if(have_mode==FALSE)
+		return ERROR;
+
 	return OK;
         }