Commit 06c2c852 authored by Jakub Jirutka's avatar Jakub Jirutka

main/nrpe: patch to not daemonize itself, improve runscript

parent 7c0d8c32
# Maintainer: Jeff Bilyk <jbilyk@gmail.com>
pkgname=nrpe
pkgver=2.15
pkgrel=5
pkgrel=6
pkgusers="nagios"
pkggroups="nagios"
pkgdesc="NRPE allows you to remotely execute Nagios plugins on other Linux/Unix machines."
......@@ -12,6 +12,8 @@ makedepends="libressl-dev perl"
install="nrpe.pre-install"
subpackages="$pkgname-plugin"
source="http://downloads.sourceforge.net/nagios/$pkgname-$pkgver.tar.gz
stay-in-foreground.patch
sample-config.patch
nrpe.initd
nrpe.confd"
builddir="$srcdir/$pkgname-$pkgver"
......@@ -55,5 +57,7 @@ plugin() {
}
sha512sums="03ce9774b5112d03235dc9da075770d89d1bcc5ffa5faf221ff7ea8ec5c92ded1e1ae9222581a87cf53736d190ac047e1acce7edc2f31f26c432d786cdef0e73 nrpe-2.15.tar.gz
7e8ed9170b20cc1e33caacc7e007bd4eef17aa100a24802f67d4c06870d3228b68da4661c75dbe0a74711efe0c9155111c380bcd80a352fe0e198aaa6ccbaa2e nrpe.initd
1070f3aaae560c2b2ee5195eb23787504864a8b6e1a92181158269d30e525733136482c7d299a71bbd44f575d2c919935adf9c162be6cd4fa99bbad06b9c3b0c nrpe.confd"
53e4060a81768058d03262ebb1f2e72b1faebc59d42b5a1deea64b917cc4d4f1ab308f122f84fe31af174198f8cfc7c13858ab91aaeb88c7b55a2d3981d22fda stay-in-foreground.patch
4ac80b51fbde6e2a54764e5ecc83e0cbec43534cb5f29e8efc7f4b0442afe72200d5d92f1e2785c021c20a111464af6897d5e89ba467b06d3f08a324a302669d sample-config.patch
b2f23bab97384ef8f1760c79d0cbadb4e81d4bb8134887a38662033a7f0c30480222b9ecb78c3ae276bd8b35470b3db316143f591baa2c535f5fb26c34ad2824 nrpe.initd
05a0f1f5f75345370cae3262f9988d537e24dfcbb6c14a1ff3486193625481045d0844c035f7be491e74ca9ad45ed0fae7b7005616936cc274cd7e8a851c8628 nrpe.confd"
# override the default options.
# nrpe_options="-c /etc/nrpe.cfg"
# Config file for /etc/init.d/nrpe
# Path of the config file.
#cfgfile="/etc/nrpe.cfg"
# The user to run NRPE.
#user="nagios"
# The group to run NRPE.
#group=
# Additional options.
#command_args=""
#!/sbin/openrc-run
# Sample init.d file for alpine linux.
: ${user:="nagios"}
: ${cfgfile:="/etc/nrpe.cfg"}
: ${nrpe_options:=" -c $cfgfile"} # for backward compatibility
daemon=/usr/bin/nrpe
conf=/etc/nrpe.cfg
command="/usr/bin/nrpe"
command_args="-f $nrpe_options ${command_args:-}"
command_background="yes"
pidfile="/run/$RC_SVCNAME.pid"
start_stop_daemon_args="
--user $user
${group:+--group $group}"
depend() {
need net
after firewall
}
get_pidfile() {
if [ -r $conf ]; then
pidfile=$(awk -F= '/^pid_file/ {print $2}' $conf)
fi
pidfile=${pidfile:-/var/run/nrpe.pid}
}
start() {
get_pidfile
ebegin "Starting NRPE"
start-stop-daemon --start --quiet \
--pidfile $pidfile \
--exec $daemon -- -d ${nrpe_options:- -c $conf}
eend $?
}
stop() {
get_pidfile
ebegin "Stopping NRPE"
start-stop-daemon --stop --quiet \
--exec $daemon \
--pidfile $pidfile
eend $?
}
--- a/sample-config/nrpe.cfg.in
+++ b/sample-config/nrpe.cfg.in
@@ -18,15 +18,6 @@
-# PID FILE
-# The name of the file in which the NRPE daemon should write it's process ID
-# number. The file is only written if the NRPE daemon is started by the root
-# user and is running in standalone mode.
-
-pid_file=/var/run/nrpe.pid
-
-
-
# PORT NUMBER
# Port number we should wait for connections on.
# NOTE: This must be a non-priviledged port (i.e. > 1024).
@@ -50,8 +41,10 @@
# You can either supply a username or a UID.
#
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd
+# NOTE: OpenRC starts NRPE already as @nrpe_user@ user. You can change the user
+# in /etc/conf.d/nrpe.
-nrpe_user=@nrpe_user@
+#nrpe_user=@nrpe_user@
@@ -60,8 +53,10 @@
# You can either supply a group name or a GID.
#
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd
+# NOTE: OpenRC starts NRPE already as @nrpe_group@ group. You can change the
+# group in /etc/conf.d/nrpe.
-nrpe_group=@nrpe_group@
+#nrpe_group=@nrpe_group@
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;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment