diff options
author | Diego Elio Pettenò <flameeyes@gentoo.org> | 2012-08-23 23:07:05 +0000 |
---|---|---|
committer | Diego Elio Pettenò <flameeyes@gentoo.org> | 2012-08-23 23:07:05 +0000 |
commit | f83595858319e0813c01abc8ea1ea53f989fe853 (patch) | |
tree | d00cac56a948802f1bfbc49a8f161360f7c1f4df /net-analyzer/nrpe/files | |
parent | Move nagios-nrpe to just nrpe. (diff) | |
download | gentoo-2-f83595858319e0813c01abc8ea1ea53f989fe853.tar.gz gentoo-2-f83595858319e0813c01abc8ea1ea53f989fe853.tar.bz2 gentoo-2-f83595858319e0813c01abc8ea1ea53f989fe853.zip |
Move from net-analyzer/nagios-nrpe to net-analyzer/nrpe, as the package work with Icinga just fine.
(Portage version: 2.2.0_alpha121/cvs/Linux x86_64, RepoMan options: --force)
Diffstat (limited to 'net-analyzer/nrpe/files')
-rw-r--r-- | net-analyzer/nrpe/files/nagios-nrpe-2.13-command-args.patch | 15 | ||||
-rw-r--r-- | net-analyzer/nrpe/files/nagios-nrpe-2.13-multiline.patch | 200 | ||||
-rw-r--r-- | net-analyzer/nrpe/files/nagios-nrpe-2.13-tcpd.patch | 33 | ||||
-rw-r--r-- | net-analyzer/nrpe/files/nrpe-nagios3 | 36 | ||||
-rw-r--r-- | net-analyzer/nrpe/files/nrpe-nagios3-r1 | 22 | ||||
-rw-r--r-- | net-analyzer/nrpe/files/nrpe.init | 30 | ||||
-rw-r--r-- | net-analyzer/nrpe/files/nrpe.xinetd | 11 | ||||
-rw-r--r-- | net-analyzer/nrpe/files/nrpe.xinetd.2 | 5 |
8 files changed, 352 insertions, 0 deletions
diff --git a/net-analyzer/nrpe/files/nagios-nrpe-2.13-command-args.patch b/net-analyzer/nrpe/files/nagios-nrpe-2.13-command-args.patch new file mode 100644 index 000000000000..fe6751aa55ee --- /dev/null +++ b/net-analyzer/nrpe/files/nagios-nrpe-2.13-command-args.patch @@ -0,0 +1,15 @@ +--- configure.old 2008-03-10 22:04:41.000000000 +0100 ++++ configure.in 2012-01-04 09:46:38.000000000 +0100 +@@ -362,7 +362,11 @@ + AC_SUBST(NAGIOS_INSTALL_OPTS) + + +-AC_ARG_ENABLE(command-args,--enable-command-args allows clients to specify command arguments. *** THIS IS A SECURITY RISK! *** Read the SECURITY file before using this option!,AC_DEFINE_UNQUOTED(ENABLE_COMMAND_ARGUMENTS)) ++AC_ARG_ENABLE(command-args,--enable-command-args allows clients to specify command arguments. *** THIS IS A SECURITY RISK! *** Read the SECURITY file before using this option!,[ ++ if test x$enableval = xyes; then ++ AC_DEFINE_UNQUOTED(ENABLE_COMMAND_ARGUMENTS) ++ fi ++ ]) + + + AC_PATH_PROG(PERL,perl) diff --git a/net-analyzer/nrpe/files/nagios-nrpe-2.13-multiline.patch b/net-analyzer/nrpe/files/nagios-nrpe-2.13-multiline.patch new file mode 100644 index 000000000000..8d96149cb36e --- /dev/null +++ b/net-analyzer/nrpe/files/nagios-nrpe-2.13-multiline.patch @@ -0,0 +1,200 @@ +diff --git a/include/common.h b/include/common.h +index 202dec4..86f8e32 100755 +--- a/include/common.h ++++ b/include/common.h +@@ -41,7 +41,7 @@ + #define DEFAULT_SOCKET_TIMEOUT 10 /* timeout after 10 seconds */
+ #define DEFAULT_CONNECTION_TIMEOUT 300 /* timeout if daemon is waiting for connection more than this time */
+
+-#define MAX_INPUT_BUFFER 2048 /* max size of most buffers we use */
++#define MAX_INPUT_BUFFER 16384 /* max size of most buffers we use */
+ #define MAX_FILENAME_LENGTH 256
+
+ #define MAX_HOST_ADDRESS_LENGTH 256 /* max size of a host address */
+@@ -55,12 +55,14 @@ +
+ #define QUERY_PACKET 1 /* id code for a packet containing a query */
+ #define RESPONSE_PACKET 2 /* id code for a packet containing a response */
++#define RESPONSE_PACKET_WITH_MORE 3 /* id code for a packet containing a response, with more data to follow */
+
+ #define NRPE_PACKET_VERSION_3 3 /* packet version identifier */
+ #define NRPE_PACKET_VERSION_2 2
+ #define NRPE_PACKET_VERSION_1 1 /* older packet version identifiers (no longer supported) */
+
+ #define MAX_PACKETBUFFER_LENGTH 1024 /* max amount of data we'll send in one query/response */
++ /* WARNING - do not change this as older clients/servers will not work */
+
+ typedef struct packet_struct{
+ int16_t packet_version;
+diff --git a/src/check_nrpe.c b/src/check_nrpe.c +index 0adced1..ff4b920 100755 +--- a/src/check_nrpe.c ++++ b/src/check_nrpe.c +@@ -221,6 +221,11 @@ int main(int argc, char **argv){ + return STATE_UNKNOWN;
+ }
+
++ /* Altinity patch: Allow multiple packets to be received */
++ /* Indentation not corrected to allow simpler patching */
++ /* START MULTI_PACKET LOOP */
++ do {
++
+ /* wait for the response packet */
+ bytes_to_recv=sizeof(receive_packet);
+ if(use_ssl==FALSE)
+@@ -233,31 +238,24 @@ int main(int argc, char **argv){ + /* reset timeout */
+ alarm(0);
+
+- /* close the connection */
+-#ifdef HAVE_SSL
+- if(use_ssl==TRUE){
+- SSL_shutdown(ssl);
+- SSL_free(ssl);
+- SSL_CTX_free(ctx);
+- }
+-#endif
+- graceful_close(sd,1000);
+-
+ /* recv() error */
+ if(rc<0){
+ printf("CHECK_NRPE: Error receiving data from daemon.\n");
++ graceful_close(sd,1000);
+ return STATE_UNKNOWN;
+ }
+
+ /* server disconnected */
+ else if(rc==0){
+ printf("CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.\n");
++ graceful_close(sd,1000);
+ return STATE_UNKNOWN;
+ }
+
+ /* receive underflow */
+ else if(bytes_to_recv<sizeof(receive_packet)){
+ printf("CHECK_NRPE: Receive underflow - only %d bytes received (%d expected).\n",bytes_to_recv,sizeof(receive_packet));
++ graceful_close(sd,1000);
+ return STATE_UNKNOWN;
+ }
+
+@@ -271,21 +269,21 @@ int main(int argc, char **argv){ + calculated_crc32=calculate_crc32((char *)&receive_packet,sizeof(receive_packet));
+ if(packet_crc32!=calculated_crc32){
+ printf("CHECK_NRPE: Response packet had invalid CRC32.\n");
+- close(sd);
++ graceful_close(sd,1000);
+ return STATE_UNKNOWN;
+ }
+
+ /* check packet version */
+ if(ntohs(receive_packet.packet_version)!=NRPE_PACKET_VERSION_2){
+ printf("CHECK_NRPE: Invalid packet version received from server.\n");
+- close(sd);
++ graceful_close(sd,1000);
+ return STATE_UNKNOWN;
+ }
+
+ /* check packet type */
+- if(ntohs(receive_packet.packet_type)!=RESPONSE_PACKET){
++ if(ntohs(receive_packet.packet_type)!=RESPONSE_PACKET && ntohs(receive_packet.packet_type)!=RESPONSE_PACKET_WITH_MORE){
+ printf("CHECK_NRPE: Invalid packet type received from server.\n");
+- close(sd);
++ graceful_close(sd,1000);
+ return STATE_UNKNOWN;
+ }
+
+@@ -297,8 +295,18 @@ int main(int argc, char **argv){ + if(!strcmp(receive_packet.buffer,""))
+ printf("CHECK_NRPE: No output returned from daemon.\n");
+ else
+- printf("%s\n",receive_packet.buffer);
+- }
++ printf("%s",receive_packet.buffer);
++
++ } while (ntohs(receive_packet.packet_type)==RESPONSE_PACKET_WITH_MORE);
++ /* END MULTI_PACKET LOOP */
++
++ /* Finish output with newline */
++ printf("\n");
++
++ /* close the connection */
++ graceful_close(sd,1000);
++
++ }
+
+ /* reset the alarm */
+ else
+@@ -434,6 +442,14 @@ int graceful_close(int sd, int timeout){ + struct timeval tv;
+ char buf[1000];
+
++#ifdef HAVE_SSL
++ if(use_ssl==TRUE){
++ SSL_shutdown(ssl);
++ SSL_free(ssl);
++ SSL_CTX_free(ctx);
++ }
++#endif
++
+ /* send FIN packet */
+ shutdown(sd,SHUT_WR);
+ for(;;){
+diff --git a/src/nrpe.c b/src/nrpe.c +index f2b0164..dfa8262 100755 +--- a/src/nrpe.c ++++ b/src/nrpe.c +@@ -972,6 +972,8 @@ void handle_connection(int sock){ + char processed_command[MAX_INPUT_BUFFER];
+ int result=STATE_OK;
+ int early_timeout=FALSE;
++ int bytes_copied=0;
++ char *pbuffer=&buffer[0];
+ int rc;
+ int x;
+ #ifdef DEBUG
+@@ -1188,6 +1190,14 @@ void handle_connection(int sock){ + if(buffer[strlen(buffer)-1]=='\n')
+ buffer[strlen(buffer)-1]='\x0';
+
++ /* Altinity patch to allow multi packet responses */
++ /* Loop not indented to allow easier patching */
++ /* START MULTI_PACKET LOOP */
++ do {
++
++ if(debug==TRUE)
++ syslog(LOG_DEBUG,"Sending response - bytes left: %d", strlen(pbuffer));
++
+ /* clear the response packet buffer */
+ bzero(&send_packet,sizeof(send_packet));
+
+@@ -1196,11 +1206,17 @@ void handle_connection(int sock){ +
+ /* initialize response packet data */
+ send_packet.packet_version=(int16_t)htons(NRPE_PACKET_VERSION_2);
+- send_packet.packet_type=(int16_t)htons(RESPONSE_PACKET);
+ send_packet.result_code=(int16_t)htons(result);
+- strncpy(&send_packet.buffer[0],buffer,MAX_PACKETBUFFER_LENGTH);
++ strncpy(&send_packet.buffer[0],pbuffer,MAX_PACKETBUFFER_LENGTH);
+ send_packet.buffer[MAX_PACKETBUFFER_LENGTH-1]='\x0';
+-
++
++ bytes_copied = strlen(&send_packet.buffer[0]);
++ pbuffer = pbuffer+bytes_copied;
++ if(strlen(pbuffer)>0)
++ send_packet.packet_type=(int16_t)htons(RESPONSE_PACKET_WITH_MORE);
++ else
++ send_packet.packet_type=(int16_t)htons(RESPONSE_PACKET);
++
+ /* calculate the crc 32 value of the packet */
+ send_packet.crc32_value=(u_int32_t)0L;
+ calculated_crc32=calculate_crc32((char *)&send_packet,sizeof(send_packet));
+@@ -1219,6 +1235,9 @@ void handle_connection(int sock){ + SSL_write(ssl,&send_packet,bytes_to_send);
+ #endif
+
++ } while (strlen(pbuffer) > 0);
++ /* END MULTI_PACKET LOOP */
++
+ #ifdef HAVE_SSL
+ if(ssl){
+ SSL_shutdown(ssl);
diff --git a/net-analyzer/nrpe/files/nagios-nrpe-2.13-tcpd.patch b/net-analyzer/nrpe/files/nagios-nrpe-2.13-tcpd.patch new file mode 100644 index 000000000000..67dd22e05310 --- /dev/null +++ b/net-analyzer/nrpe/files/nagios-nrpe-2.13-tcpd.patch @@ -0,0 +1,33 @@ +--- configure.in.orig 2008-03-10 22:04:41.000000000 +0100 ++++ configure.in 2012-01-08 17:59:49.804613011 +0100 +@@ -147,11 +147,27 @@ + AC_CHECK_LIB(nsl,main,SOCKETLIBS="$SOCKETLIBS -lnsl") + AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket") + AC_SUBST(SOCKETLIBS) +-AC_CHECK_LIB(wrap,main,[ +- LIBWRAPLIBS="$LIBWRAPLIBS -lwrap" ++ ++AC_ARG_ENABLE(tcp-wrapper,--enable-tcp-wrapper enables support for TCP wrappers. *** DISABLING IS A SECURITY RISK! *** Read the SECURITY file before using this option! (default: auto),[ ++ if test x$enableval = xyes; then ++ enable_tcp_wrapper=yes ++ else ++ enable_tcp_wrapper=no ++ fi ++ ],enable_tcp_wrapper="auto") ++ ++LIBWRAPLIBS="" ++if test "x$enable_tcp_wrapper" = "xauto"; then ++ AC_CHECK_LIB(wrap,main,[ ++ LIBWRAPLIBS="$LIBWRAPLIBS -lwrap" ++ AC_DEFINE(HAVE_LIBWRAP) ++ ]) ++elif test "x$enable_tcp_wrapper" = "xyes"; then ++ AC_CHECK_LIB(wrap,main,LIBWRAPLIBS="$LIBWRAPLIBS -lwrap",[AC_MSG_ERROR([TCP wrapper library not found])]) + AC_DEFINE(HAVE_LIBWRAP) +- ]) ++fi + AC_SUBST(LIBWRAPLIBS) ++ + AC_CHECK_FUNCS(strdup strstr strtoul initgroups closesocket) + + dnl socklen_t check - from curl diff --git a/net-analyzer/nrpe/files/nrpe-nagios3 b/net-analyzer/nrpe/files/nrpe-nagios3 new file mode 100644 index 000000000000..28be2b83377f --- /dev/null +++ b/net-analyzer/nrpe/files/nrpe-nagios3 @@ -0,0 +1,36 @@ +#!/sbin/runscript + +extra_started_commands="reload" + +depend() { + need net +} + +start() { + ebegin "Starting nrpe" + start-stop-daemon --start --quiet --name nrpe \ + --exec /usr/bin/nrpe \ + -c nagios:nagios \ + -- -c /etc/nagios/nrpe.cfg \ + --daemon + eend $? "Failed to Start nrpe" +} + +stop() { + ebegin "Stopping nrpe" + start-stop-daemon --stop --quiet -n nrpe + eend $? "Failed to Stop nrpe" +} + +reload() { + ebegin "Reloading nrpe" + kill -HUP `pgrep nrpe | head -1` + eend $? "Failed to reload nrpe" +} + +restart() { + ebegin "Restarting nrpe" + svc_stop + svc_start + eend $? "Failed to Restart nrpe" +} diff --git a/net-analyzer/nrpe/files/nrpe-nagios3-r1 b/net-analyzer/nrpe/files/nrpe-nagios3-r1 new file mode 100644 index 000000000000..8032a30c47a6 --- /dev/null +++ b/net-analyzer/nrpe/files/nrpe-nagios3-r1 @@ -0,0 +1,22 @@ +#!/sbin/runscript + +extra_started_commands="reload" + +command="/usr/bin/nrpe" +command_args="-c /etc/nagios/nrpe.cfg --daemon" +pidfile="${pidfile:-/var/run/nrpe/nrpe.pid}" +start_stop_daemon_args="--user nagios --group nagios" + +depend() { + need net +} + +start_pre() { + checkpath -d -m 0750 -o nagios:nagios /var/run/nrpe +} + +reload() { + ebegin "Reloading nrpe" + kill -HUP $(head -n1 ${pidfile}) + eend $? "Failed to reload nrpe" +} diff --git a/net-analyzer/nrpe/files/nrpe.init b/net-analyzer/nrpe/files/nrpe.init new file mode 100644 index 000000000000..cf3b2242b2dd --- /dev/null +++ b/net-analyzer/nrpe/files/nrpe.init @@ -0,0 +1,30 @@ +#!/sbin/runscript +# Copyright 1999-2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-analyzer/nrpe/files/nrpe.init,v 1.1 2012/08/23 23:07:05 flameeyes Exp $ + +: ${CFGFILE:=/etc/nagios/nrpe.cfg} + +get_config() { + [ -f ${CFGFILE} ] || return 1 + + sed -n -e 's:^[ \t]*'$1'=\([^#]\+\).*:\1:p' \ + ${CFGFILE} +} + +extra_started_commands="reload" + +command=/usr/libexec/${SVCNAME} +command_args="-c ${CFGFILE} --daemon" +pidfile=$(get_config pid_file) + +depend() { + config ${CFGFILE} + need net +} + +reload() { + ebegin "Reloading ${SVCNAME}" + kill -HUP `cat $(get_config pid_file)` + eend $? +} diff --git a/net-analyzer/nrpe/files/nrpe.xinetd b/net-analyzer/nrpe/files/nrpe.xinetd new file mode 100644 index 000000000000..52632880127c --- /dev/null +++ b/net-analyzer/nrpe/files/nrpe.xinetd @@ -0,0 +1,11 @@ +service nrpe { + socket_type = stream + protocol = tcp + wait = no + user = nagios + group = nagios + server = /usr/bin/nrpe + server_args = -c /etc/nagios/nrpe.cfg --inetd +# only_from = 127.0.0.1 + disabled = yes +} diff --git a/net-analyzer/nrpe/files/nrpe.xinetd.2 b/net-analyzer/nrpe/files/nrpe.xinetd.2 new file mode 100644 index 000000000000..d9f226eb2f96 --- /dev/null +++ b/net-analyzer/nrpe/files/nrpe.xinetd.2 @@ -0,0 +1,5 @@ +/nrpe + server_args = -c /etc/nagios/nrpe.cfg --inetd +# only_from = 127.0.0.1 + disabled = yes +} |