ソースを参照

Added support for compiling and building RPMs on AIX

Eric Stanley 14 年 前
コミット
176027a4ca
6 ファイル変更474 行追加49 行削除
  1. 6 0
      Changelog
  2. 5 1
      configure
  3. 3 0
      configure.in
  4. 131 47
      nrpe.spec
  5. 252 0
      nrpe.spec.in
  6. 77 1
      src/nrpe.c

+ 6 - 0
Changelog

@@ -3,6 +3,12 @@ NRPE Changelog
 **************
 
 
+x.xx - xx/xx/xxxx
+-----------------
+- Added SRC support on AIX (Thierry Bertaud)
+- Updated RPM SPEC file to support creating RPMs on AIX (Eric Stanley)
+- Updated logging to support compiling on AIX (Eric Stanley)
+
 2.13 - 11/11/2011
 -----------------
 - Applied Kaspersky Labs supplied patch for extending allowed_hosts (Konstantin Malov)

+ 5 - 1
configure

@@ -646,6 +646,7 @@ INSTALL
 INSTALL_DATA
 INSTALL_SCRIPT
 INSTALL_PROGRAM
+RPM_RELEASE
 PKG_REL_DATE
 PKG_HOME_URL
 PKG_VERSION
@@ -2358,7 +2359,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 ac_config_headers="$ac_config_headers include/config.h"
 
-ac_config_files="$ac_config_files Makefile subst src/Makefile package/solaris/Makefile init-script init-script.debian init-script.suse sample-config/nrpe.cfg sample-config/nrpe.xinetd"
+ac_config_files="$ac_config_files Makefile subst src/Makefile package/solaris/Makefile init-script init-script.debian init-script.suse nrpe.spec sample-config/nrpe.cfg sample-config/nrpe.xinetd"
 
 
 
@@ -2366,6 +2367,8 @@ PKG_NAME=nrpe
 PKG_VERSION="2.13"
 PKG_HOME_URL="http://www.nagios.org/"
 PKG_REL_DATE="11-11-2011"
+RPM_RELEASE=1
+
 
 
 
@@ -5714,6 +5717,7 @@ do
     "init-script") CONFIG_FILES="$CONFIG_FILES init-script" ;;
     "init-script.debian") CONFIG_FILES="$CONFIG_FILES init-script.debian" ;;
     "init-script.suse") CONFIG_FILES="$CONFIG_FILES init-script.suse" ;;
+    "nrpe.spec") CONFIG_FILES="$CONFIG_FILES nrpe.spec" ;;
     "sample-config/nrpe.cfg") CONFIG_FILES="$CONFIG_FILES sample-config/nrpe.cfg" ;;
     "sample-config/nrpe.xinetd") CONFIG_FILES="$CONFIG_FILES sample-config/nrpe.xinetd" ;;
 

+ 3 - 0
configure.in

@@ -14,6 +14,7 @@ AC_CONFIG_FILES([Makefile
 	init-script
 	init-script.debian
 	init-script.suse
+	nrpe.spec
 	sample-config/nrpe.cfg
 	sample-config/nrpe.xinetd])
 AC_PREFIX_DEFAULT(/usr/local/nagios)
@@ -22,10 +23,12 @@ PKG_NAME=nrpe
 PKG_VERSION="2.13"
 PKG_HOME_URL="http://www.nagios.org/"
 PKG_REL_DATE="11-11-2011"
+RPM_RELEASE=1
 AC_SUBST(PKG_NAME)
 AC_SUBST(PKG_VERSION)
 AC_SUBST(PKG_HOME_URL)
 AC_SUBST(PKG_REL_DATE)
+AC_SUBST(RPM_RELEASE)
 
 dnl Figure out how to invoke "install" and what install options to use.
 AC_PROG_INSTALL

+ 131 - 47
nrpe.spec

@@ -1,3 +1,25 @@
+%define isaix %(test "`uname -s`" = "AIX" && echo "1" || echo "0")
+%define islinux %(test "`uname -s`" = "Linux" && echo "1" || echo "0")
+
+%if %{isaix}
+	%define _prefix	/opt/nagios
+	%define _docdir %{_prefix}/doc/nrpe-2.13
+	%define nshome /opt/nagios
+	%define _make gmake
+%endif
+%if %{islinux}
+	%define _init_dir /etc/init.d
+	%define _exec_prefix %{_prefix}/sbin
+	%define _bindir %{_prefix}/sbin
+	%define _sbindir %{_prefix}/lib/nagios/cgi
+	%define _libexecdir %{_prefix}/lib/nagios/plugins
+	%define _datadir %{_prefix}/share/nagios
+	%define _localstatedir /var/log/nagios
+	%define nshome /var/log/nagios
+	%define _make make
+%endif
+%define _sysconfdir /etc/nagios
+
 %define name nrpe
 %define version 2.13
 %define release 1
@@ -24,17 +46,21 @@ BuildRoot: %{_tmppath}/%{name}-buildroot
 Prefix: %{_prefix}
 Prefix: /etc/init.d
 Prefix: /etc/nagios
-Requires: bash, grep, nagios-plugins
-PreReq: /usr/bin/logger, chkconfig, sh-utils, shadow-utils, sed, initscripts, fileutils, mktemp
+%if %{isaix}
+Requires: nagios-plugins
+%endif
+%if %{islinux}
+Requires: bash, grep, nagios-plugins, util-linux, chkconfig, shadow-utils, sed, initscripts, mktemp
+%endif
 
 %description
-Nrpe is a system daemon that will execute various Nagios plugins
-locally on behalf of a remote (monitoring) host that uses the
-check_nrpe plugin.  Various plugins that can be executed by the 
-daemon are available at:
-http://sourceforge.net/projects/nagiosplug
+NPRE (Nagios Remote Plugin Executor) is a system daemon that 
+will execute various Nagios plugins locally on behalf of a 
+remote (monitoring) host that uses the check_nrpe plugin.  
+Various plugins that can be executed by the daemon are available 
+at: http://sourceforge.net/projects/nagiosplug
 
-This package provides the core agent.
+This package provides the client-side NRPE agent (daemon).
 
 %package plugin
 Group: Application/System
@@ -42,13 +68,14 @@ Summary: Provides nrpe plugin for Nagios.
 Requires: nagios-plugins
 
 %description plugin
-Nrpe is a system daemon that will execute various Nagios plugins
-locally on behalf of a remote (monitoring) host that uses the
-check_nrpe plugin.  Various plugins that can be executed by the 
-daemon are available at:
-http://sourceforge.net/projects/nagiosplug
+NPRE (Nagios Remote Plugin Executor) is a system daemon that 
+will execute various Nagios plugins locally on behalf of a 
+remote (monitoring) host that uses the check_nrpe plugin.  
+Various plugins that can be executed by the daemon are available 
+at: http://sourceforge.net/projects/nagiosplug
 
-This package provides the nrpe plugin for Nagios-related applications.
+This package provides the server-side NRPE plugin for 
+Nagios-related applications.
 
 %prep
 %setup -q
@@ -56,20 +83,47 @@ This package provides the nrpe plugin for Nagios-related applications.
 
 %pre
 # Create `nagios' group on the system if necessary
-if grep ^nagios: /etc/group; then
-	: # group already exists
-else
-	/usr/sbin/groupadd %{nsgrp} || %nnmmsg Unexpected error adding group "%{nsgrp}". Aborting install process.
+%if %{isaix}
+lsgroup %{nsgrp} > /dev/null 2> /dev/null
+if [ $? -eq 2 ] ; then
+	mkgroup %{nsgrp} || %nnmmsg Unexpected error adding group "%{nsgrp}". Aborting install process.
+fi
+%endif
+%if %{islinux}
+getent group %{nsgrp} > /dev/null 2> /dev/null
+if [ $? -ne 0 ] ; then
+	groupadd %{nsgrp} || %nnmmsg Unexpected error adding group "%{nsgrp}". Aborting install process.
 fi
+%endif
 
 # Create `nagios' user on the system if necessary
-if id %{nsusr} ; then
-	: # user already exists
-else
-	/usr/sbin/useradd -r -d /var/log/nagios -s /bin/sh -c "%{nsusr}" -g %{nsgrp} %{nsusr} || \
+%if %{isaix}
+lsuser %{nsusr} > /dev/null 2> /dev/null
+if [ $? -eq 2 ] ; then
+	useradd -d %{nshome} -c "%{nsusr}" -g %{nsgrp} %{nsusr} || \
 		%nnmmsg Unexpected error adding user "%{nsusr}". Aborting install process.
 fi
+%endif
+%if %{islinux}
+getent passwd %{nsusr} > /dev/null 2> /dev/null
+if [ $? -ne 0 ] ; then
+	useradd -r -d %{nshome} -c "%{nsusr}" -g %{nsgrp} %{nsusr} || \
+		%nnmmsg Unexpected error adding user "%{nsusr}". Aborting install process.
+fi
+%endif
+
+%if %{isaix}
+# Check to see if the nrpe service is running and, if so, stop it.
+/usr/bin/lssrc -s nrpe > /dev/null 2> /dev/null
+if [ $? -eq 0 ] ; then
+	status=`/usr/bin/lssrc -s nrpe | /usr/bin/gawk '$1=="nrpe" {print $NF}'`
+	if [ "$status" = "active" ] ; then
+		/usr/bin/stopsrc -s nrpe
+	fi
+fi
+%endif
 
+%if %{islinux}
 # if LSB standard /etc/init.d does not exist,
 # create it as a symlink to the first match we find
 if [ -d /etc/init.d -o -L /etc/init.d ]; then
@@ -81,73 +135,103 @@ elif [ -d /usr/local/etc/rc.d ]; then
 elif [ -d /sbin/init.d ]; then
   ln -s /sbin/init.d /etc/init.d
 fi
+%endif
 
+%if %{isaix}
+%post
+/usr/bin/lssrc -s nrpe > /dev/null 2> /dev/null
+if [ $? -eq 1 ] ; then
+	/usr/bin/mkssys -p %{_bindir}/nrpe -s nrpe -u 0 -a "-c %{_sysconfdir}/nrpe.cfg -d -s" -Q -R -S -n 15 -f 9
+fi
+/usr/bin/startsrc -s nrpe
+%endif
 
 %preun
+%if %{isaix}
+status=`/usr/bin/lssrc -s nrpe | /usr/bin/gawk '$1=="nrpe" {print $NF}'`
+if [ "$status" = "active" ] ; then
+	/usr/bin/stopsrc -s nrpe
+fi
+/usr/bin/rmssys -s nrpe
+%endif
+%if %{islinux}
 if [ "$1" = 0 ]; then
 	/sbin/service nrpe stop > /dev/null 2>&1
 	/sbin/chkconfig --del nrpe
 fi
+%endif
 
+%if %{islinux}
 %postun
 if [ "$1" -ge "1" ]; then
 	/sbin/service nrpe condrestart >/dev/null 2>&1 || :
 fi
+%endif
 
 %build
 export PATH=$PATH:/usr/sbin
 CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" \
-./configure \
+MAKE=%{_make} ./configure \
 	--with-init-dir=/etc/init.d \
 	--with-nrpe-port=%{nsport} \
 	--with-nrpe-user=%{nsusr} \
 	--with-nrpe-group=%{nsgrp} \
 	--prefix=%{_prefix} \
-	--exec-prefix=%{_prefix}/sbin \
-	--bindir=%{_prefix}/sbin \
-	--sbindir=%{_prefix}/lib/nagios/cgi \
-	--libexecdir=%{_prefix}/lib/nagios/plugins \
-	--datadir=%{_prefix}/share/nagios \
-	--sysconfdir=/etc/nagios \
-	--localstatedir=/var/log/nagios \
+	--exec-prefix=%{_exec_prefix} \
+	--bindir=%{_bindir} \
+	--sbindir=%{_sbindir} \
+	--libexecdir=%{_libexecdir} \
+	--datadir=%{_datadir} \
+	--sysconfdir=%{_sysconfdir} \
+	--localstatedir=%{_localstatedir} \
 	--enable-command-args
-
-make all
+%{_make} all
 
 %install
 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
-install -d -m 0755 ${RPM_BUILD_ROOT}/etc/init.d
-install -d -m 0755 ${RPM_BUILD_ROOT}/etc/nagios
-install -d -m 0755 ${RPM_BUILD_ROOT}/usr/sbin
-install -d -m 0755 ${RPM_BUILD_ROOT}/usr/lib/nagios/plugins
+%if %{islinux}
+install -d -m 0755 ${RPM_BUILD_ROOT}%{_init_dir}
+%endif
+DESTDIR=${RPM_BUILD_ROOT} %{_make} install install-daemon-config
+#install -d -m 0755 ${RPM_BUILD_ROOT}%{_sysconfdir}
+#install -d -m 0755 ${RPM_BUILD_ROOT}%{_bindir}
+#install -d -m 0755 ${RPM_BUILD_ROOT}%{_libexecdir}
 
 # install templated configuration files
-cp sample-config/nrpe.cfg ${RPM_BUILD_ROOT}/etc/nagios/nrpe.cfg
-cp init-script ${RPM_BUILD_ROOT}/etc/init.d/nrpe
-cp src/nrpe ${RPM_BUILD_ROOT}/usr/sbin
-cp src/check_nrpe ${RPM_BUILD_ROOT}/usr/lib/nagios/plugins
+#cp sample-config/nrpe.cfg ${RPM_BUILD_ROOT}%{_sysconfdir}/nrpe.cfg
+#%if %{isaix}
+#cp init-script ${RPM_BUILD_ROOT}%{_init_dir}/nrpe
+#%endif
+#cp src/nrpe ${RPM_BUILD_ROOT}%{_bindir}
+#cp src/check_nrpe ${RPM_BUILD_ROOT}%{_libexecdir}
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
 
 %files
+%if %{islinux}
 %defattr(755,root,root)
 /etc/init.d/nrpe
-%{_prefix}/sbin/nrpe
-%dir /etc/nagios
-%defattr(644,root,root)
-%config(noreplace) /etc/nagios/*.cfg
+%endif
+%{_bindir}/nrpe
+%dir %{_sysconfdir}
+%defattr(600,%{nsusr},%{nsgrp})
+%config(noreplace) %{_sysconfdir}/*.cfg
 %defattr(755,%{nsusr},%{nsgrp})
 %doc Changelog LEGAL README 
 
 %files plugin
-%defattr(755,root,root)
-%{_prefix}/lib/nagios/plugins
 %defattr(755,%{nsusr},%{nsgrp})
-%doc Changelog LEGAL README
+%{_libexecdir}
+%defattr(644,%{nsusr},%{nsgrp})
+%doc Changelog LEGAL README 
 
 %changelog
+* Mon Mar 12 2012 Eric Stanley estanley<@>nagios.com
+- Created autoconf input file 
+- Updated to support building on AIX
+- Updated install to use make install*
 * Mon Jan 23 2006 Andreas Kasenides ank<@>cs.ucy.ac.cy
 - fixed nrpe.cfg relocation to sample-config
 - replaced Copyright label with License

+ 252 - 0
nrpe.spec.in

@@ -0,0 +1,252 @@
+%define isaix %(test "`uname -s`" = "AIX" && echo "1" || echo "0")
+%define islinux %(test "`uname -s`" = "Linux" && echo "1" || echo "0")
+
+%if %{isaix}
+	%define _prefix	/opt/nagios
+	%define _docdir %{_prefix}/doc/@PACKAGE_NAME@-@PACKAGE_VERSION@
+	%define nshome /opt/nagios
+	%define _make gmake
+%endif
+%if %{islinux}
+	%define _init_dir /etc/init.d
+	%define _exec_prefix %{_prefix}/sbin
+	%define _bindir %{_prefix}/sbin
+	%define _sbindir %{_prefix}/lib/nagios/cgi
+	%define _libexecdir %{_prefix}/lib/nagios/plugins
+	%define _datadir %{_prefix}/share/nagios
+	%define _localstatedir /var/log/nagios
+	%define nshome /var/log/nagios
+	%define _make make
+%endif
+%define _sysconfdir /etc/nagios
+
+%define name @PACKAGE_NAME@
+%define version @PACKAGE_VERSION@
+%define release @RPM_RELEASE@
+%define nsusr @nrpe_user@
+%define nsgrp @nrpe_group@
+%define nsport @nrpe_port@
+
+# Reserve option to override port setting with:
+# rpm -ba|--rebuild --define 'nsport 5666'
+%{?port:%define nsport %{port}}
+
+# Macro that print mesages to syslog at package (un)install time
+%define nnmmsg logger -t %{name}/rpm
+
+Summary: Host/service/network monitoring agent for Nagios
+URL: http://www.nagios.org
+Name: %{name}
+Version: %{version}
+Release: %{release}
+License: GPL
+Group: Application/System
+Source0: %{name}-%{version}.tar.gz
+BuildRoot: %{_tmppath}/%{name}-buildroot
+Prefix: %{_prefix}
+Prefix: /etc/init.d
+Prefix: /etc/nagios
+%if %{isaix}
+Requires: nagios-plugins
+%endif
+%if %{islinux}
+Requires: bash, grep, nagios-plugins, util-linux, chkconfig, shadow-utils, sed, initscripts, mktemp
+%endif
+
+%description
+NPRE (Nagios Remote Plugin Executor) is a system daemon that 
+will execute various Nagios plugins locally on behalf of a 
+remote (monitoring) host that uses the check_nrpe plugin.  
+Various plugins that can be executed by the daemon are available 
+at: http://sourceforge.net/projects/nagiosplug
+
+This package provides the client-side NRPE agent (daemon).
+
+%package plugin
+Group: Application/System
+Summary: Provides nrpe plugin for Nagios.
+Requires: nagios-plugins
+
+%description plugin
+NPRE (Nagios Remote Plugin Executor) is a system daemon that 
+will execute various Nagios plugins locally on behalf of a 
+remote (monitoring) host that uses the check_nrpe plugin.  
+Various plugins that can be executed by the daemon are available 
+at: http://sourceforge.net/projects/nagiosplug
+
+This package provides the server-side NRPE plugin for 
+Nagios-related applications.
+
+%prep
+%setup -q
+
+
+%pre
+# Create `nagios' group on the system if necessary
+%if %{isaix}
+lsgroup %{nsgrp} > /dev/null 2> /dev/null
+if [ $? -eq 2 ] ; then
+	mkgroup %{nsgrp} || %nnmmsg Unexpected error adding group "%{nsgrp}". Aborting install process.
+fi
+%endif
+%if %{islinux}
+getent group %{nsgrp} > /dev/null 2> /dev/null
+if [ $? -ne 0 ] ; then
+	groupadd %{nsgrp} || %nnmmsg Unexpected error adding group "%{nsgrp}". Aborting install process.
+fi
+%endif
+
+# Create `nagios' user on the system if necessary
+%if %{isaix}
+lsuser %{nsusr} > /dev/null 2> /dev/null
+if [ $? -eq 2 ] ; then
+	useradd -d %{nshome} -c "%{nsusr}" -g %{nsgrp} %{nsusr} || \
+		%nnmmsg Unexpected error adding user "%{nsusr}". Aborting install process.
+fi
+%endif
+%if %{islinux}
+getent passwd %{nsusr} > /dev/null 2> /dev/null
+if [ $? -ne 0 ] ; then
+	useradd -r -d %{nshome} -c "%{nsusr}" -g %{nsgrp} %{nsusr} || \
+		%nnmmsg Unexpected error adding user "%{nsusr}". Aborting install process.
+fi
+%endif
+
+%if %{isaix}
+# Check to see if the nrpe service is running and, if so, stop it.
+/usr/bin/lssrc -s nrpe > /dev/null 2> /dev/null
+if [ $? -eq 0 ] ; then
+	status=`/usr/bin/lssrc -s nrpe | /usr/bin/gawk '$1=="nrpe" {print $NF}'`
+	if [ "$status" = "active" ] ; then
+		/usr/bin/stopsrc -s nrpe
+	fi
+fi
+%endif
+
+%if %{islinux}
+# if LSB standard /etc/init.d does not exist,
+# create it as a symlink to the first match we find
+if [ -d /etc/init.d -o -L /etc/init.d ]; then
+  : # we're done
+elif [ -d /etc/rc.d/init.d ]; then
+  ln -s /etc/rc.d/init.d /etc/init.d
+elif [ -d /usr/local/etc/rc.d ]; then
+  ln -s  /usr/local/etc/rc.d /etc/init.d
+elif [ -d /sbin/init.d ]; then
+  ln -s /sbin/init.d /etc/init.d
+fi
+%endif
+
+%if %{isaix}
+%post
+/usr/bin/lssrc -s nrpe > /dev/null 2> /dev/null
+if [ $? -eq 1 ] ; then
+	/usr/bin/mkssys -p %{_bindir}/nrpe -s nrpe -u 0 -a "-c %{_sysconfdir}/nrpe.cfg -d -s" -Q -R -S -n 15 -f 9
+fi
+/usr/bin/startsrc -s nrpe
+%endif
+
+%preun
+%if %{isaix}
+status=`/usr/bin/lssrc -s nrpe | /usr/bin/gawk '$1=="nrpe" {print $NF}'`
+if [ "$status" = "active" ] ; then
+	/usr/bin/stopsrc -s nrpe
+fi
+/usr/bin/rmssys -s nrpe
+%endif
+%if %{islinux}
+if [ "$1" = 0 ]; then
+	/sbin/service nrpe stop > /dev/null 2>&1
+	/sbin/chkconfig --del nrpe
+fi
+%endif
+
+%if %{islinux}
+%postun
+if [ "$1" -ge "1" ]; then
+	/sbin/service nrpe condrestart >/dev/null 2>&1 || :
+fi
+%endif
+
+%build
+export PATH=$PATH:/usr/sbin
+CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" \
+MAKE=%{_make} ./configure \
+	--with-init-dir=/etc/init.d \
+	--with-nrpe-port=%{nsport} \
+	--with-nrpe-user=%{nsusr} \
+	--with-nrpe-group=%{nsgrp} \
+	--prefix=%{_prefix} \
+	--exec-prefix=%{_exec_prefix} \
+	--bindir=%{_bindir} \
+	--sbindir=%{_sbindir} \
+	--libexecdir=%{_libexecdir} \
+	--datadir=%{_datadir} \
+	--sysconfdir=%{_sysconfdir} \
+	--localstatedir=%{_localstatedir} \
+	--enable-command-args
+%{_make} all
+
+%install
+[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
+%if %{islinux}
+install -d -m 0755 ${RPM_BUILD_ROOT}%{_init_dir}
+%endif
+DESTDIR=${RPM_BUILD_ROOT} %{_make} install install-daemon-config
+#install -d -m 0755 ${RPM_BUILD_ROOT}%{_sysconfdir}
+#install -d -m 0755 ${RPM_BUILD_ROOT}%{_bindir}
+#install -d -m 0755 ${RPM_BUILD_ROOT}%{_libexecdir}
+
+# install templated configuration files
+#cp sample-config/nrpe.cfg ${RPM_BUILD_ROOT}%{_sysconfdir}/nrpe.cfg
+#%if %{isaix}
+#cp init-script ${RPM_BUILD_ROOT}%{_init_dir}/nrpe
+#%endif
+#cp src/nrpe ${RPM_BUILD_ROOT}%{_bindir}
+#cp src/check_nrpe ${RPM_BUILD_ROOT}%{_libexecdir}
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+
+%files
+%if %{islinux}
+%defattr(755,root,root)
+/etc/init.d/nrpe
+%endif
+%{_bindir}/nrpe
+%dir %{_sysconfdir}
+%defattr(600,%{nsusr},%{nsgrp})
+%config(noreplace) %{_sysconfdir}/*.cfg
+%defattr(755,%{nsusr},%{nsgrp})
+%doc Changelog LEGAL README 
+
+%files plugin
+%defattr(755,%{nsusr},%{nsgrp})
+%{_libexecdir}
+%defattr(644,%{nsusr},%{nsgrp})
+%doc Changelog LEGAL README 
+
+%changelog
+* Mon Mar 12 2012 Eric Stanley estanley<@>nagios.com
+- Created autoconf input file 
+- Updated to support building on AIX
+- Updated install to use make install*
+* Mon Jan 23 2006 Andreas Kasenides ank<@>cs.ucy.ac.cy
+- fixed nrpe.cfg relocation to sample-config
+- replaced Copyright label with License
+- added --enable-command-args to enable remote arg passing (if desired can be disabled by commenting out)
+
+* Wed Nov 12 2003 Ingimar Robertsson <iar@skyrr.is>
+- Added adding of nagios group if it does not exist.
+
+* Tue Jan 07 2003 James 'Showkilr' Peterson <showkilr@showkilr.com>
+- Removed the lines which removed the nagios user and group from the system
+- changed the patch release version from 3 to 1
+
+* Mon Jan 06 2003 James 'Showkilr' Peterson <showkilr@showkilr.com>
+- Removed patch files required for nrpe 1.5
+- Update spec file for version 1.6 (1.6-1)
+
+* Sat Dec 28 2002 James 'Showkilr' Peterson <showkilr@showkilr.com>
+- First RPM build (1.5-1)

+ 77 - 1
src/nrpe.c

@@ -85,6 +85,7 @@ int     show_license=FALSE;
 int     show_version=FALSE;
 int     use_inetd=TRUE;
 int     debug=FALSE;
+int     use_src=FALSE; /* Define parameter for SRC option */
 
 
 
@@ -153,6 +154,8 @@ int main(int argc, char **argv){
 		printf(" <mode>        = One of the following two operating modes:\n");  
 		printf("   -i          =    Run as a service under inetd or xinetd\n");
 		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("\n");
 		printf("Notes:\n");
 		printf("This program is designed to process requests from the check_nrpe\n");
@@ -274,6 +277,74 @@ int main(int argc, char **argv){
 		handle_connection(0);
 	        }
 
+	/* if we're running under SRC... 
+	   we don't fork but does drop-privileges*/
+	else if (use_src==TRUE){
+
+		/* close standard file descriptors */
+		close(0);
+		close(1);
+		close(2);
+
+		/* redirect standard descriptors to /dev/null */
+		open("/dev/null",O_RDONLY);
+		open("/dev/null",O_WRONLY);
+		open("/dev/null",O_WRONLY);
+
+		chdir("/");
+		/*umask(0);*/
+
+		/* handle signals */
+		signal(SIGQUIT,sighandler);
+		signal(SIGTERM,sighandler);
+		signal(SIGHUP,sighandler);
+
+		/* log info to syslog facility */
+		syslog(LOG_NOTICE,"Starting up daemon");
+
+		/* write pid file */
+		if(write_pid_file()==ERROR)
+			return STATE_CRITICAL;
+
+		/* drop privileges */
+		drop_privileges(nrpe_user,nrpe_group);
+
+		/* make sure we're not root */
+		check_privileges();
+
+		do{
+
+			/* reset flags */
+			sigrestart=FALSE;
+			sigshutdown=FALSE;
+
+			/* wait for connections */
+			wait_for_connections();
+
+			/* free all memory we allocated */
+			free_memory();
+			
+			if(sigrestart==TRUE){
+
+				/* read the config file */
+				result=read_config_file(config_file);	
+
+				/* exit if there are errors... */
+				if(result==ERROR){
+					syslog(LOG_ERR,"Config file '%s' contained errors, bailing out...",config_file);
+					return STATE_CRITICAL;
+				        }
+			        }
+
+		        }while(sigrestart==TRUE && sigshutdown==FALSE);
+
+		/* remove pid file */
+		remove_pid_file();
+
+		syslog(LOG_NOTICE,"Daemon shutdown\n");
+	        }            
+
+
 	/* else daemonize and start listening for requests... */
 	else if(fork()==0){
 		
@@ -1846,6 +1917,8 @@ int process_arguments(int argc, char **argv){
 	static struct option long_options[]={
 		{"config", required_argument, 0, 'c'},
 		{"inetd", no_argument, 0, 'i'},
+		/* To compatibility between short and long options but not used on AIX */
+		{"src", no_argument, 0, 's'},
 		{"daemon", no_argument, 0, 'd'},
 		{"no-ssl", no_argument, 0, 'n'},
 		{"help", no_argument, 0, 'h'},
@@ -1858,7 +1931,7 @@ int process_arguments(int argc, char **argv){
 	if(argc<2)
 		return ERROR;
 
-	snprintf(optchars,MAX_INPUT_BUFFER,"c:hVldin");
+	snprintf(optchars,MAX_INPUT_BUFFER,"c:hVldins");
 
 	while(1){
 #ifdef HAVE_GETOPT_LONG
@@ -1897,6 +1970,9 @@ int process_arguments(int argc, char **argv){
 		case 'n':
 			use_ssl=FALSE;
 			break;
+		case 's':   /* Argument s to indicate SRC option*/
+			use_src=TRUE;
+			break;
 		default:
 			return ERROR;
 			break;