From meno.abels@adviser.com  Mon May 16 22:48:03 2005
Return-Path: <meno.abels@adviser.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id EDBF916A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 16 May 2005 22:48:02 +0000 (GMT)
Received: from smtp.adviser.com (adviser.com [217.20.119.125])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 58FCA43D88
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 16 May 2005 22:48:02 +0000 (GMT)
	(envelope-from meno.abels@adviser.com)
Received: from p213.54.76.25.tisdip.tiscali.de ([213.54.76.25] helo=neo.abels.adviser.com)
	by smtp.adviser.com with esmtpsa (TLSv1:AES256-SHA:256)
	(Exim 4.51 (FreeBSD))
	id 1DXoNJ-0004ZV-VN; Tue, 17 May 2005 00:47:52 +0200
Received: by neo.abels.adviser.com (sSMTP sendmail emulation); Tue, 17 May 2005 00:47:46 +0200
Message-Id: <20050516224802.58FCA43D88@mx1.FreeBSD.org>
Date: Tue, 17 May 2005 00:47:46 +0200
From: Meno Abels <meno.abels@adviser.com>
Reply-To: Meno Abels <meno.abels@adviser.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Meno Abels <meno.abels@adviser.com>,
	Paul Dlug <paul@nerdlabs.com>
Subject: UPDATE port: net-mgmt/nrpe2
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         81139
>Category:       ports
>Synopsis:       UPDATE port: net-mgmt/nrpe2
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pav
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon May 16 22:50:01 GMT 2005
>Closed-Date:    Thu May 26 19:26:21 GMT 2005
>Last-Modified:  Thu May 26 19:26:21 GMT 2005
>Originator:     Meno Abels <meno.abels@adviser.com>
>Release:        FreeBSD 5.3 i386
>Organization:
Adviser COM
>Environment:
System: FreeBSD race 5.3 FreeBSD 5.3 #4: Tue Apr 19 14:18:44 CEST 2005 root@jamal.abels.adviser.com:/usr/obj/usr/src/sys/GENERIC i386


>Description:
	The nrpe2 does not write a pid file to /var/run. This does 
	not allow to run the standard rc.subr start/stop script.
	The current start/stop script has also some faults in the paths.
	So I added the writing of the pid to the source and changed
	the start/stop script to standard freebsd.
	I also deleted the following file:
		net-mgmt/nrpe2/pkg-plis
	And I added:
		net-mgmt/nrpe2/files/patch-pid-file
		net-mgmt/nrpe2/files/nrpe2.sh.in
	And I increased the PORTREVISION by one.
	So I think that a patch is more complex than a new shar. If you
	want to get a patch feel free to contact me. I also send the
	this change to Ethan Galstad (nagios@nagios.org) in the hope
	that i will accept this harmless extention.
>How-To-Repeat:
	not applied change request
>Fix:

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	net-mgmt/nrpe2
#	net-mgmt/nrpe2/Makefile
#	net-mgmt/nrpe2/files
#	net-mgmt/nrpe2/files/patch-pid-file
#	net-mgmt/nrpe2/files/nrpe2.sh.in
#	net-mgmt/nrpe2/distinfo
#	net-mgmt/nrpe2/pkg-descr
#	net-mgmt/nrpe2/pkg-install
#
echo c - net-mgmt/nrpe2
mkdir -p net-mgmt/nrpe2 > /dev/null 2>&1
echo x - net-mgmt/nrpe2/Makefile
sed 's/^X//' >net-mgmt/nrpe2/Makefile << 'END-of-net-mgmt/nrpe2/Makefile'
X# New ports collection makefile for:	nrpe
X# Date created:				1 Aug 2002
X# Whom:					Paul Dlug<paul@nerdlabs.com>
X#
X# $FreeBSD$
X#
X
XPORTNAME=		nrpe2
XPORTVERSION=		2.0
XPORTREVISION=		1
XCATEGORIES=		net-mgmt
XMASTER_SITES=		${MASTER_SITE_SOURCEFORGE}
XMASTER_SITE_SUBDIR=	nagios
XDISTNAME=		nrpe-${PORTVERSION}
X
XMAINTAINER=		paul@nerdlabs.com
XCOMMENT=		Nagios Remote Plugin Executor
X
XRUN_DEPENDS=		${LOCALBASE}/libexec/nagios/check_nagios:${PORTSDIR}/net-mgmt/nagios-plugins
X
XGNU_CONFIGURE=		yes
XUSE_PERL5_BUILD=	yes
XUSE_REINPLACE=		yes
X
XUSE_RC_SUBR=    	nrpe2.sh
XSUB_FILES=      	nrpe2.sh
X
XPLIST_FILES=   		sbin/nrpe2 etc/nrpe.cfg-sample libexec/nagios/check_nrpe2
X
XCONFIGURE_ARGS+=	--libexecdir=${PREFIX}/libexec/nagios --bindir=${PREFIX}/sbin --sysconfdir=${PREFIX}/etc
X
XOPTIONS=		SSL "SSL support" off \
X			ARGS "Enable command arguments *POTENTIAL SECURITY RISK*" off
X.if defined(WITH_SSL)
XUSE_OPENSSL=	yes
XCONFIGURE_ARGS+=	--enable-ssl
X.else
XCONFIGURE_ARGS+=	--disable-ssl
X.endif
X
X.if defined(WITH_ARGS)
XCONFIGURE_ARGS+=	--enable-command-args
X.endif
X
Xdo-install:
X	${INSTALL_PROGRAM} ${WRKSRC}/src/nrpe ${PREFIX}/sbin/nrpe2
X	${INSTALL_PROGRAM} ${WRKSRC}/src/check_nrpe ${PREFIX}/libexec/nagios/check_nrpe2
X	${INSTALL_DATA} ${WRKSRC}/nrpe.cfg ${PREFIX}/etc/nrpe.cfg-sample
X
X.include <bsd.port.mk>
END-of-net-mgmt/nrpe2/Makefile
echo c - net-mgmt/nrpe2/files
mkdir -p net-mgmt/nrpe2/files > /dev/null 2>&1
echo x - net-mgmt/nrpe2/files/patch-pid-file
sed 's/^X//' >net-mgmt/nrpe2/files/patch-pid-file << 'END-of-net-mgmt/nrpe2/files/patch-pid-file'
X--- orig/nrpe-2.0/src/Makefile.in	Tue Aug  5 07:01:53 2003
X+++ src/Makefile.in	Tue May 17 00:25:33 2005
X@@ -9,7 +9,7 @@
X SRC_COMMON=../common
X 
X CC=@CC@
X-CFLAGS=@CFLAGS@ @DEFS@
X+CFLAGS=@CFLAGS@ @DEFS@ -DPID_DIR=\"/var/run/\" 
X LDFLAGS=@LDFLAGS@ @LIBS@
X SOCKETLIBS=@SOCKETLIBS@
X 
X--- orig/nrpe-2.0/src/nrpe.c	Tue Sep  9 04:52:37 2003
X+++ src/nrpe.c	Tue May 17 00:24:29 2005
X@@ -23,6 +23,7 @@
X #include "nrpe.h"
X #include "utils.h"
X 
X+
X #ifdef HAVE_SSL
X #include "dh.h"
X #endif
X@@ -83,7 +84,6 @@
X #endif
X 
X 
X-
X int main(int argc, char **argv){
X 	int result=OK;
X 	int x;
X@@ -219,7 +219,45 @@
X 
X 	/* else daemonize and start listening for requests... */
X 	else if(fork()==0){
X-
X+#ifdef PID_DIR
X+		int fd;
X+		int pid_written = 0;
X+		char *pid_fname;
X+		char pbuf[16];
X+		char *bname = strrchr(argv[0], '/'); /* basename from XPG4.2 would be nice */
X+
X+		bname = !bname ? argv[0] : ++bname;
X+		pid_fname = malloc(strlen(PID_DIR) + strlen(bname) + sizeof(".pid"));
X+		strcpy(pid_fname, PID_DIR);
X+		strcat(pid_fname, bname); strcat(pid_fname, ".pid");
X+		if ((fd = open (pid_fname, O_RDONLY)) >= 0) {
X+			int status = read (fd, pbuf, (sizeof pbuf) - 1);
X+			close (fd);
X+			if (status > 0) {
X+				int pid;
X+				pbuf [status] = 0;
X+				pid = atoi (pbuf);
X+				/* If the previous server process is not still running,
X+				   write a new pid file immediately. */
X+				if (pid && (pid == getpid() || kill (pid, 0) < 0)) {
X+					unlink (pid_fname);
X+				} else {
X+					syslog(LOG_ERR,"There's already a nrpe server running.");
X+					free(pid_fname);
X+					return STATE_CRITICAL;
X+				}
X+			}
X+		} 
X+		if ((fd = open (pid_fname, O_WRONLY | O_CREAT, 0644)) >= 0) {
X+			sprintf (pbuf, "%d\n", (int)getpid ());
X+			write (fd, pbuf, strlen (pbuf));
X+			close (fd);
X+		} else {
X+			syslog(LOG_ERR,"Can not write the pidfile(%s).", pid_fname);
X+		}
X+		free(pid_fname);
X+#endif
X+		
X 		/* we're a daemon - set up a new process group */
X 		setsid();
X 
END-of-net-mgmt/nrpe2/files/patch-pid-file
echo x - net-mgmt/nrpe2/files/nrpe2.sh.in
sed 's/^X//' >net-mgmt/nrpe2/files/nrpe2.sh.in << 'END-of-net-mgmt/nrpe2/files/nrpe2.sh.in'
X#!/bin/sh
X#
X# $FreeBSD$
X#
X
X# PROVIDE: nrpe2
X# REQUIRE: NETWORKING
X# KEYWORD: FreeBSD shutdown
X
X#
X# Add the following lines to /etc/rc.conf to enable nrpe2:
X#
X#nrpe2_enable="YES"
X#
X#
X
X. %%RC_SUBR%%
X
Xname=nrpe2
Xrcvar=`set_rcvar`
X
Xcommand="%%PREFIX%%/sbin/nrpe2"
Xrequired_files=%%PREFIX%%/etc/nrpe.cfg
Xcommand_args="-c ${required_files} -d"
Xpidfile=/var/run/${name}.pid
X
X# set defaults
X
Xnrpe2_enable=${nrpe2_enable:-"NO"}
Xnrpe2_flags=${nrpe2_flags:-""}
X
Xload_rc_config ${name}
Xrun_rc_command "$1"
END-of-net-mgmt/nrpe2/files/nrpe2.sh.in
echo x - net-mgmt/nrpe2/distinfo
sed 's/^X//' >net-mgmt/nrpe2/distinfo << 'END-of-net-mgmt/nrpe2/distinfo'
XMD5 (nrpe-2.0.tar.gz) = 70ef9502a3b7e49fa520dbceabfa04d0
XSIZE (nrpe-2.0.tar.gz) = 52157
END-of-net-mgmt/nrpe2/distinfo
echo x - net-mgmt/nrpe2/pkg-descr
sed 's/^X//' >net-mgmt/nrpe2/pkg-descr << 'END-of-net-mgmt/nrpe2/pkg-descr'
Xnrpe is used to execute Nagios plugins on remote hosts and report the results
Xto the main Nagios server. From the Nagios homepage:
X
XAllows you to execute "local" plugins (like check_disk, check_procs, etc.) on 
Xremote hosts. The check_nrpe plugin is called from Nagios and actually makes 
Xthe plugin requests to the remote host. Requires that nrpe be running on the 
Xremote host (either as a standalone daemon or as a service under inetd). 
X
Xnrpe2 is incompatible with nrpe version 1, if you are running this version
Xsee net-mgmt/nrpe. Both ports can be installed in parallel but share the same
Xconfiguration file by default. This is easily changed in the nrpe startup
Xfile.
X
XWWW: http://www.nagios.org/
END-of-net-mgmt/nrpe2/pkg-descr
echo x - net-mgmt/nrpe2/pkg-install
sed 's/^X//' >net-mgmt/nrpe2/pkg-install << 'END-of-net-mgmt/nrpe2/pkg-install'
X#!/bin/sh
X#
X#	$FreeBSD: ports/net/nagios/pkg-install,v 1.2 2002/05/29 06:35:16 kuriyama Exp $
X#
X
XPKG_PREFIX=${PKG_PREFIX:=/usr/local}
X
Xuser=nagios
Xgroup=nagios
X
Xask() {
X    local question default answer
X
X    question=$1
X    default=$2
X    if [ -z "${PACKAGE_BUILDING}" ]; then
X        read -p "${question} [${default}]? " answer
X    fi
X    if [ x${answer} = x ]; then
X        answer=${default}
X    fi
X    echo ${answer}
X}
X
Xyesno() {
X    local dflt question answer
X
X    question=$1
X    dflt=$2
X    while :; do
X        answer=$(ask "${question}" "${dflt}")
X        case "${answer}" in
X        [Yy]*)          return 0;;
X        [Nn]*)          return 1;;
X        esac
X        echo "Please answer yes or no."
X    done
X}
X
Xif [ x"$2" = xPRE-INSTALL ]; then
X    if /usr/sbin/pw groupshow "${group}" 2>/dev/null; then
X        echo "You already have a group \"${group}\", so I will use it."
X    else
X        echo "You need a group \"${group}\"."
X        if yesno "Would you like me to create it" y; then
X            /usr/sbin/pw groupadd ${group} -h - || exit
X            echo "Done."
X        else
X            echo "Please create it, and try again."
X            exit 1
X        fi
X    fi
X
X    if /usr/sbin/pw user show "${user}" 2>/dev/null; then
X        echo "You already have a user \"${user}\", so I will use it."
X    else
X        echo "You need a user \"${user}\"."
X        if yesno "Would you like me to create it" y; then
X            /usr/sbin/pw useradd ${user} -g ${group} -h - -d ${PKG_PREFIX}/var/nagios \
X                -s /nonexistent -c "Nagios pseudo-user" || exit
X            echo "Done."
X        else
X            echo "Please create it, and try again."
X            exit 1
X        fi
X    fi
X
Xfi
END-of-net-mgmt/nrpe2/pkg-install
exit

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: pav 
State-Changed-When: Fri May 20 15:05:08 GMT 2005 
State-Changed-Why:  
Please resubmit as an unified diff between old and new port directory, like: 

diff -ruN /usr/ports/net-mgmt/nrpe2 ~/myports/nrpe2-modified 


Responsible-Changed-From-To: freebsd-ports-bugs->pav 
Responsible-Changed-By: pav 
Responsible-Changed-When: Fri May 20 15:05:08 GMT 2005 
Responsible-Changed-Why:  
Track 

http://www.freebsd.org/cgi/query-pr.cgi?pr=81139 

From: Meno Abels <meno.abels@adviser.com>
To: bug-followup@FreeBSD.org,  meno.abels@adviser.com
Cc:  
Subject: Re: ports/81139: UPDATE port: net-mgmt/nrpe2
Date: Wed, 25 May 2005 06:00:24 +0200

 Hello,
 
 here is the unified diff, but think on my deleted and added files
 which are not all mentioned in the diff.
 Hopefully my mail client will not reformat the diff.
 
 regards
 
 meno
 
 diff -ruN /usr/ports/net-mgmt/nrpe2/Makefile nrpe2.mod/Makefile
 --- /usr/ports/net-mgmt/nrpe2/Makefile    Tue Dec 14 18:12:02 2004
 +++ nrpe2.mod/Makefile    Tue May 17 00:36:08 2005
 @@ -7,7 +7,7 @@
  
  PORTNAME=        nrpe2
  PORTVERSION=        2.0
 -PORTREVISION=        0
 +PORTREVISION=        1
  CATEGORIES=        net-mgmt
  MASTER_SITES=        ${MASTER_SITE_SOURCEFORGE}
  MASTER_SITE_SUBDIR=    nagios
 @@ -20,14 +20,17 @@
  
  GNU_CONFIGURE=        yes
  USE_PERL5_BUILD=    yes
 +USE_REINPLACE=        yes
 +
 +USE_RC_SUBR=        nrpe2.sh
 +SUB_FILES=          nrpe2.sh
 +
 +PLIST_FILES=           sbin/nrpe2 etc/nrpe.cfg-sample 
 libexec/nagios/check_nrpe2
  
  CONFIGURE_ARGS+=    --libexecdir=${PREFIX}/libexec/nagios 
 --bindir=${PREFIX}/sbin --sysconfdir=${PREFIX}/etc
  
  OPTIONS=        SSL "SSL support" off \
              ARGS "Enable command arguments *POTENTIAL SECURITY RISK*" off
 -
 -.include <bsd.port.pre.mk>
 -
  .if defined(WITH_SSL)
  USE_OPENSSL=    yes
  CONFIGURE_ARGS+=    --enable-ssl
 @@ -43,6 +46,5 @@
      ${INSTALL_PROGRAM} ${WRKSRC}/src/nrpe ${PREFIX}/sbin/nrpe2
      ${INSTALL_PROGRAM} ${WRKSRC}/src/check_nrpe 
 ${PREFIX}/libexec/nagios/check_nrpe2
      ${INSTALL_DATA} ${WRKSRC}/nrpe.cfg ${PREFIX}/etc/nrpe.cfg-sample
 -    ${INSTALL_SCRIPT} ${WRKSRC}/init-script.freebsd 
 ${PREFIX}/etc/rc.d/nrpe.sh
  
 -.include <bsd.port.post.mk>
 +.include <bsd.port.mk>
 diff -ruN /usr/ports/net-mgmt/nrpe2/files/nrpe2.sh.in 
 nrpe2.mod/files/nrpe2.sh.in
 --- /usr/ports/net-mgmt/nrpe2/files/nrpe2.sh.in    Thu Jan  1 01:00:00 1970
 +++ nrpe2.mod/files/nrpe2.sh.in    Tue May 17 00:09:40 2005
 @@ -0,0 +1,33 @@
 +#!/bin/sh
 +#
 +# $FreeBSD$
 +#
 +
 +# PROVIDE: nrpe2
 +# REQUIRE: NETWORKING
 +# KEYWORD: FreeBSD shutdown
 +
 +#
 +# Add the following lines to /etc/rc.conf to enable nrpe2:
 +#
 +#nrpe2_enable="YES"
 +#
 +#
 +
 +. %%RC_SUBR%%
 +
 +name=nrpe2
 +rcvar=`set_rcvar`
 +
 +command="%%PREFIX%%/sbin/nrpe2"
 +required_files=%%PREFIX%%/etc/nrpe.cfg
 +command_args="-c ${required_files} -d"
 +pidfile=/var/run/${name}.pid
 +
 +# set defaults
 +
 +nrpe2_enable=${nrpe2_enable:-"NO"}
 +nrpe2_flags=${nrpe2_flags:-""}
 +
 +load_rc_config ${name}
 +run_rc_command "$1"
 diff -ruN /usr/ports/net-mgmt/nrpe2/files/patch-pid-file 
 nrpe2.mod/files/patch-pid-file
 --- /usr/ports/net-mgmt/nrpe2/files/patch-pid-file    Thu Jan  1 
 01:00:00 1970
 +++ nrpe2.mod/files/patch-pid-file    Tue May 17 00:34:04 2005
 @@ -0,0 +1,76 @@
 +--- orig/nrpe-2.0/src/Makefile.in    Tue Aug  5 07:01:53 2003
 ++++ src/Makefile.in    Tue May 17 00:25:33 2005
 +@@ -9,7 +9,7 @@
 + SRC_COMMON=../common
 +
 + CC=@CC@
 +-CFLAGS=@CFLAGS@ @DEFS@
 ++CFLAGS=@CFLAGS@ @DEFS@ -DPID_DIR=\"/var/run/\"
 + LDFLAGS=@LDFLAGS@ @LIBS@
 + SOCKETLIBS=@SOCKETLIBS@
 +
 +--- orig/nrpe-2.0/src/nrpe.c    Tue Sep  9 04:52:37 2003
 ++++ src/nrpe.c    Tue May 17 00:24:29 2005
 +@@ -23,6 +23,7 @@
 + #include "nrpe.h"
 + #include "utils.h"
 +
 ++
 + #ifdef HAVE_SSL
 + #include "dh.h"
 + #endif
 +@@ -83,7 +84,6 @@
 + #endif
 +
 +
 +-
 + int main(int argc, char **argv){
 +     int result=OK;
 +     int x;
 +@@ -219,7 +219,45 @@
 +
 +     /* else daemonize and start listening for requests... */
 +     else if(fork()==0){
 +-
 ++#ifdef PID_DIR
 ++        int fd;
 ++        int pid_written = 0;
 ++        char *pid_fname;
 ++        char pbuf[16];
 ++        char *bname = strrchr(argv[0], '/'); /* basename from XPG4.2 
 would be nice */
 ++
 ++        bname = !bname ? argv[0] : ++bname;
 ++        pid_fname = malloc(strlen(PID_DIR) + strlen(bname) + 
 sizeof(".pid"));
 ++        strcpy(pid_fname, PID_DIR);
 ++        strcat(pid_fname, bname); strcat(pid_fname, ".pid");
 ++        if ((fd = open (pid_fname, O_RDONLY)) >= 0) {
 ++            int status = read (fd, pbuf, (sizeof pbuf) - 1);
 ++            close (fd);
 ++            if (status > 0) {
 ++                int pid;
 ++                pbuf [status] = 0;
 ++                pid = atoi (pbuf);
 ++                /* If the previous server process is not still running,
 ++                   write a new pid file immediately. */
 ++                if (pid && (pid == getpid() || kill (pid, 0) < 0)) {
 ++                    unlink (pid_fname);
 ++                } else {
 ++                    syslog(LOG_ERR,"There's already a nrpe server 
 running.");
 ++                    free(pid_fname);
 ++                    return STATE_CRITICAL;
 ++                }
 ++            }
 ++        }
 ++        if ((fd = open (pid_fname, O_WRONLY | O_CREAT, 0644)) >= 0) {
 ++            sprintf (pbuf, "%d\n", (int)getpid ());
 ++            write (fd, pbuf, strlen (pbuf));
 ++            close (fd);
 ++        } else {
 ++            syslog(LOG_ERR,"Can not write the pidfile(%s).", pid_fname);
 ++        }
 ++        free(pid_fname);
 ++#endif
 ++       
 +         /* we're a daemon - set up a new process group */
 +         setsid();
 +
 
 

From: Pav Lucistnik <pav@FreeBSD.org>
To: meno.abels@adviser.com, bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/81139: UPDATE port: net-mgmt/nrpe2
Date: Wed, 25 May 2005 09:38:12 +0200

 Diff got corrupted by your mailer (tabs->spaces, lines got wrapped),
 perhaps you could upload the diff on webspace somewhere?
 
 Oh and you made one mistake in it, you removed
 .include <bsd.port.pre.mk> which is mandatory when using OPTIONS
 (OPTIONS definition must be above it, WITH_* WITHOUT_* variables can be
 used only below it).
 
 -- 
 Pav Lucistnik <pav@oook.cz>
               <pav@FreeBSD.org>
 
 The number you dialed is imaginary.
 Please turn your phone by 90 degrees and try again.

From: Meno Abels <meno.abels@adviser.com>
To: pav@FreeBSD.org
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/81139: UPDATE port: net-mgmt/nrpe2
Date: Wed, 25 May 2005 11:22:00 +0200

 This is a multi-part message in MIME format.
 --------------020109080801050207010906
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Hello,
 
 i fixed the makefile as you recommended. The quirk was there before a 
 started to work on.
 I attach now the diff so it will be ok-:)
 
 regards
 
 Meno
 
 >Diff got corrupted by your mailer (tabs->spaces, lines got wrapped),
 >perhaps you could upload the diff on webspace somewhere?
 >
 >Oh and you made one mistake in it, you removed
 >.include <bsd.port.pre.mk> which is mandatory when using OPTIONS
 >(OPTIONS definition must be above it, WITH_* WITHOUT_* variables can be
 >used only below it).
 >
 >  
 >
 
 
 --------------020109080801050207010906
 Content-Type: text/plain;
  name="nrpe2.patch"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="nrpe2.patch"
 
 diff -ruN nrpe2/Makefile nrpe2.mod/Makefile
 --- nrpe2/Makefile	Wed May 25 11:15:15 2005
 +++ nrpe2.mod/Makefile	Wed May 25 11:16:23 2005
 @@ -7,7 +7,7 @@
  
  PORTNAME=		nrpe2
  PORTVERSION=		2.0
 -PORTREVISION=		0
 +PORTREVISION=		1
  CATEGORIES=		net-mgmt
  MASTER_SITES=		${MASTER_SITE_SOURCEFORGE}
  MASTER_SITE_SUBDIR=	nagios
 @@ -20,12 +20,17 @@
  
  GNU_CONFIGURE=		yes
  USE_PERL5_BUILD=	yes
 +USE_REINPLACE=		yes
 +
 +USE_RC_SUBR=    	nrpe2.sh
 +SUB_FILES=      	nrpe2.sh
 +
 +PLIST_FILES=   		sbin/nrpe2 etc/nrpe.cfg-sample libexec/nagios/check_nrpe2
  
  CONFIGURE_ARGS+=	--libexecdir=${PREFIX}/libexec/nagios --bindir=${PREFIX}/sbin --sysconfdir=${PREFIX}/etc
  
  OPTIONS=		SSL "SSL support" off \
  			ARGS "Enable command arguments *POTENTIAL SECURITY RISK*" off
 -
  .if defined(WITH_SSL)
  USE_OPENSSL=	yes
  CONFIGURE_ARGS+=	--enable-ssl
 @@ -43,6 +48,5 @@
  	${INSTALL_PROGRAM} ${WRKSRC}/src/nrpe ${PREFIX}/sbin/nrpe2
  	${INSTALL_PROGRAM} ${WRKSRC}/src/check_nrpe ${PREFIX}/libexec/nagios/check_nrpe2
  	${INSTALL_DATA} ${WRKSRC}/nrpe.cfg ${PREFIX}/etc/nrpe.cfg-sample
 -	${INSTALL_SCRIPT} ${WRKSRC}/init-script.freebsd ${PREFIX}/etc/rc.d/nrpe.sh
  
  .include <bsd.port.post.mk>
 diff -ruN nrpe2/files/nrpe2.sh.in nrpe2.mod/files/nrpe2.sh.in
 --- nrpe2/files/nrpe2.sh.in	Thu Jan  1 01:00:00 1970
 +++ nrpe2.mod/files/nrpe2.sh.in	Tue May 17 00:09:40 2005
 @@ -0,0 +1,33 @@
 +#!/bin/sh
 +#
 +# $FreeBSD$
 +#
 +
 +# PROVIDE: nrpe2
 +# REQUIRE: NETWORKING
 +# KEYWORD: FreeBSD shutdown
 +
 +#
 +# Add the following lines to /etc/rc.conf to enable nrpe2:
 +#
 +#nrpe2_enable="YES"
 +#
 +#
 +
 +. %%RC_SUBR%%
 +
 +name=nrpe2
 +rcvar=`set_rcvar`
 +
 +command="%%PREFIX%%/sbin/nrpe2"
 +required_files=%%PREFIX%%/etc/nrpe.cfg
 +command_args="-c ${required_files} -d"
 +pidfile=/var/run/${name}.pid
 +
 +# set defaults
 +
 +nrpe2_enable=${nrpe2_enable:-"NO"}
 +nrpe2_flags=${nrpe2_flags:-""}
 +
 +load_rc_config ${name}
 +run_rc_command "$1"
 diff -ruN nrpe2/files/patch-pid-file nrpe2.mod/files/patch-pid-file
 --- nrpe2/files/patch-pid-file	Thu Jan  1 01:00:00 1970
 +++ nrpe2.mod/files/patch-pid-file	Tue May 17 00:34:04 2005
 @@ -0,0 +1,76 @@
 +--- orig/nrpe-2.0/src/Makefile.in	Tue Aug  5 07:01:53 2003
 ++++ src/Makefile.in	Tue May 17 00:25:33 2005
 +@@ -9,7 +9,7 @@
 + SRC_COMMON=../common
 + 
 + CC=@CC@
 +-CFLAGS=@CFLAGS@ @DEFS@
 ++CFLAGS=@CFLAGS@ @DEFS@ -DPID_DIR=\"/var/run/\" 
 + LDFLAGS=@LDFLAGS@ @LIBS@
 + SOCKETLIBS=@SOCKETLIBS@
 + 
 +--- orig/nrpe-2.0/src/nrpe.c	Tue Sep  9 04:52:37 2003
 ++++ src/nrpe.c	Tue May 17 00:24:29 2005
 +@@ -23,6 +23,7 @@
 + #include "nrpe.h"
 + #include "utils.h"
 + 
 ++
 + #ifdef HAVE_SSL
 + #include "dh.h"
 + #endif
 +@@ -83,7 +84,6 @@
 + #endif
 + 
 + 
 +-
 + int main(int argc, char **argv){
 + 	int result=OK;
 + 	int x;
 +@@ -219,7 +219,45 @@
 + 
 + 	/* else daemonize and start listening for requests... */
 + 	else if(fork()==0){
 +-
 ++#ifdef PID_DIR
 ++		int fd;
 ++		int pid_written = 0;
 ++		char *pid_fname;
 ++		char pbuf[16];
 ++		char *bname = strrchr(argv[0], '/'); /* basename from XPG4.2 would be nice */
 ++
 ++		bname = !bname ? argv[0] : ++bname;
 ++		pid_fname = malloc(strlen(PID_DIR) + strlen(bname) + sizeof(".pid"));
 ++		strcpy(pid_fname, PID_DIR);
 ++		strcat(pid_fname, bname); strcat(pid_fname, ".pid");
 ++		if ((fd = open (pid_fname, O_RDONLY)) >= 0) {
 ++			int status = read (fd, pbuf, (sizeof pbuf) - 1);
 ++			close (fd);
 ++			if (status > 0) {
 ++				int pid;
 ++				pbuf [status] = 0;
 ++				pid = atoi (pbuf);
 ++				/* If the previous server process is not still running,
 ++				   write a new pid file immediately. */
 ++				if (pid && (pid == getpid() || kill (pid, 0) < 0)) {
 ++					unlink (pid_fname);
 ++				} else {
 ++					syslog(LOG_ERR,"There's already a nrpe server running.");
 ++					free(pid_fname);
 ++					return STATE_CRITICAL;
 ++				}
 ++			}
 ++		} 
 ++		if ((fd = open (pid_fname, O_WRONLY | O_CREAT, 0644)) >= 0) {
 ++			sprintf (pbuf, "%d\n", (int)getpid ());
 ++			write (fd, pbuf, strlen (pbuf));
 ++			close (fd);
 ++		} else {
 ++			syslog(LOG_ERR,"Can not write the pidfile(%s).", pid_fname);
 ++		}
 ++		free(pid_fname);
 ++#endif
 ++		
 + 		/* we're a daemon - set up a new process group */
 + 		setsid();
 + 
 diff -ruN nrpe2/pkg-plist nrpe2.mod/pkg-plist
 --- nrpe2/pkg-plist	Sat Aug 28 19:56:17 2004
 +++ nrpe2.mod/pkg-plist	Thu Jan  1 01:00:00 1970
 @@ -1,4 +0,0 @@
 -sbin/nrpe2
 -etc/nrpe.cfg-sample
 -etc/rc.d/nrpe.sh
 -libexec/nagios/check_nrpe2
 
 --------------020109080801050207010906--

From: Pav Lucistnik <pav@FreeBSD.org>
To: Meno Abels <meno.abels@adviser.com>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/81139: UPDATE port: net-mgmt/nrpe2
Date: Wed, 25 May 2005 11:25:36 +0200

 Meno Abels p=ED=B9e v st 25. 05. 2005 v 11:22 +0200:
 
 > i fixed the makefile as you recommended. The quirk was there before a=20
 > started to work on.
 > I attach now the diff so it will be ok-:)
 
 Patch to Makefile does not apply... you're diffing it against unmodified
 Makefile as in ports now, right?
 
 --=20
 Pav Lucistnik <pav@oook.cz>
               <pav@FreeBSD.org>
 
 A spoonful of curry, garlic and mustard helps the medicine go down...
 and come straight back up again.
   -- JLE on #angband

From: Pav Lucistnik <pav@FreeBSD.org>
To: paul@nerdlabs.com, bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/81139: UPDATE port: net-mgmt/nrpe2
Date: Thu, 26 May 2005 19:29:34 +0200

 Dear maintainer of FreeBSD port net-mgmt/nrpe2, please take a look at
 the following patch, which 
 
 - adds rcng startup script
 - make nrpe write pid file in /var/run
 - replaces pkg-plist file with PLIST_FILES in Makefile
 
 Do you approve this patch?
 
 
 Index: Makefile
 ===================================================================
 RCS file: /home/pcvs/ports/net-mgmt/nrpe2/Makefile,v
 retrieving revision 1.14
 diff -a -u -r1.14 Makefile
 --- Makefile	14 Dec 2004 17:12:02 -0000	1.14
 +++ Makefile	26 May 2005 17:25:36 -0000
 @@ -7,7 +7,7 @@
  
  PORTNAME=		nrpe2
  PORTVERSION=		2.0
 -PORTREVISION=		0
 +PORTREVISION=		1
  CATEGORIES=		net-mgmt
  MASTER_SITES=		${MASTER_SITE_SOURCEFORGE}
  MASTER_SITE_SUBDIR=	nagios
 @@ -20,6 +20,11 @@
  
  GNU_CONFIGURE=		yes
  USE_PERL5_BUILD=	yes
 +USE_REINPLACE=		yes
 +
 +USE_RC_SUBR=		nrpe2.sh
 +
 +PLIST_FILES=		sbin/nrpe2 etc/nrpe.cfg-sample libexec/nagios/check_nrpe2
  
  CONFIGURE_ARGS+=	--libexecdir=${PREFIX}/libexec/nagios --bindir=${PREFIX}/sbin --sysconfdir=${PREFIX}/etc
  
 @@ -43,6 +48,5 @@
  	${INSTALL_PROGRAM} ${WRKSRC}/src/nrpe ${PREFIX}/sbin/nrpe2
  	${INSTALL_PROGRAM} ${WRKSRC}/src/check_nrpe ${PREFIX}/libexec/nagios/check_nrpe2
  	${INSTALL_DATA} ${WRKSRC}/nrpe.cfg ${PREFIX}/etc/nrpe.cfg-sample
 -	${INSTALL_SCRIPT} ${WRKSRC}/init-script.freebsd ${PREFIX}/etc/rc.d/nrpe.sh
  
  .include <bsd.port.post.mk>
 Index: pkg-plist
 ===================================================================
 RCS file: pkg-plist
 diff -N pkg-plist
 --- pkg-plist	28 Aug 2004 17:56:17 -0000	1.4
 +++ /dev/null	1 Jan 1970 00:00:00 -0000
 @@ -1,4 +0,0 @@
 -sbin/nrpe2
 -etc/nrpe.cfg-sample
 -etc/rc.d/nrpe.sh
 -libexec/nagios/check_nrpe2
 Index: files/nrpe2.sh.in
 ===================================================================
 RCS file: files/nrpe2.sh.in
 diff -N files/nrpe2.sh.in
 --- /dev/null	1 Jan 1970 00:00:00 -0000
 +++ files/nrpe2.sh.in	26 May 2005 17:25:36 -0000
 @@ -0,0 +1,33 @@
 +#!/bin/sh
 +#
 +# $FreeBSD$
 +#
 +
 +# PROVIDE: nrpe2
 +# REQUIRE: NETWORKING
 +# KEYWORD: FreeBSD shutdown
 +
 +#
 +# Add the following lines to /etc/rc.conf to enable nrpe2:
 +#
 +#nrpe2_enable="YES"
 +#
 +#
 +
 +. %%RC_SUBR%%
 +
 +name=nrpe2
 +rcvar=`set_rcvar`
 +
 +command="%%PREFIX%%/sbin/nrpe2"
 +required_files=%%PREFIX%%/etc/nrpe.cfg
 +command_args="-c ${required_files} -d"
 +pidfile=/var/run/${name}.pid
 +
 +# set defaults
 +
 +nrpe2_enable=${nrpe2_enable:-"NO"}
 +nrpe2_flags=${nrpe2_flags:-""}
 +
 +load_rc_config ${name}
 +run_rc_command "$1"
 Index: files/patch-pid-file
 ===================================================================
 RCS file: files/patch-pid-file
 diff -N files/patch-pid-file
 --- /dev/null	1 Jan 1970 00:00:00 -0000
 +++ files/patch-pid-file	26 May 2005 17:25:36 -0000
 @@ -0,0 +1,76 @@
 +--- orig/nrpe-2.0/src/Makefile.in	Tue Aug  5 07:01:53 2003
 ++++ src/Makefile.in	Tue May 17 00:25:33 2005
 +@@ -9,7 +9,7 @@
 + SRC_COMMON=../common
 + 
 + CC=@CC@
 +-CFLAGS=@CFLAGS@ @DEFS@
 ++CFLAGS=@CFLAGS@ @DEFS@ -DPID_DIR=\"/var/run/\" 
 + LDFLAGS=@LDFLAGS@ @LIBS@
 + SOCKETLIBS=@SOCKETLIBS@
 + 
 +--- orig/nrpe-2.0/src/nrpe.c	Tue Sep  9 04:52:37 2003
 ++++ src/nrpe.c	Tue May 17 00:24:29 2005
 +@@ -23,6 +23,7 @@
 + #include "nrpe.h"
 + #include "utils.h"
 + 
 ++
 + #ifdef HAVE_SSL
 + #include "dh.h"
 + #endif
 +@@ -83,7 +84,6 @@
 + #endif
 + 
 + 
 +-
 + int main(int argc, char **argv){
 + 	int result=OK;
 + 	int x;
 +@@ -219,7 +219,45 @@
 + 
 + 	/* else daemonize and start listening for requests... */
 + 	else if(fork()==0){
 +-
 ++#ifdef PID_DIR
 ++		int fd;
 ++		int pid_written = 0;
 ++		char *pid_fname;
 ++		char pbuf[16];
 ++		char *bname = strrchr(argv[0], '/'); /* basename from XPG4.2 would be nice */
 ++
 ++		bname = !bname ? argv[0] : ++bname;
 ++		pid_fname = malloc(strlen(PID_DIR) + strlen(bname) + sizeof(".pid"));
 ++		strcpy(pid_fname, PID_DIR);
 ++		strcat(pid_fname, bname); strcat(pid_fname, ".pid");
 ++		if ((fd = open (pid_fname, O_RDONLY)) >= 0) {
 ++			int status = read (fd, pbuf, (sizeof pbuf) - 1);
 ++			close (fd);
 ++			if (status > 0) {
 ++				int pid;
 ++				pbuf [status] = 0;
 ++				pid = atoi (pbuf);
 ++				/* If the previous server process is not still running,
 ++				   write a new pid file immediately. */
 ++				if (pid && (pid == getpid() || kill (pid, 0) < 0)) {
 ++					unlink (pid_fname);
 ++				} else {
 ++					syslog(LOG_ERR,"There's already a nrpe server running.");
 ++					free(pid_fname);
 ++					return STATE_CRITICAL;
 ++				}
 ++			}
 ++		} 
 ++		if ((fd = open (pid_fname, O_WRONLY | O_CREAT, 0644)) >= 0) {
 ++			sprintf (pbuf, "%d\n", (int)getpid ());
 ++			write (fd, pbuf, strlen (pbuf));
 ++			close (fd);
 ++		} else {
 ++			syslog(LOG_ERR,"Can not write the pidfile(%s).", pid_fname);
 ++		}
 ++		free(pid_fname);
 ++#endif
 ++		
 + 		/* we're a daemon - set up a new process group */
 + 		setsid();
 + 
 
 -- 
 Pav Lucistnik <pav@oook.cz>
               <pav@FreeBSD.org>
 
 Oh, no! Aaargh! It is the most unnatural, most disgusting
 creature imaginable: a two-eyed cyclops!

From: Paul Dlug <paul@nerdlabs.com>
To: pav@FreeBSD.org
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/81139: UPDATE port: net-mgmt/nrpe2
Date: Thu, 26 May 2005 15:08:57 -0400

 On May 26, 2005, at 1:29 PM, Pav Lucistnik wrote:
 
 > Dear maintainer of FreeBSD port net-mgmt/nrpe2, please take a look at
 > the following patch, which
 >
 > - adds rcng startup script
 > - make nrpe write pid file in /var/run
 > - replaces pkg-plist file with PLIST_FILES in Makefile
 >
 > Do you approve this patch?
 
 This looks good to me, thanks.
 
 
 --Paul
State-Changed-From-To: feedback->closed 
State-Changed-By: pav 
State-Changed-When: Thu May 26 19:26:13 GMT 2005 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=81139 
>Unformatted:
