aboutsummaryrefslogtreecommitdiffstats
path: root/main/nrpe/stay-in-foreground.patch
diff options
context:
space:
mode:
Diffstat (limited to 'main/nrpe/stay-in-foreground.patch')
-rw-r--r--main/nrpe/stay-in-foreground.patch76
1 files changed, 76 insertions, 0 deletions
diff --git a/main/nrpe/stay-in-foreground.patch b/main/nrpe/stay-in-foreground.patch
new file mode 100644
index 0000000000..ad54c25041
--- /dev/null
+++ b/main/nrpe/stay-in-foreground.patch
@@ -0,0 +1,76 @@
+From: Jakub Jirutka <jakub@jirutka.cz>
+Date: Mon, 28 Aug 2017 21:13:00 +0200
+Subject: [PATCH] Add option "stay in foreground"
+
+This patch is based on https://support.nagios.com/forum/viewtopic.php?f=34&t=17597.
+
+--- a/src/nrpe.c
++++ b/src/nrpe.c
+@@ -98,6 +98,7 @@
+ int use_inetd=TRUE;
+ int debug=FALSE;
+ int use_src=FALSE; /* Define parameter for SRC option */
++int stay_in_foreground=FALSE;
+
+
+ void complete_SSL_shutdown( SSL *);
+@@ -171,6 +172,7 @@
+ printf(" -d = Run as a standalone daemon\n");
+ /* Updates help section to indicate how to start under SRC on AIX */
+ printf(" -d -s = Run as a subsystem under AIX\n");
++ printf(" -f = Run and stay in foreground\n");
+ printf("\n");
+ printf("Notes:\n");
+ printf("This program is designed to process requests from the check_nrpe\n");
+@@ -292,6 +294,22 @@
+ handle_connection(0);
+ }
+
++ /* if we're running in the foreground... */
++ else if (stay_in_foreground==TRUE){
++
++ /* drop privileges */
++ drop_privileges(nrpe_user,nrpe_group);
++
++ /* make sure we're not root */
++ check_privileges();
++
++ /* log info to syslog facility */
++ syslog(LOG_NOTICE,"Starting up NRPE");
++
++ /* wait for connections */
++ wait_for_connections();
++ }
++
+ /* if we're running under SRC...
+ we don't fork but does drop-privileges*/
+ else if (use_src==TRUE){
+@@ -2088,6 +2103,7 @@
+ {"4", no_argument, 0, '4'},
+ {"6", no_argument, 0, '4'},
+ {"daemon", no_argument, 0, 'd'},
++ {"foreground", no_argument, 0, 'f'},
+ {"no-ssl", no_argument, 0, 'n'},
+ {"help", no_argument, 0, 'h'},
+ {"license", no_argument, 0, 'l'},
+@@ -2099,7 +2115,7 @@
+ if(argc<2)
+ return ERROR;
+
+- snprintf(optchars,MAX_INPUT_BUFFER,"c:hVldi46n");
++ snprintf(optchars,MAX_INPUT_BUFFER,"c:hVldi46nf");
+
+ while(1){
+ #ifdef HAVE_GETOPT_LONG
+@@ -2130,6 +2146,11 @@
+ case 'd':
+ use_inetd=FALSE;
+ have_mode=TRUE;
++ break;
++ case 'f':
++ stay_in_foreground=TRUE;
++ use_inetd=FALSE;
++ have_mode=TRUE;
+ break;
+ case 'i':
+ use_inetd=TRUE;