summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Scherbaum <dertobi123@gentoo.org>2009-12-31 10:06:18 +0000
committerTobias Scherbaum <dertobi123@gentoo.org>2009-12-31 10:06:18 +0000
commit83c216c5643a44fda089cb9bbe1eea684f63178d (patch)
tree963535f4d744d2f7ac33dd4c08eb0f39a95ba885 /net-analyzer
parentFixed dependency, bug #298936. (diff)
downloadgentoo-2-83c216c5643a44fda089cb9bbe1eea684f63178d.tar.gz
gentoo-2-83c216c5643a44fda089cb9bbe1eea684f63178d.tar.bz2
gentoo-2-83c216c5643a44fda089cb9bbe1eea684f63178d.zip
Revbump, add support for large, multiline output (#264467). Also do respect LDFALGS when building nrpe_check_control.
(Portage version: 2.2_rc61/cvs/Linux x86_64)
Diffstat (limited to 'net-analyzer')
-rw-r--r--net-analyzer/nagios-nrpe/ChangeLog11
-rw-r--r--net-analyzer/nagios-nrpe/files/multiline.patch199
-rw-r--r--net-analyzer/nagios-nrpe/nagios-nrpe-2.12-r103.ebuild103
3 files changed, 311 insertions, 2 deletions
diff --git a/net-analyzer/nagios-nrpe/ChangeLog b/net-analyzer/nagios-nrpe/ChangeLog
index 6b190f0c32d8..a24563502b08 100644
--- a/net-analyzer/nagios-nrpe/ChangeLog
+++ b/net-analyzer/nagios-nrpe/ChangeLog
@@ -1,6 +1,13 @@
# ChangeLog for net-analyzer/nagios-nrpe
-# Copyright 2002-2009 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/net-analyzer/nagios-nrpe/ChangeLog,v 1.65 2009/03/18 22:22:03 ranger Exp $
+# Copyright 1999-2009 Gentoo Foundation; Distributed under the GPL v2
+# $Header: /var/cvsroot/gentoo-x86/net-analyzer/nagios-nrpe/ChangeLog,v 1.66 2009/12/31 10:06:18 dertobi123 Exp $
+
+*nagios-nrpe-2.12-r103 (31 Dec 2009)
+
+ 31 Dec 2009; Tobias Scherbaum <dertobi123@gentoo.org>
+ +nagios-nrpe-2.12-r103.ebuild, +files/multiline.patch:
+ Revbump, add support for large, multiline output (#264467). Also do
+ respect LDFALGS when building nrpe_check_control.
18 Mar 2009; Brent Baude <ranger@gentoo.org> nagios-nrpe-2.12-r102.ebuild:
Marking nagios-nrpe-2.12-r102 ppc stable for bug 256177
diff --git a/net-analyzer/nagios-nrpe/files/multiline.patch b/net-analyzer/nagios-nrpe/files/multiline.patch
new file mode 100644
index 000000000000..c70580704531
--- /dev/null
+++ b/net-analyzer/nagios-nrpe/files/multiline.patch
@@ -0,0 +1,199 @@
+diff -ur nrpe-2.12.original/include/common.h nrpe-2.12/include/common.h
+--- nrpe-2.12.original/include/common.h 2008-03-10 22:04:42.000000000 +0100
++++ nrpe-2.12/include/common.h 2008-08-05 00:27:10.664753368 +0200
+@@ -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 */
++#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;
+Binary files nrpe-2.12.original/src/check_nrpe and nrpe-2.12/src/check_nrpe differ
+diff -ur nrpe-2.12.original/src/check_nrpe.c nrpe-2.12/src/check_nrpe.c
+--- nrpe-2.12.original/src/check_nrpe.c 2008-03-10 22:04:43.000000000 +0100
++++ nrpe-2.12/src/check_nrpe.c 2008-08-05 00:48:00.731981872 +0200
+@@ -221,6 +221,11 @@
+ 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 @@
+ /* 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 @@
+ 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 @@
+ 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 @@
+ 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(;;){
+Binary files nrpe-2.12.original/src/nrpe and nrpe-2.12/src/nrpe differ
+diff -ur nrpe-2.12.original/src/nrpe.c nrpe-2.12/src/nrpe.c
+--- nrpe-2.12.original/src/nrpe.c 2008-08-04 16:17:25.729637000 +0200
++++ nrpe-2.12/src/nrpe.c 2008-08-05 00:52:47.690415400 +0200
+@@ -1029,6 +1029,8 @@
+ 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
+@@ -1245,6 +1247,14 @@
+ 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));
+
+@@ -1253,11 +1263,17 @@
+
+ /* 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));
+@@ -1276,6 +1292,9 @@
+ 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/nagios-nrpe/nagios-nrpe-2.12-r103.ebuild b/net-analyzer/nagios-nrpe/nagios-nrpe-2.12-r103.ebuild
new file mode 100644
index 000000000000..e341bc88318d
--- /dev/null
+++ b/net-analyzer/nagios-nrpe/nagios-nrpe-2.12-r103.ebuild
@@ -0,0 +1,103 @@
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-analyzer/nagios-nrpe/nagios-nrpe-2.12-r103.ebuild,v 1.1 2009/12/31 10:06:18 dertobi123 Exp $
+
+EAPI=2
+
+inherit eutils toolchain-funcs
+
+DESCRIPTION="Nagios $PV NRPE - Nagios Remote Plugin Executor"
+HOMEPAGE="http://www.nagios.org/"
+SRC_URI="mirror://sourceforge/nagios/nrpe-${PV}.tar.gz"
+
+RESTRICT="mirror"
+LICENSE="GPL-2"
+SLOT="0"
+
+KEYWORDS="~alpha ~amd64 ~hppa ~ppc ~ppc64 ~sparc ~x86"
+
+IUSE="ssl command-args"
+DEPEND=">=net-analyzer/nagios-plugins-1.3.0
+ ssl? ( dev-libs/openssl )"
+S="${WORKDIR}/nrpe-${PV}"
+
+pkg_setup() {
+ enewgroup nagios
+ enewuser nagios -1 /bin/bash /dev/null nagios
+}
+
+src_prepare() {
+ # Add support for large output,
+ # http://opsview-blog.opsera.com/dotorg/2008/08/enhancing-nrpe.html
+ epatch "${FILESDIR}/multiline.patch"
+}
+
+src_configure() {
+ local myconf
+
+ myconf="${myconf} $(use_enable ssl) \
+ $(use_enable command-args)"
+
+ # Generate the dh.h header file for better security (2005 Mar 20 eldad)
+ if useq ssl ; then
+ openssl dhparam -C 512 | sed -n '1,/BEGIN DH PARAMETERS/p' | grep -v "BEGIN DH PARAMETERS" > "${S}"/src/dh.h
+ fi
+
+ econf ${myconf} \
+ --host=${CHOST} \
+ --prefix=/usr \
+ --libexecdir=/usr/$(get_libdir)/nagios/plugins \
+ --localstatedir=/var/nagios \
+ --sysconfdir=/etc/nagios \
+ --with-nrpe-user=nagios \
+ --with-nrpe-grp=nagios || die "econf failed"
+}
+
+src_compile() {
+ emake all || die "make failed"
+ # Add nifty nrpe check tool
+ cd contrib
+ $(tc-getCC) ${CFLAGS} ${LDFLAGS} -o nrpe_check_control nrpe_check_control.c
+}
+
+src_install() {
+ dodoc LEGAL Changelog README SECURITY README.SSL \
+ contrib/README.nrpe_check_control
+
+ insinto /etc/nagios
+ newins "${S}"/sample-config/nrpe.cfg nrpe.cfg
+ fowners root:nagios /etc/nagios/nrpe.cfg
+ fperms 0640 /etc/nagios/nrpe.cfg
+
+ exeopts -m0750 -o nagios -g nagios
+ exeinto /usr/bin
+ doexe src/nrpe
+
+ exeopts -m0750 -o nagios -g nagios
+ exeinto /usr/$(get_libdir)/nagios/plugins
+ doexe src/check_nrpe contrib/nrpe_check_control
+
+ newinitd "${FILESDIR}"/nrpe-nagios3 nrpe
+
+ # Create pidfile in /var/run/nrpe, bug #233859
+ keepdir /var/run/nrpe
+ fowners nagios:nagios /var/run/nrpe
+ sed -i -e \
+ "s#pid_file=/var/run/nrpe.pid#pid_file=/var/run/nrpe/nrpe.pid#" \
+ "${D}"/etc/nagios/nrpe.cfg || die "sed failed"
+}
+
+pkg_postinst() {
+ einfo
+ einfo "If you are using the nrpe daemon, remember to edit"
+ einfo "the config file /etc/nagios/nrpe.cfg"
+ einfo
+
+ if useq command-args ; then
+ ewarn "You have enabled command-args for NRPE. This enables"
+ ewarn "the ability for clients to supply arguments to commands"
+ ewarn "which should be run. "
+ ewarn "THIS IS CONSIDERED A SECURITY RISK!"
+ ewarn "Please read /usr/share/doc/${PF}/SECURITY.bz2 for more info"
+ fi
+}