View | Details | Raw Unified | Return to bug 81139
Collapse All | Expand All

(-)nrpe2.mod/Makefile (-3 / +7 lines)
Lines 7-13 Link Here
7
7
8
PORTNAME=		nrpe2
8
PORTNAME=		nrpe2
9
PORTVERSION=		2.0
9
PORTVERSION=		2.0
10
PORTREVISION=		0
10
PORTREVISION=		1
11
CATEGORIES=		net-mgmt
11
CATEGORIES=		net-mgmt
12
MASTER_SITES=		${MASTER_SITE_SOURCEFORGE}
12
MASTER_SITES=		${MASTER_SITE_SOURCEFORGE}
13
MASTER_SITE_SUBDIR=	nagios
13
MASTER_SITE_SUBDIR=	nagios
Lines 20-31 Link Here
20
20
21
GNU_CONFIGURE=		yes
21
GNU_CONFIGURE=		yes
22
USE_PERL5_BUILD=	yes
22
USE_PERL5_BUILD=	yes
23
USE_REINPLACE=		yes
24
25
USE_RC_SUBR=    	nrpe2.sh
26
SUB_FILES=      	nrpe2.sh
27
28
PLIST_FILES=   		sbin/nrpe2 etc/nrpe.cfg-sample libexec/nagios/check_nrpe2
23
29
24
CONFIGURE_ARGS+=	--libexecdir=${PREFIX}/libexec/nagios --bindir=${PREFIX}/sbin --sysconfdir=${PREFIX}/etc
30
CONFIGURE_ARGS+=	--libexecdir=${PREFIX}/libexec/nagios --bindir=${PREFIX}/sbin --sysconfdir=${PREFIX}/etc
25
31
26
OPTIONS=		SSL "SSL support" off \
32
OPTIONS=		SSL "SSL support" off \
27
			ARGS "Enable command arguments *POTENTIAL SECURITY RISK*" off
33
			ARGS "Enable command arguments *POTENTIAL SECURITY RISK*" off
28
29
.if defined(WITH_SSL)
34
.if defined(WITH_SSL)
30
USE_OPENSSL=	yes
35
USE_OPENSSL=	yes
31
CONFIGURE_ARGS+=	--enable-ssl
36
CONFIGURE_ARGS+=	--enable-ssl
Lines 43-48 Link Here
43
	${INSTALL_PROGRAM} ${WRKSRC}/src/nrpe ${PREFIX}/sbin/nrpe2
48
	${INSTALL_PROGRAM} ${WRKSRC}/src/nrpe ${PREFIX}/sbin/nrpe2
44
	${INSTALL_PROGRAM} ${WRKSRC}/src/check_nrpe ${PREFIX}/libexec/nagios/check_nrpe2
49
	${INSTALL_PROGRAM} ${WRKSRC}/src/check_nrpe ${PREFIX}/libexec/nagios/check_nrpe2
45
	${INSTALL_DATA} ${WRKSRC}/nrpe.cfg ${PREFIX}/etc/nrpe.cfg-sample
50
	${INSTALL_DATA} ${WRKSRC}/nrpe.cfg ${PREFIX}/etc/nrpe.cfg-sample
46
	${INSTALL_SCRIPT} ${WRKSRC}/init-script.freebsd ${PREFIX}/etc/rc.d/nrpe.sh
47
51
48
.include <bsd.port.post.mk>
52
.include <bsd.port.post.mk>
(-)nrpe2.mod/files/nrpe2.sh.in (+33 lines)
Line 0 Link Here
1
#!/bin/sh
2
#
3
# $FreeBSD$
4
#
5
6
# PROVIDE: nrpe2
7
# REQUIRE: NETWORKING
8
# KEYWORD: FreeBSD shutdown
9
10
#
11
# Add the following lines to /etc/rc.conf to enable nrpe2:
12
#
13
#nrpe2_enable="YES"
14
#
15
#
16
17
. %%RC_SUBR%%
18
19
name=nrpe2
20
rcvar=`set_rcvar`
21
22
command="%%PREFIX%%/sbin/nrpe2"
23
required_files=%%PREFIX%%/etc/nrpe.cfg
24
command_args="-c ${required_files} -d"
25
pidfile=/var/run/${name}.pid
26
27
# set defaults
28
29
nrpe2_enable=${nrpe2_enable:-"NO"}
30
nrpe2_flags=${nrpe2_flags:-""}
31
32
load_rc_config ${name}
33
run_rc_command "$1"
(-)nrpe2.mod/files/patch-pid-file (+76 lines)
Line 0 Link Here
1
--- orig/nrpe-2.0/src/Makefile.in	Tue Aug  5 07:01:53 2003
2
+++ src/Makefile.in	Tue May 17 00:25:33 2005
3
@@ -9,7 +9,7 @@
4
 SRC_COMMON=../common
5
 
6
 CC=@CC@
7
-CFLAGS=@CFLAGS@ @DEFS@
8
+CFLAGS=@CFLAGS@ @DEFS@ -DPID_DIR=\"/var/run/\" 
9
 LDFLAGS=@LDFLAGS@ @LIBS@
10
 SOCKETLIBS=@SOCKETLIBS@
11
 
12
--- orig/nrpe-2.0/src/nrpe.c	Tue Sep  9 04:52:37 2003
13
+++ src/nrpe.c	Tue May 17 00:24:29 2005
14
@@ -23,6 +23,7 @@
15
 #include "nrpe.h"
16
 #include "utils.h"
17
 
18
+
19
 #ifdef HAVE_SSL
20
 #include "dh.h"
21
 #endif
22
@@ -83,7 +84,6 @@
23
 #endif
24
 
25
 
26
-
27
 int main(int argc, char **argv){
28
 	int result=OK;
29
 	int x;
30
@@ -219,7 +219,45 @@
31
 
32
 	/* else daemonize and start listening for requests... */
33
 	else if(fork()==0){
34
-
35
+#ifdef PID_DIR
36
+		int fd;
37
+		int pid_written = 0;
38
+		char *pid_fname;
39
+		char pbuf[16];
40
+		char *bname = strrchr(argv[0], '/'); /* basename from XPG4.2 would be nice */
41
+
42
+		bname = !bname ? argv[0] : ++bname;
43
+		pid_fname = malloc(strlen(PID_DIR) + strlen(bname) + sizeof(".pid"));
44
+		strcpy(pid_fname, PID_DIR);
45
+		strcat(pid_fname, bname); strcat(pid_fname, ".pid");
46
+		if ((fd = open (pid_fname, O_RDONLY)) >= 0) {
47
+			int status = read (fd, pbuf, (sizeof pbuf) - 1);
48
+			close (fd);
49
+			if (status > 0) {
50
+				int pid;
51
+				pbuf [status] = 0;
52
+				pid = atoi (pbuf);
53
+				/* If the previous server process is not still running,
54
+				   write a new pid file immediately. */
55
+				if (pid && (pid == getpid() || kill (pid, 0) < 0)) {
56
+					unlink (pid_fname);
57
+				} else {
58
+					syslog(LOG_ERR,"There's already a nrpe server running.");
59
+					free(pid_fname);
60
+					return STATE_CRITICAL;
61
+				}
62
+			}
63
+		} 
64
+		if ((fd = open (pid_fname, O_WRONLY | O_CREAT, 0644)) >= 0) {
65
+			sprintf (pbuf, "%d\n", (int)getpid ());
66
+			write (fd, pbuf, strlen (pbuf));
67
+			close (fd);
68
+		} else {
69
+			syslog(LOG_ERR,"Can not write the pidfile(%s).", pid_fname);
70
+		}
71
+		free(pid_fname);
72
+#endif
73
+		
74
 		/* we're a daemon - set up a new process group */
75
 		setsid();
76
 
(-)nrpe2.mod/pkg-plist (-4 lines)
Lines 1-4 Link Here
1
sbin/nrpe2
2
etc/nrpe.cfg-sample
3
etc/rc.d/nrpe.sh
4
libexec/nagios/check_nrpe2

Return to bug 81139