Просмотр исходного кода

Merge pull request #295 from dougnazar/aix

Fix compilation on AIX & Solaris

Fixes:

    Detect if linker supports rpath option.
    Only use rpath if it is required (missing library or version mismatch).
    Add Makefile recipe for snprintf.o as AIX libc doesn't have asprintf.
    Prioritize local headers over additional system includes.
    Prioritize include directories without prefix.
    Check if default system paths are enough for compile.

Cleanups:

    AIX uses the const version of the structures.
    Notate the intentional fallthoughs in the sprintf code.
    Modernize autoconf
Emmett Kapsner 2 недель назад
Родитель
Сommit
f946a2100d

+ 191 - 7
aclocal.m4

@@ -1,7 +1,191 @@
-m4_include([macros/ax_nagios_get_os])
-m4_include([macros/ax_nagios_get_distrib])
-m4_include([macros/ax_nagios_get_init])
-m4_include([macros/ax_nagios_get_inetd])
-m4_include([macros/ax_nagios_get_paths])
-m4_include([macros/ax_nagios_get_files])
-m4_include([macros/ax_nagios_get_ssl])
+# generated automatically by aclocal 1.17 -*- Autoconf -*-
+
+# Copyright (C) 1996-2024 Free Software Foundation, Inc.
+
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
+# ===========================================================================
+#    https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
+#
+# DESCRIPTION
+#
+#   Check whether the given FLAG works with the linker or gives an error.
+#   (Warnings, however, are ignored)
+#
+#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
+#   success/failure.
+#
+#   If EXTRA-FLAGS is defined, it is added to the linker's default flags
+#   when the check is done.  The check is thus made with the flags: "LDFLAGS
+#   EXTRA-FLAGS FLAG".  This can for example be used to force the linker to
+#   issue an error when a bad flag is given.
+#
+#   INPUT gives an alternative input source to AC_LINK_IFELSE.
+#
+#   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
+#   macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+#   Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved.  This file is offered as-is, without any
+#   warranty.
+
+#serial 6
+
+AC_DEFUN([AX_CHECK_LINK_FLAG],
+[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
+AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
+  ax_check_save_flags=$LDFLAGS
+  LDFLAGS="$LDFLAGS $4 $1"
+  AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
+    [AS_VAR_SET(CACHEVAR,[yes])],
+    [AS_VAR_SET(CACHEVAR,[no])])
+  LDFLAGS=$ax_check_save_flags])
+AS_VAR_IF(CACHEVAR,yes,
+  [m4_default([$2], :)],
+  [m4_default([$3], :)])
+AS_VAR_POPDEF([CACHEVAR])dnl
+])dnl AX_CHECK_LINK_FLAGS
+
+# ===========================================================================
+#    https://www.gnu.org/software/autoconf-archive/ax_normalize_path.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_NORMALIZE_PATH(VARNAME, [REFERENCE_STRING])
+#
+# DESCRIPTION
+#
+#   Perform some cleanups on the value of $VARNAME (interpreted as a path):
+#
+#     - empty paths are changed to '.'
+#     - trailing slashes are removed
+#     - repeated slashes are squeezed except a leading doubled slash '//'
+#       (which might indicate a networked disk on some OS).
+#
+#   REFERENCE_STRING is used to turn '/' into '\' and vice-versa: if
+#   REFERENCE_STRING contains some backslashes, all slashes and backslashes
+#   are turned into backslashes, otherwise they are all turned into slashes.
+#
+#   This makes processing of DOS filenames quite easier, because you can
+#   turn a filename to the Unix notation, make your processing, and turn it
+#   back to original notation.
+#
+#     filename='A:\FOO\\BAR\'
+#     old_filename="$filename"
+#     # Switch to the unix notation
+#     AX_NORMALIZE_PATH([filename], ["/"])
+#     # now we have $filename = 'A:/FOO/BAR' and we can process it as if
+#     # it was a Unix path.  For instance let's say that you want
+#     # to append '/subpath':
+#     filename="$filename/subpath"
+#     # finally switch back to the original notation
+#     AX_NORMALIZE_PATH([filename], ["$old_filename"])
+#     # now $filename equals to 'A:\FOO\BAR\subpath'
+#
+#   One good reason to make all path processing with the unix convention is
+#   that backslashes have a special meaning in many cases. For instance
+#
+#     expr 'A:\FOO' : 'A:\Foo'
+#
+#   will return 0 because the second argument is a regex in which
+#   backslashes have to be backslashed. In other words, to have the two
+#   strings to match you should write this instead:
+#
+#     expr 'A:\Foo' : 'A:\\Foo'
+#
+#   Such behavior makes DOS filenames extremely unpleasant to work with. So
+#   temporary turn your paths to the Unix notation, and revert them to the
+#   original notation after the processing. See the macro
+#   AX_COMPUTE_RELATIVE_PATHS for a concrete example of this.
+#
+#   REFERENCE_STRING defaults to $VARIABLE, this means that slashes will be
+#   converted to backslashes if $VARIABLE already contains some backslashes
+#   (see $thirddir below).
+#
+#     firstdir='/usr/local//share'
+#     seconddir='C:\Program Files\\'
+#     thirddir='C:\home/usr/'
+#     AX_NORMALIZE_PATH([firstdir])
+#     AX_NORMALIZE_PATH([seconddir])
+#     AX_NORMALIZE_PATH([thirddir])
+#     # $firstdir = '/usr/local/share'
+#     # $seconddir = 'C:\Program Files'
+#     # $thirddir = 'C:\home\usr'
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Alexandre Duret-Lutz <adl@gnu.org>
+#
+#   This program is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation; either version 2 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <https://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+#serial 8
+
+AU_ALIAS([ADL_NORMALIZE_PATH], [AX_NORMALIZE_PATH])
+AC_DEFUN([AX_NORMALIZE_PATH],
+[case ":[$]$1:" in
+# change empty paths to '.'
+  ::) $1='.' ;;
+# strip trailing slashes
+  :*[[\\/]]:) $1=`echo "[$]$1" | sed 's,[[\\/]]*[$],,'` ;;
+  :*:) ;;
+esac
+# squeeze repeated slashes
+case ifelse($2,,"[$]$1",$2) in
+# if the path contains any backslashes, turn slashes into backslashes
+ *\\*) $1=`echo "[$]$1" | sed 's,\(.\)[[\\/]][[\\/]]*,\1\\\\,g'` ;;
+# if the path contains slashes, also turn backslashes into slashes
+ *) $1=`echo "[$]$1" | sed 's,\(.\)[[\\/]][[\\/]]*,\1/,g'` ;;
+esac])
+
+m4_include([macros/ax_nagios_get_distrib.m4])
+m4_include([macros/ax_nagios_get_files.m4])
+m4_include([macros/ax_nagios_get_inetd.m4])
+m4_include([macros/ax_nagios_get_init.m4])
+m4_include([macros/ax_nagios_get_os.m4])
+m4_include([macros/ax_nagios_get_paths.m4])
+m4_include([macros/ax_nagios_get_ssl.m4])

Разница между файлами не показана из-за своего большого размера
+ 211 - 362
configure


+ 33 - 42
configure.ac

@@ -8,6 +8,7 @@ m4_include([build-aux/custom_help.m4])
 AC_INIT([nrpe],[newdate],[nagios-users@lists.sourceforge.net],[nrpe],[https://www.nagios.org/downloads/nagios-core-addons/])
 AC_CONFIG_SRCDIR([src/nrpe.c])
 AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_MACRO_DIRS([macros])
 AC_PREFIX_DEFAULT(/usr/local/nagios)
 
 PKG_NAME=nrpe
@@ -53,21 +54,21 @@ dnl Figure out how to invoke "install" and what install options to use.
 AC_PROG_INSTALL
 
 dnl Get O/S, Distribution, init, inetd, system-specific directories
-AC_NAGIOS_GET_OS
-AC_NAGIOS_GET_DISTRIB_TYPE
-AC_NAGIOS_GET_INIT
-AC_NAGIOS_GET_INETD
-AC_NAGIOS_GET_PATHS
-AC_NAGIOS_GET_FILES
+AX_NAGIOS_GET_OS
+AX_NAGIOS_GET_DISTRIB_TYPE
+AX_NAGIOS_GET_INIT
+AX_NAGIOS_GET_INETD
+AX_NAGIOS_GET_PATHS
+AX_NAGIOS_GET_FILES
 
 if test "$dist_type" = solaris -a "$dist_ver" = 10; then
-	AC_DEFINE(SOLARIS_10,yes)
+	AC_DEFINE(SOLARIS_10,[1],[Set to 1 if we are on Solaris 10])
 fi
 
 dnl Do they just want to see where things will go?
 if test x${showdirs_only} = xyes; then
 	AC_CONFIG_FILES([paths])
-	AC_OUTPUT()
+	AC_OUTPUT
 	chmod 755 paths
 	./paths
 	exit 0
@@ -106,8 +107,6 @@ AC_PROG_CC
 AC_PROG_MAKE_SET
 
 dnl Checks for header files.
-AC_HEADER_STDC
-AC_HEADER_TIME
 AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(ctype.h dirent.h errno.h fcntl.h getopt.h grp.h inttypes.h)
 AC_CHECK_HEADERS(netdb.h pwd.h signal.h stdint.h strings.h string.h syslog.h)
@@ -121,7 +120,7 @@ AC_STRUCT_TM
 AC_TYPE_MODE_T
 AC_TYPE_PID_T
 AC_TYPE_SIZE_T
-AC_TYPE_SIGNAL
+
 AC_TYPE_GETGROUPS
 
 dnl Check lengths for later tests of u_int32_t and int32_t
@@ -171,36 +170,32 @@ AC_CHECK_TYPES([struct sockaddr_storage],[],[],[#include <sys/socket.h>])
 
 dnl Should we use seteuid() or setresuid()?
 AC_CHECK_FUNC(seteuid,
-	AC_DEFINE(SETEUID(id),[seteuid(id)]),
-	AC_DEFINE(SETEUID(id),[setresuid((uid_t) -1, id, (uid_t) -1)])
+	AC_DEFINE(SETEUID(id),[seteuid(id)],[Use seteuid() or setresuid() depending on the platform]),
+	AC_DEFINE(SETEUID(id),[setresuid((uid_t) -1, id, (uid_t) -1)],[Use seteuid() or setresuid() depending on the platform])
 )
 
 dnl Check for asprintf() and friends...
 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
-AC_TRY_LINK([#include <stdarg.h>
-va_list ap1,ap2;], [va_copy(ap1,ap2);],
-ac_cv_HAVE_VA_COPY=yes,
-ac_cv_HAVE_VA_COPY=no)])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
+va_list ap1,ap2;]], [[va_copy(ap1,ap2);]])],[ac_cv_HAVE_VA_COPY=yes],[ac_cv_HAVE_VA_COPY=no])])
 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
 	AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
 else
 	AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
-	AC_TRY_LINK([#include <stdarg.h>
-	va_list ap1,ap2;], [__va_copy(ap1,ap2);],
-	ac_cv_HAVE___VA_COPY=yes,
-	ac_cv_HAVE___VA_COPY=no)])
+	AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
+	va_list ap1,ap2;]], [[__va_copy(ap1,ap2);]])],[ac_cv_HAVE___VA_COPY=yes],[ac_cv_HAVE___VA_COPY=no])])
 	if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
 		AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
 	fi
 fi
 
-AC_CHECK_FUNC(vsnprintf,,SNPRINTF_O=./snprintf.o)
-AC_CHECK_FUNC(snprintf,,SNPRINTF_O=./snprintf.o)
-AC_CHECK_FUNC(asprintf,,SNPRINTF_O=./snprintf.o)
-AC_CHECK_FUNC(vasprintf,,SNPRINTF_O=./snprintf.o)
+AC_CHECK_FUNC(vsnprintf,,SNPRINTF_O=snprintf.o)
+AC_CHECK_FUNC(snprintf,,SNPRINTF_O=snprintf.o)
+AC_CHECK_FUNC(asprintf,,SNPRINTF_O=snprintf.o)
+AC_CHECK_FUNC(vasprintf,,SNPRINTF_O=snprintf.o)
 
 AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[
-AC_TRY_RUN([
+AC_RUN_IFELSE([AC_LANG_SOURCE([[
 #include <sys/types.h>
 #include <stdarg.h>
 void foo(const char *format, ...) {
@@ -223,13 +218,12 @@ void foo(const char *format, ...) {
 	exit(0);
 }
 main() { foo("hello"); }
-],
-ac_cv_HAVE_C99_VSNPRINTF=yes,ac_cv_HAVE_C99_VSNPRINTF=no,ac_cv_HAVE_C99_VSNPRINTF=cross)])
+]])],[ac_cv_HAVE_C99_VSNPRINTF=yes],[ac_cv_HAVE_C99_VSNPRINTF=no],[ac_cv_HAVE_C99_VSNPRINTF=cross])])
 if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
 	AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf])
 fi
 
-dnl AC_CHECK_FUNC(snprintf,AC_DEFINE(HAVE_SNPRINTF),SNPRINTF_O=./snprintf.o)
+dnl AC_CHECK_FUNC(snprintf,AC_DEFINE(HAVE_SNPRINTF),SNPRINTF_O=snprintf.o)
 
 dnl Check for getopt_long (Solaris)
 AC_CHECK_FUNCS([getopt_long],,AC_CHECK_LIB([iberty],[getopt_long],OTHERLIBS="$OTHERLIBS -liberty"))
@@ -252,8 +246,8 @@ if test x$check_for_tcpd != xno; then
 	AC_CHECK_LIB(wrap,main,[
 		LIBWRAPLIBS="$LIBWRAPLIBS -lwrap"
 		AC_DEFINE(HAVE_LIBWRAP,[1],[Have the TCP wrappers library])
-		AC_TRY_LINK([#include <tcpd.h>
-			],[int a = rfc931_timeout;],AC_DEFINE(HAVE_RFC931_TIMEOUT))
+		AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <tcpd.h>
+			]], [[int a = rfc931_timeout;]])],[AC_DEFINE(HAVE_RFC931_TIMEOUT, 1, Set to 1 if you have rfc931_timeout)],[])
 	],[
 		if test x$check_for_tcpd = xyes; then
 			AC_MSG_ERROR(--enable-tcpd specified but unable to locate libwrap.)
@@ -273,7 +267,7 @@ AC_CHECK_TYPE([socklen_t], ,[
 		curl_cv_socklen_t_equiv=
 		for arg2 in "struct sockaddr" void; do
 			for t in int size_t unsigned long "unsigned long"; do
-				AC_TRY_COMPILE([
+				AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 					#ifdef HAVE_SYS_TYPES_H
 					#include <sys/types.h>
 					#endif
@@ -282,13 +276,13 @@ AC_CHECK_TYPE([socklen_t], ,[
 					#endif
 
 					int getpeername (int, $arg2 *, $t *);
-				],[
+				]], [[
 					$t len;
 					getpeername(0,0,&len);
-				],[
+				]])],[
 					curl_cv_socklen_t_equiv="$t"
 					break
-				])
+				],[])
 			done
 		done
 
@@ -304,13 +298,10 @@ AC_CHECK_TYPE([socklen_t], ,[
 
 
 AC_MSG_CHECKING(for type of socket size)
-AC_TRY_COMPILE([#include <stdlib.h>
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
 #include <sys/types.h>
 #include <sys/socket.h>
-],
-[int a = send(1, (const void *)0, (size_t *) 0, (int *) 0);],
-[AC_DEFINE(SOCKET_SIZE_TYPE, size_t, [Socket Size Type]) AC_MSG_RESULT(size_t)],
-[AC_DEFINE(SOCKET_SIZE_TYPE, int, [Socket Size Type]) AC_MSG_RESULT(int)])
+]], [[int a = send(1, (const void *)0, (size_t *) 0, (int *) 0);]])],[AC_DEFINE(SOCKET_SIZE_TYPE, size_t, [Socket Size Type]) AC_MSG_RESULT(size_t)],[AC_DEFINE(SOCKET_SIZE_TYPE, int, [Socket Size Type]) AC_MSG_RESULT(int)])
 
 dnl Does user want to check for SSL?
 AC_ARG_ENABLE([ssl],
@@ -332,7 +323,7 @@ dnl Optional SSL library and include paths
 if test x$check_for_ssl = xyes; then
 	# need_dh should only be set for NRPE
 	#need_dh=yes
-	AC_NAGIOS_GET_SSL
+	AX_NAGIOS_GET_SSL
 fi
 
 AC_ARG_WITH([log_facility],
@@ -389,7 +380,7 @@ AC_ARG_ENABLE([bash-command-substitution],
 
 
 AC_PATH_PROG(PERL,perl)
-AC_OUTPUT()
+AC_OUTPUT
 
 dnl Review options
 echo ""

+ 3 - 13
include/config.h.in

@@ -247,22 +247,12 @@ typedef int int32_t;
 #include <errno.h>
 #endif
 
-/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
-#undef TIME_WITH_SYS_TIME
-
 /* Define to 1 if you have the <sys/time.h> header file. */
 #undef HAVE_SYS_TIME_H
-
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>
 #endif
+#include <time.h>
 
 
 /* Define to 1 if you have the <sys/socket.h> header file. */

+ 1 - 1
include/nrpe-ssl.h

@@ -27,7 +27,7 @@ typedef struct _SSL_PARMS {
 
 
 #ifdef HAVE_SSL
-# if (defined(__sun) && defined(SOLARIS_10)) || defined(_AIX) || defined(__hpux)
+# if (defined(__sun) && defined(SOLARIS_10)) || defined(__hpux)
 extern SSL_METHOD *meth;
 # else
 extern const SSL_METHOD *meth;

+ 21 - 21
macros/README.md

@@ -18,7 +18,7 @@ Contents
 
 The collection consists of the following macros:
 
-### AX_NAGIOS_GET_OS alias AC_NAGIOS_GET_OS
+### AX_NAGIOS_GET_OS
 
 > Output Variable : `opsys`
 
@@ -26,7 +26,7 @@ This macro detects the operating system, and transforms it into a generic
 label. The most common OS's that use Nagios software are recognized and
 used in subsequent macros.
 
-### AX_NAGIOS_GET_DISTRIB_TYPE alias AC_NAGIOS_GET_DISTRIB_TYPE
+### AX_NAGIOS_GET_DISTRIB_TYPE
 
 > Output Variables : `dist_type`, `dist_ver`
 
@@ -36,7 +36,7 @@ This macro detects the distribution type. For Linux, this would be rh
 For BSD, this would be openbsd, netbsd, freebsd, dragonfly, etc. It can
 also be aix, solaris, osx, and so on for Unix operating systems.
 
-### AX_NAGIOS_GET_INIT alias AC_NAGIOS_GET_INIT
+### AX_NAGIOS_GET_INIT
 
 > Output Variable : `init_type`
 
@@ -46,7 +46,7 @@ will generally be one of sysv (many), bsd (Slackware), newbsd (*BSD),
 launchd (OS X), smf10 or smf11 (Solaris), systemd (newer Linux),
 gentoo (older Gentoo), upstart (several), or unknown.
 
-### AX_NAGIOS_GET_INETD alias AC_NAGIOS_GET_INETD
+### AX_NAGIOS_GET_INETD
 
 > Output Variable : `inetd_type`
 
@@ -55,7 +55,7 @@ on demand, which historically has been "inetd". The inetd_type
 will generally be one of inetd, xinetd, launchd (OS X), smf10 or smf11
 (Solaris), systemd (newer Linux), upstart (several), or unknown.
 
-### AX_NAGIOS_GET_PATHS alias AC_NAGIOS_GET_PATHS
+### AX_NAGIOS_GET_PATHS
 
 > Output Variables : **many!**
 
@@ -67,7 +67,7 @@ located in /etc. For distributions or software repositories, the
 O/S dependant directories, such as /usr/bin, /usr/sbin, /var/lib/nagios,
 /usr/lib/nagios, etc. or for OS X, /Library/LaunchDaemons.
 
-### AX_NAGIOS_GET_FILES alias AC_NAGIOS_GET_FILES
+### AX_NAGIOS_GET_FILES
 
 > Output Variables : `src_init`, `src_inetd`, `src_tmpfile`
 
@@ -76,7 +76,7 @@ In that directory will be "*.in" files for the various "init_type" and
 "inetd_type" systems. This macro will determine which file(s) from
 that directory will be needed.
 
-### AX_NAGIOS_GET_SSL alias AC_NAGIOS_GET_SSL
+### AX_NAGIOS_GET_SSL
 
 > Output Variables : `HAVE_KRB5_H`, `HAVE_SSL`, `SSL_INC_DIR`, `SSL_LIB_DIR`, `CFLAGS`, `LDFLAGS`, `LIBS`
 
@@ -138,28 +138,28 @@ reference it.
 
 * Create (or add these lines to) file `YourProject/aclocal.m4`
 
-           m4_include([macros/ax_nagios_get_os])
-           m4_include([macros/ax_nagios_get_distrib])
-           m4_include([macros/ax_nagios_get_init])
-           m4_include([macros/ax_nagios_get_inetd])
-           m4_include([macros/ax_nagios_get_paths])
-           m4_include([macros/ax_nagios_get_files])
-           m4_include([macros/ax_nagios_get_ssl])
+           m4_include([macros/ax_nagios_get_os.m4])
+           m4_include([macros/ax_nagios_get_distrib.m4])
+           m4_include([macros/ax_nagios_get_init.m4])
+           m4_include([macros/ax_nagios_get_inetd.m4])
+           m4_include([macros/ax_nagios_get_paths.m4])
+           m4_include([macros/ax_nagios_get_files.m4])
+           m4_include([macros/ax_nagios_get_ssl.m4])
 
 * In your `YourProject/configure.ac` add the following lines. A good place
 to put them would be right after any `AC_PROG_*` entries:
 
-           AC_NAGIOS_GET_OS
-           AC_NAGIOS_GET_DISTRIB_TYPE
-           AC_NAGIOS_GET_INIT
-           AC_NAGIOS_GET_INETD
-           AC_NAGIOS_GET_PATHS
-           AC_NAGIOS_GET_FILES
+           AX_NAGIOS_GET_OS
+           AX_NAGIOS_GET_DISTRIB_TYPE
+           AX_NAGIOS_GET_INIT
+           AX_NAGIOS_GET_INETD
+           AX_NAGIOS_GET_PATHS
+           AX_NAGIOS_GET_FILES
 
 * If you need SSL functionality, add the following to `YourProject/configure.ac`
 where you want to check for SSL:
 
-           AC_NAGIOS_GET_SSL
+           AX_NAGIOS_GET_SSL
 
 * You will now be able to reference any of the variables in `config.h.in`
 and any files listed in the `AC_CONFIG_FILES` macro in `configure.ac`.

+ 1 - 3
macros/ax_nagios_get_distrib → macros/ax_nagios_get_distrib.m4

@@ -44,7 +44,6 @@
 #   exception to the GPL to apply to your modified version as well.
 # ===========================================================================
 
-AU_ALIAS([AC_NAGIOS_GET_DISTRIB_TYPE], [AX_NAGIOS_GET_DISTRIB_TYPE])
 AC_DEFUN([AX_NAGIOS_GET_DISTRIB_TYPE],
 [
 
@@ -55,8 +54,7 @@ AC_SUBST(dist_ver)
 # Get user hints for possible cross-compile
 #
 	AC_MSG_CHECKING(what the distribution type is )
-	AC_ARG_WITH(dist-type, AC_HELP_STRING([--with-dist-type=type],
-	[specify distribution type (suse, rh, debian, etc.)]),
+	AC_ARG_WITH(dist-type, AS_HELP_STRING([--with-dist-type=type],[specify distribution type (suse, rh, debian, etc.)]),
 		[
 			#
 			# Run this if --with was specified

+ 0 - 1
macros/ax_nagios_get_files → macros/ax_nagios_get_files.m4

@@ -41,7 +41,6 @@
 #   exception to the GPL to apply to your modified version as well.
 # ===========================================================================
 
-AU_ALIAS([AC_NAGIOS_GET_FILES], [AX_NAGIOS_GET_FILES])
 AC_DEFUN([AX_NAGIOS_GET_FILES],
 [
 

+ 1 - 3
macros/ax_nagios_get_inetd → macros/ax_nagios_get_inetd.m4

@@ -48,7 +48,6 @@
 #   exception to the GPL to apply to your modified version as well.
 # ===========================================================================
 
-AU_ALIAS([AC_NAGIOS_GET_INETD], [AX_NAGIOS_GET_INETD])
 AC_DEFUN([AX_NAGIOS_GET_INETD],
 [
 
@@ -58,8 +57,7 @@ AC_SUBST(inetd_type)
 # Get user hints for possible cross-compile
 #
 	AC_MSG_CHECKING(what inetd is being used )
-	AC_ARG_WITH(inetd_type, AC_HELP_STRING([--with-inetd-type=type],
-	[which super-server the system runs (inetd, xinetd, systemd, launchd,
+	AC_ARG_WITH(inetd_type, AS_HELP_STRING([--with-inetd-type=type],[which super-server the system runs (inetd, xinetd, systemd, launchd,
 	 smf10, smf11, etc.)]),
 		[
 			inetd_type_wanted=yes

+ 1 - 3
macros/ax_nagios_get_init → macros/ax_nagios_get_init.m4

@@ -50,7 +50,6 @@
 #   exception to the GPL to apply to your modified version as well.
 # ===========================================================================
 
-AU_ALIAS([AC_NAGIOS_GET_INIT], [AX_NAGIOS_GET_INIT])
 AC_DEFUN([AX_NAGIOS_GET_INIT],
 [
 
@@ -60,8 +59,7 @@ AC_SUBST(init_type)
 # Get user hints for possible cross-compile
 #
 	AC_MSG_CHECKING(what init system is being used )
-	AC_ARG_WITH(init_type,AC_HELP_STRING([--with-init-type=type],
-	 [specify init type (bsd, sysv, systemd, launchd, smf10, smf11, upstart,
+	AC_ARG_WITH(init_type,AS_HELP_STRING([--with-init-type=type],[specify init type (bsd, sysv, systemd, launchd, smf10, smf11, upstart,
 		openrc, etc.)]),
 		[
 			#

+ 1 - 3
macros/ax_nagios_get_os → macros/ax_nagios_get_os.m4

@@ -38,7 +38,6 @@
 #   exception to the GPL to apply to your modified version as well.
 # ===========================================================================
 
-AU_ALIAS([AC_NAGIOS_GET_OS], [AX_NAGIOS_GET_OS])
 AC_DEFUN([AX_NAGIOS_GET_OS],
 [
 
@@ -49,8 +48,7 @@ AC_SUBST(arch)
 # Get user hints
 #
 	AC_MSG_CHECKING(what the operating system is )
-	AC_ARG_WITH(opsys, AC_HELP_STRING([--with-opsys=OS],
-	[specify operating system (linux, osx, bsd, solaris, irix, cygwin,
+	AC_ARG_WITH(opsys, AS_HELP_STRING([--with-opsys=OS],[specify operating system (linux, osx, bsd, solaris, irix, cygwin,
 	 aix, hp-ux, etc.)]),
 		[
 			#

+ 12 - 25
macros/ax_nagios_get_paths → macros/ax_nagios_get_paths.m4

@@ -43,7 +43,6 @@
 #   exception to the GPL to apply to your modified version as well.
 # ===========================================================================
 
-AU_ALIAS([AC_NAGIOS_GET_PATHS], [AX_NAGIOS_GET_PATHS])
 AC_DEFUN([AX_NAGIOS_GET_PATHS],
 [
 
@@ -87,8 +86,7 @@ fi
 AC_MSG_CHECKING(for which paths to use )
 
 AC_ARG_ENABLE(install_method,
-	AC_HELP_STRING([--enable-install-method=<method>],
-	[sets the install method to use: 'default' (the default) will install to
+	AS_HELP_STRING([--enable-install-method=<method>],[sets the install method to use: 'default' (the default) will install to
 	/usr/local/nagios, 'os' will try to determine which method to use based
 	on OS type and distribution. Fine tuning using the '--bindir', etc.
 	overrides above will still work]),
@@ -97,8 +95,7 @@ AC_ARG_ENABLE(install_method,
 )
 
 AC_ARG_ENABLE(showdirs_only,
-	AC_HELP_STRING([--enable-showdirs-only=yes],
-	[This option will cause 'configure' to stop after determining the install
+	AS_HELP_STRING([--enable-showdirs-only=yes],[This option will cause 'configure' to stop after determining the install
 	 locations based on '--enable-install-method', so you can see the
 	 destinations before a full './configure', 'make', 'make install'
 	 process.]),
@@ -162,53 +159,43 @@ AS_CASE([$PKG_NAME],
 		need_plg=yes
 )
 
-AC_ARG_WITH(pkgsysconfdir, AC_HELP_STRING([--with-pkgsysconfdir=DIR],
-	[where configuration files should be placed]),
+AC_ARG_WITH(pkgsysconfdir, AS_HELP_STRING([--with-pkgsysconfdir=DIR],[where configuration files should be placed]),
 	if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
 		pkgsysconfdir="$withval"
 	fi)
-AC_ARG_WITH(objsysconfdir, AC_HELP_STRING([--with-objsysconfdir=DIR],
-	[where object configuration files should be placed]),
+AC_ARG_WITH(objsysconfdir, AS_HELP_STRING([--with-objsysconfdir=DIR],[where object configuration files should be placed]),
 	if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
 		objsysconfdir="$withval"
 	fi)
-AC_ARG_WITH(privatesysconfdir, AC_HELP_STRING([--with-privatesysconfdir=DIR],
-	[where private configuration files should be placed]),
+AC_ARG_WITH(privatesysconfdir, AS_HELP_STRING([--with-privatesysconfdir=DIR],[where private configuration files should be placed]),
 	if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
 		privatesysconfdir="$withval"
 	fi)
-AC_ARG_WITH(webdir, AC_HELP_STRING([--with-webdir=DIR],
-	[where the website files should be placed]),
+AC_ARG_WITH(webdir, AS_HELP_STRING([--with-webdir=DIR],[where the website files should be placed]),
 	if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
 		webdir="$withval"
 	fi)
-AC_ARG_WITH(pluginsdir, AC_HELP_STRING([--with-pluginsdir=DIR],
-	[where the plugins should be placed]),
+AC_ARG_WITH(pluginsdir, AS_HELP_STRING([--with-pluginsdir=DIR],[where the plugins should be placed]),
 	if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
 		pluginsdir="$withval"
 	fi)
-AC_ARG_WITH(brokersdir, AC_HELP_STRING([--with-brokersdir=DIR],
-	[where the broker modules should be placed]),
+AC_ARG_WITH(brokersdir, AS_HELP_STRING([--with-brokersdir=DIR],[where the broker modules should be placed]),
 	if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
 		brokersdir="$withval"
 	fi)
-AC_ARG_WITH(cgibindir, AC_HELP_STRING([--with-cgibindir=DIR],
-	[where the CGI programs should be placed]),
+AC_ARG_WITH(cgibindir, AS_HELP_STRING([--with-cgibindir=DIR],[where the CGI programs should be placed]),
 	if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
 		cgibindir="$withval"
 	fi)
-AC_ARG_WITH(logdir, AC_HELP_STRING([--with-logdir=DIR],
-	[where log files should be placed]),
+AC_ARG_WITH(logdir, AS_HELP_STRING([--with-logdir=DIR],[where log files should be placed]),
 	if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
 		logdir="$withval"
 	fi)
-AC_ARG_WITH(piddir, AC_HELP_STRING([--with-piddir=DIR],
-	[where the PID file should be placed]),
+AC_ARG_WITH(piddir, AS_HELP_STRING([--with-piddir=DIR],[where the PID file should be placed]),
 	if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
 		piddir="$withval"
 	fi)
-AC_ARG_WITH(pipedir, AC_HELP_STRING([--with-pipedir=DIR],
-	[where socket and pipe files should be placed]),
+AC_ARG_WITH(pipedir, AS_HELP_STRING([--with-pipedir=DIR],[where socket and pipe files should be placed]),
 	if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
 		pipedir="$withval"
 	fi)

+ 90 - 56
macros/ax_nagios_get_ssl → macros/ax_nagios_get_ssl.m4

@@ -40,7 +40,6 @@
 #   exception to the GPL to apply to your modified version as well.
 # ===========================================================================
 
-AU_ALIAS([AC_NAGIOS_GET_SSL], [AX_NAGIOS_GET_SSL])
 AC_DEFUN([AX_NAGIOS_GET_SSL],
 [
 
@@ -76,14 +75,6 @@ generate_dh_params: \$(srcdir)/generate_dh_params.c
 	\$(CC) \$(CFLAGS) -o \@S|@@ \$(srcdir)/generate_dh_params.c \$(LDFLAGS)"
 
 
-# gnutls/openssl.h
-# nss_compat_ossl/nss_compat_ossl.h
-
-dnl # Which type - openssl, gnutls-openssl, nss
-dnl AC_ARG_WITH([ssl-type],
-dnl dnl	AS_HELP_STRING([--with-ssl-type=TYPE],[replace TYPE with gnutls or nss to use one of these instead of openssl]),
-dnl 	AS_HELP_STRING([--with-ssl-type=TYPE],[replace TYPE with gnutls to use that instead of openssl]),
-dnl 	[SSL_TYPE=$withval])
 
 AC_ARG_WITH([ssl],
 	AS_HELP_STRING([--with-ssl=DIR],[sets location of the SSL installation]),
@@ -116,10 +107,11 @@ fi
 
 
 dflt_hdrs="$ssl_inc_dir $ssl_dir $ssl_inc_dir/include $ssl_dir/include \
+			/usr/include /usr /usr/local /usr/pkg /usr/sfw /usr/sfw/include \
 			/usr/local/opt/{BBB} /usr/include/{BBB} /usr/local/include/{BBB} \
 			/usr/local/{AAA} /usr/local/{BBB} /usr/lib/{AAA} /usr/lib/{BBB} \
-			/usr/{AAA} /usr/pkg /usr/local /usr /usr/freeware/lib/{BBB} \
-			/usr/sfw /usr/sfw/include /opt/{BBB}"
+			/usr/{AAA} /usr/freeware/lib/{BBB} /opt/{BBB}"
+
 
 dflt_libs="$ssl_lib_dir {ssldir} {ssldir}/lib {ssldir}/lib64 /usr/lib64 \
 			/usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu \
@@ -137,32 +129,20 @@ AS_CASE([$SSL_TYPE],
 		 SSL_INC_PREFIX=openssl
 		 SSL_HDR=ssl.h
 		 ssl_lib=libssl],
-	[gnutls],
-		[ssl_hdr_dirs=`echo "$dflt_hdrs" | sed -e 's/{AAA}/gnutls/g' | sed -e 's/{BBB}/gnutls/g'`
-		 ssl_lib_dirs=`echo "$dflt_libs" | sed -e 's/{AAA}/gnutls/g' | sed -e 's/{BBB}/gnutls/g'`
-		 SSL_INC_PREFIX=gnutls
-		 SSL_TYPE=gnutls_compat
-		 SSL_HDR=compat.h
-		 ssl_lib=libgnutls],
-	[nss],
-		[ssl_hdr_dirs=`echo "$dflt_hdrs" | sed -e 's/{AAA}/nss_compat_ossl/g' | sed -e 's/{BBB}/nss_compat_ossl/g'`
-		 ssl_lib_dirs=`echo "$dflt_libs" | sed -e 's/{AAA}/nss_compat_ossl/g' | sed -e 's/{BBB}/nss_compat_ossl/g'`
-		 SSL_HDR=nss_compat_ossl.h
-		 ssl_lib=libnss_compat],
 	[*], echo >&6; AC_MSG_ERROR(['--with-ssl-type=$SSL_TYPE' is invalid])
 )
 
 
-# Check for SSL support
+dnl Check for SSL support
 
 if test x$SSL_TYPE != xNONE; then
 
 	found_ssl=no
 
-	# RedHat 8.0 and 9.0 include openssl compiled with kerberos,
-	# so we must include header file
-	# Must come before openssl checks for Redhat EL 3
-	AC_MSG_CHECKING(for Kerberos include files)
+	dnl RedHat 8.0 and 9.0 include openssl compiled with kerberos,
+	dnl so we must include header file
+	dnl Must come before openssl checks for Redhat EL 3
+	AC_MSG_CHECKING([for Kerberos include files])
 	found_kerberos=no
 	for dir in $kerberos_inc_dir /usr/kerberos/include /usr/include/krb5 \
 				/usr/include; do
@@ -170,18 +150,18 @@ if test x$SSL_TYPE != xNONE; then
 		if test -f "$dir/krb5.h"; then
 			found_kerberos=yes
 			CFLAGS="$CFLAGS -I$kerbdir"
-			AC_DEFINE_UNQUOTED(HAVE_KRB5_H,[1],[Have the krb5.h header file])
+			AC_DEFINE([HAVE_KRB5_H],[1],[Have the krb5.h header file])
 			break
 		fi
 	done
 
 	if test x_$found_kerberos != x_yes; then
-		AC_MSG_WARN(could not find include files)
+		AC_MSG_WARN([could not find include files])
 	else
-		AC_MSG_RESULT(found Kerberos include files in $kerbdir)
+		AC_MSG_RESULT([found Kerberos include files in $kerbdir])
 	fi
 
-	# First, try using pkg_config
+	dnl First, try using pkg_config
 	if test $try_pkg_config -ne 0 ; then
 		AC_CHECK_TOOL([PKG_CONFIG], [pkg-config])
 	fi
@@ -192,14 +172,23 @@ if test x$SSL_TYPE != xNONE; then
 			LDFLAGS="$LDFLAGS `$PKG_CONFIG $SSL_TYPE --libs-only-L 2>/dev/null`"
 			LIBS="$LIBS `$PKG_CONFIG $SSL_TYPE --libs-only-l 2>/dev/null`"
 			found_ssl=yes
-			AC_DEFINE_UNQUOTED(HAVE_SSL,[1],[Have SSL support])
 		fi
 	fi
 
+	ax_nagios_run_ssl_save_LIBS=$LIBS
+	if test "x_$found_ssl" != "x_yes"; then
+		LIBS="$LIBS -l`echo $ssl_lib | sed -e 's/^lib//'` -lcrypto";
+	fi
+
+	dnl Next try just compiling with default settings (unless inc/lib were specified)
+	if test "x_$found_ssl" != "x_yes" && test "x$ssl_inc_dir" == "x" && test "x$ssl_lib_dir" == "x"; then
+		_AX_NAGIOS_RUN_SSL([found_ssl=yes])
+	fi
+
 	if test x_$found_ssl != x_yes; then
 
-		# Find the SSL Headers
-		AC_MSG_CHECKING(for SSL headers)
+		dnl Find the SSL Headers
+		AC_MSG_CHECKING([for SSL headers])
 		for dir in $ssl_hdr_dirs; do
 			if test "$dir" = "/include"; then
 				continue
@@ -236,13 +225,16 @@ if test x$SSL_TYPE != xNONE; then
 		done
 
 		if test x_$found_ssl != x_yes; then
-			AC_MSG_ERROR(Cannot find ssl headers)
+			AC_MSG_ERROR([Cannot find ssl headers])
 		else
-			AC_MSG_RESULT(found in $sslincdir)
+			AX_NORMALIZE_PATH([sslincdir])
+			AC_MSG_RESULT([found in $sslincdir])
+
+			dnl Now try and find SSL libraries
 
-			# Now try and find SSL libraries
+			AX_CHECK_LINK_FLAG([-Wl,-rpath,/], [RPATH=yes], [RPATH=no])
 
-			AC_MSG_CHECKING(for SSL libraries)
+			AC_MSG_CHECKING([for SSL libraries])
 			found_ssl=no
 			ssl_lib_dirs=`echo "$ssl_lib_dirs" | sed -e "s|{ssldir}|$ssldir|g"`
 
@@ -274,13 +266,23 @@ if test x$SSL_TYPE != xNONE; then
 			done
 
 			if test x_$found_ssl != x_yes; then
-				AC_MSG_ERROR(Cannot find ssl libraries)
+				AC_MSG_ERROR([Cannot find ssl libraries])
 			else
-				AC_MSG_RESULT(found in $SSL_LIB_DIR)
-
-				LDFLAGS="$LDFLAGS -L$SSL_LIB_DIR -Wl,-rpath,$SSL_LIB_DIR";
-				LIBS="$LIBS -l`echo $ssl_lib | sed -e 's/^lib//'` -lcrypto";
-				AC_DEFINE_UNQUOTED(HAVE_SSL,[1],[Have SSL support])
+				AX_NORMALIZE_PATH([SSL_LIB_DIR])
+				AC_MSG_RESULT([found in $SSL_LIB_DIR])
+
+				LDFLAGS="$LDFLAGS -L$SSL_LIB_DIR";
+
+				if test x$RPATH == xyes ; then
+					# Do we need to add rpath?
+					AC_MSG_CHECKING([checking if rpath is required...])
+					_AX_NAGIOS_RUN_SSL(
+						[AC_MSG_RESULT([no])],
+						[AC_MSG_RESULT([yes])
+						 LDFLAGS="$LDFLAGS -Wl,-rpath,$SSL_LIB_DIR"],
+						[AC_MSG_RESULT([no])]
+					)
+				fi
 			fi
 		fi
 	fi
@@ -290,7 +292,7 @@ if test x$SSL_TYPE != xNONE; then
 			SSL_INC_PREFIX="${SSL_INC_PREFIX}/"
 		fi
 
-		# try to compile and link to see if SSL is set up properly
+		dnl try to compile and link to see if SSL is set up properly
 		AC_MSG_CHECKING([whether compiling and linking against SSL works])
 
 		AC_LINK_IFELSE(
@@ -298,6 +300,7 @@ if test x$SSL_TYPE != xNONE; then
 			[
 				AC_MSG_RESULT([yes])
 				SSL_OBJS="nrpe-ssl.o"
+				AC_DEFINE([HAVE_SSL], [1], [Have SSL support])
 				$1
 			], [
 				AC_MSG_ERROR([no])
@@ -305,6 +308,12 @@ if test x$SSL_TYPE != xNONE; then
 			])
 	fi
 
+	dnl Detection finished. Reset LIBS if we did not succeed
+	if test "x_$found_ssl" != "x_yes"; then
+		LIBS=$ax_nagios_run_ssl_save_LIBS
+	fi
+
+
 	if test x$found_ssl = xyes -a x$need_dh = xyes; then
 
 		AC_LINK_IFELSE([dnl
@@ -325,15 +334,15 @@ if test x$SSL_TYPE != xNONE; then
 				SSL_MAJOR=$(echo $nagios_ssl_version | cut -d' ' -f1)
 				SSL_MINOR=$(echo $nagios_ssl_version | cut -d' ' -f2)
 			],
-			AC_MSG_ERROR(Failed to detect OpenSSL version!))
+			AC_MSG_ERROR([Failed to detect OpenSSL version!]))
 
 		if test x$auto_dh = xyes -a $SSL_MAJOR -lt 1 -o \( $SSL_MAJOR -eq 1 -a $SSL_MINOR -lt 1 \); then
-			# auto_dh not available before v1.1.0
+			dnl auto_dh not available before v1.1.0
 			auto_dh=no
 		fi
 
 		if test x$auto_dh = xyes; then
-			AC_DEFINE(AUTO_SSL_DH)
+			AC_DEFINE([AUTO_SSL_DH], [1], [Define to 1 to auto configure SSL DH parameters])
 		fi
 
 
@@ -342,19 +351,44 @@ if test x$SSL_TYPE != xNONE; then
 		if test x$need_dh = xyes ; then
 			if test x$auto_dh = xno ; then
 				if test $SSL_MAJOR -lt 3 ; then
-					# Find the openssl program
-					# Only need openssl binary if we're not using auto or using version less than 3.0
-					AC_PATH_PROG(sslbin,openssl,value-if-not-found,${ssldir}/sbin${PATH_SEPARATOR}${ssldir}/bin${PATH_SEPARATOR}${PATH})
+					dnl Find the openssl program
+					dnl Only need openssl binary if we are not using auto or using version less than 3.0
+					AC_PATH_PROG([sslbin],[openssl],[value-if-not-found],[${ssldir}/sbin${PATH_SEPARATOR}${ssldir}/bin${PATH_SEPARATOR}${PATH}])
 
-					AC_SUBST(SSL_DH_HEADER_MAKE, ${SSL_DH_HEADER_MAKE_OLD})
+					AC_SUBST([SSL_DH_HEADER_MAKE], [${SSL_DH_HEADER_MAKE_OLD}])
 				else
-					AC_SUBST(SSL_DH_HEADER_MAKE, ${SSL_DH_HEADER_MAKE_NEW})
+					AC_SUBST([SSL_DH_HEADER_MAKE], [${SSL_DH_HEADER_MAKE_NEW}])
 				fi
 
-				AC_SUBST(SSL_DH_HEADER,../include/dh.h)
+				AC_SUBST([SSL_DH_HEADER],[../include/dh.h])
 			fi
-			AC_DEFINE(USE_SSL_DH)
+			AC_DEFINE([USE_SSL_DH], [1], [Define to 1 to use SSL DH])
 		fi
 	fi
 fi
 ])
+
+
+# _AX_NAGIOS_RUN_SSL([action-if-true], [action-if-false], [action-if-cross-compiling])
+AC_DEFUN([_AX_NAGIOS_RUN_SSL], [
+	tmp_prefix=""
+	if test -n "$SSL_INC_PREFIX" ; then
+		tmp_prefix="${SSL_INC_PREFIX}/"
+	fi
+
+	AC_RUN_IFELSE(
+		[AC_LANG_PROGRAM([
+			#include <${tmp_prefix}opensslv.h>
+			#include <${tmp_prefix}crypto.h>
+		],[
+			#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+				return OpenSSL_version_num() == OPENSSL_VERSION_NUMBER ? EXIT_SUCCESS : EXIT_FAILURE;
+			#else
+				return SSLeay() == OPENSSL_VERSION_NUMBER ? EXIT_SUCCESS : EXIT_FAILURE;
+			#endif
+		])],
+		[$1],
+		[$2],
+		[$3]
+	)
+])

+ 4 - 1
src/Makefile.in

@@ -14,7 +14,7 @@ CFG_INCLUDE=../include
 # DESTDIR=
 
 CC=@CC@
-CFLAGS=@CFLAGS@ @DEFS@ -I $(CFG_INCLUDE) -I $(SRC_INCLUDE)
+CFLAGS=-I $(CFG_INCLUDE) -I $(SRC_INCLUDE) @CFLAGS@ @DEFS@
 LDFLAGS=@LDFLAGS@ @LIBS@
 SOCKETLIBS=@SOCKETLIBS@
 LIBWRAPLIBS=@LIBWRAPLIBS@
@@ -55,6 +55,9 @@ check_nrpe: $(srcdir)/check_nrpe.c utils.o $(SRC_INCLUDE)/utils.h $(CFG_INCLUDE)
 utils.o: $(srcdir)/utils.c $(SRC_INCLUDE)/utils.h $(CFG_INCLUDE)/common.h $(CFG_INCLUDE)/config.h
 	$(CC) $(CFLAGS) -c -o $@ $(srcdir)/utils.c
 
+snprintf.o: $(srcdir)/snprintf.c
+	$(CC) $(CFLAGS) -c -o $@ $(srcdir)/snprintf.c
+
 nrpe-ssl.o: $(srcdir)/nrpe-ssl.c $(SRC_INCLUDE)/nrpe-ssl.h $(CFG_INCLUDE)/common.h $(CFG_INCLUDE)/config.h
 	$(CC) $(CFLAGS) -c -o $@ $(srcdir)/nrpe-ssl.c
 

+ 1 - 1
src/check_nrpe.c

@@ -950,7 +950,7 @@ int connect_to_remote(void)
 			logit(LOG_NOTICE, "Remote %s - SSL Version: %s", rem_host, SSL_get_version(ssl));
 
 		if (sslprm.log_opts & SSL_LogCipher) {
-# if (defined(__sun) && defined(SOLARIS_10)) || defined(_AIX) || defined(__hpux)
+# if (defined(__sun) && defined(SOLARIS_10)) || defined(__hpux)
 			SSL_CIPHER *c = SSL_get_current_cipher(ssl);
 # else
 			const SSL_CIPHER *c = SSL_get_current_cipher(ssl);

+ 1 - 1
src/nrpe-ssl.c

@@ -6,7 +6,7 @@
 #include "utils.h"
 
 #ifdef HAVE_SSL
-# if (defined(__sun) && defined(SOLARIS_10)) || defined(_AIX) || defined(__hpux)
+# if (defined(__sun) && defined(SOLARIS_10)) || defined(__hpux)
 SSL_METHOD *meth;
 # else
 const SSL_METHOD *meth;

+ 1 - 1
src/nrpe.c

@@ -1821,7 +1821,7 @@ void init_handle_conn(void)
 #ifdef HAVE_SSL
 int handle_conn_ssl(int sock, void *ssl_ptr)
 {
-# if (defined(__sun) && defined(SOLARIS_10)) || defined(_AIX) || defined(__hpux)
+# if (defined(__sun) && defined(SOLARIS_10)) || defined(__hpux)
 	SSL_CIPHER *c;
 #else
 	const SSL_CIPHER *c;

+ 2 - 0
src/snprintf.c

@@ -494,6 +494,7 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args
 				break;
 			case 'X':
 				cnk->flags |= DP_F_UP;
+				/* fallthrough */
 			case 'x':
 				cnk->type = CNK_HEX;
 				cnk->flags |= DP_F_UNSIGNED;
@@ -504,6 +505,7 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args
 			case 'G':
 			case 'F':
 				cnk->flags |= DP_F_UP;
+				/* fallthrough */
 			case 'a':
 				/* hex float not supported yet */
 			case 'e':

Некоторые файлы не были показаны из-за большого количества измененных файлов